diff --git a/.github/workflows/publish-pre-release.yml b/.github/workflows/publish-pre-release.yml new file mode 100644 index 0000000..ce34f3f --- /dev/null +++ b/.github/workflows/publish-pre-release.yml @@ -0,0 +1,62 @@ +name: Publish pre-release + +on: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + +jobs: + publish-package: + name: Publish package + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install dependencies + run: npm ci + + - name: Build package version + id: pkg + run: | + export PREID='${{ github.event_name == 'pull_request' && 'pr' || 'rc' }}' + export PREID_NUMBER_PR='${{ github.event.pull_request.number }}.${{ github.run_id }}' + export PREID_NUMBER_RC='${{ github.run_id }}' + export PREID_NUMBER="${{ github.event_name == 'pull_request' && '$PREID_NUMBER_PR' || '$PREID_NUMBER_RC' }}" + export CURRENT_VERSION=$(cat package.json | jq -r .version) + export VERSION="$CURRENT_VERSION-${PREID}.${PREID_NUMBER}" + export PACKAGE_NAME="$(cat package.json | jq -r .name)" + echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Publishing for version $VERSION" + + - name: Bump package.json version + run: | + git config --global user.email "${{github.actor}}" + git config --global user.name "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com" + npm version ${{ steps.pkg.outputs.version }} + + - name: Build + run: npm run embeddable:package + + - name: Publish + run: | + npm config set '//npm.pkg.github.com/:_authToken=${{ github.token }}' + npm publish + echo 'Install via npm:' >> $GITHUB_STEP_SUMMARY + echo '
npm install --save-exact ${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}' >> $GITHUB_STEP_SUMMARY
+ echo 'Install via yarn classic:' >> $GITHUB_STEP_SUMMARY
+ echo 'yarn add --exact ${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}' >> $GITHUB_STEP_SUMMARY
+ echo 'Install via package.json:' >> $GITHUB_STEP_SUMMARY
+ echo '"${{ steps.pkg.outputs.name }}": "${{ steps.pkg.outputs.version }}"' >> $GITHUB_STEP_SUMMARY
diff --git a/.npmrc b/.npmrc
index 4fd0219..42c07c8 100644
--- a/.npmrc
+++ b/.npmrc
@@ -1 +1,2 @@
-engine-strict=true
\ No newline at end of file
+engine-strict=true
+@syltek:registry=https://npm.pkg.github.com
diff --git a/README.md b/README.md
index 8f75de1..52d60c8 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+> [!IMPORTANT]
+> This is a fork of [emebeddable's vanilla components](https://github.com/embeddable-hq/vanilla-components-v1) check the [/docs](./docs) for more information.
+
# Embeddable.com Starter Pack
Hello and welcome to our Embeddable components **starter pack** built just for you by the Embeddable team ❤️ We wish to thank you for using our platform and welcome any feedback.
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 0000000..2a720ff
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,40 @@
+# `@syltek/syltek/embeddable-vanilla-components`
+
+## What is this repo?
+
+This repo is a fork of [`@embeddable.com/vanilla-components`](https://www.npmjs.com/package/@embeddable.com/vanilla-components) published as [`@syltek/syltek/embeddable-vanilla-components`](https://github.com/syltek/embeddable-vanilla-components/pkgs/npm/embeddable-vanilla-components) onto [npm Github Package Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry).
+
+## How to use it?
+
+Add `@syltek/syltek/embeddable-vanilla-components` as a dependency to your package. It is recommended you grab the latest version from [here](https://github.com/syltek/embeddable-vanilla-components/pkgs/npm/embeddable-vanilla-components/versions).
+
+New versions are published every time `main` or an open PR is updated. Stable changes (i.e: changes merged onto `main`) are released marked as `rc` while unstable changes (i.e: Pull Requests) are released marked as `pr`.
+
+### Working _locally_ with a repo that depends onto this one
+
+This is the main use case when working with [embeddable](https://github.com/syltek/embeddable). Let's say you are making changes onto this repo; but you want them reflected onto that one.
+
+Any local-development techniques (such as package linking, bundling and installing the zipped bundle…) would work; but in general those require some knowledge on how the dependency resolution for nodejs application work.
+
+Instead, we recommend you just open a PR here. The PR will trigger a run of the [pre-release publish](https://github.com/syltek/embeddable-vanilla-components/actions) workflow. Once that finishes the job summary will include a version you can install onto [embeddable](https://github.com/syltek/embeddable) and test the changes.
+
+## How to upgrade from the upstream?
+
+We refer to the default [embeddable vanilla components](https://github.com/embeddable-hq/vanilla-components-v1) as the _upstream_.
+
+From time to time we will want to merge their available new features and fixes into this fork. Here is a quick cheatsheet of the commands to do that:
+
+```bash
+git remote add -f embeddable git@github.com:embeddable-hq/vanilla-components-v1.git
+git checkout main
+git merge emebeddable/main
+```
+
+## Motivation
+
+We really like emeddable vanilla components; but we had some needs that were not properly covered:
+
+- lack of i18n support
+- missing "fine-grained" customizations on some dropdown elements (like the options available within the DateRangePicker)
+
+After some internal discussion and conversations with the embeddable team; we decided to fork the repo and
diff --git a/package.json b/package.json
index 8e6e8c2..2036287 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "@embeddable.com/vanilla-components",
+ "name": "@syltek/embeddable-vanilla-components",
"version": "1.0.7",
"type": "module",
"main": "dist/index.js",
@@ -8,8 +8,10 @@
"dist",
"README.md"
],
+ "repository": "https://github.com/syltek/embeddable-vanilla-components",
"publishConfig": {
- "access": "public"
+ "access": "public",
+ "registry": "https://npm.pkg.github.com"
},
"scripts": {
"embeddable:build": "embeddable build",
@@ -155,4 +157,4 @@
"tabWidth": 2,
"trailingComma": "all"
}
-}
+}
\ No newline at end of file
diff --git a/src/components/vanilla/controls/DatePicker/utils/dateUtils.ts b/src/components/vanilla/controls/DatePicker/utils/dateUtils.ts
index 7325042..8c0f209 100644
--- a/src/components/vanilla/controls/DatePicker/utils/dateUtils.ts
+++ b/src/components/vanilla/controls/DatePicker/utils/dateUtils.ts
@@ -36,6 +36,10 @@ export function getComparisonOptions(period: TimeRange) {
value: 'Previous period',
note: getNote(subDays(period.from, days), subDays(period.to, days)),
},
+ {
+ value: 'Previous week',
+ note: getNote(subDays(period.from, 7), subDays(period.to, 7)),
+ },
{
value: 'Previous month',
note: getNote(subMonths(period.from, 1), subMonths(period.to, 1)),
@@ -59,7 +63,13 @@ export function getComparisonPeriod(rts: string, period: TimeRange) {
to: new Date(),
};
}
- if (rts === 'Previous month') {
+ if (rts === 'Previous week') {
+ return {
+ relativeTimeString: 'previous week',
+ from: subDays(period.from, 7),
+ to: subDays(period.to, 7),
+ };
+ } else if (rts === 'Previous month') {
return {
relativeTimeString: 'previous month',
from: subMonths(period.from, 1),