Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/publish-pre-release.yml
Original file line number Diff line number Diff line change
@@ -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 '<pre><code>npm install --save-exact ${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}</code></pre>' >> $GITHUB_STEP_SUMMARY
echo 'Install via yarn classic:' >> $GITHUB_STEP_SUMMARY
echo '<pre><code>yarn add --exact ${{ steps.pkg.outputs.name }}@${{ steps.pkg.outputs.version }}</code></pre>' >> $GITHUB_STEP_SUMMARY
echo 'Install via package.json:' >> $GITHUB_STEP_SUMMARY
echo '<pre><code>"${{ steps.pkg.outputs.name }}": "${{ steps.pkg.outputs.version }}"</code></pre>' >> $GITHUB_STEP_SUMMARY
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
engine-strict=true
engine-strict=true
@syltek:registry=https://npm.pkg.github.com
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
40 changes: 40 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@embeddable.com/vanilla-components",
"name": "@syltek/embeddable-vanilla-components",
"version": "1.0.7",
"type": "module",
"main": "dist/index.js",
Expand All @@ -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",
Expand Down Expand Up @@ -155,4 +157,4 @@
"tabWidth": 2,
"trailingComma": "all"
}
}
}
12 changes: 11 additions & 1 deletion src/components/vanilla/controls/DatePicker/utils/dateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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),
Expand Down