From 2194970688fccf5ec94ada330686db7769bb4f92 Mon Sep 17 00:00:00 2001 From: Jean-Michel FRANCOIS Date: Wed, 11 Mar 2026 11:58:56 +0100 Subject: [PATCH 1/3] chore: save --- docs/plan-tsup-migration.md | 182 ++++++++++++++++ package.json | 1 + packages/a11y/libx/Gesture/constants.js | 4 + packages/a11y/libx/Gesture/constants.js.map | 1 + packages/a11y/libx/Gesture/focus.js | 52 +++++ packages/a11y/libx/Gesture/focus.js.map | 1 + packages/a11y/libx/Gesture/index.js | 16 ++ packages/a11y/libx/Gesture/index.js.map | 1 + packages/a11y/libx/Gesture/preventScroll.js | 21 ++ .../a11y/libx/Gesture/preventScroll.js.map | 1 + packages/a11y/libx/Gesture/propTypes.js | 1 + packages/a11y/libx/Gesture/propTypes.js.map | 1 + .../a11y/libx/Gesture/withCalendarGesture.js | 78 +++++++ .../libx/Gesture/withCalendarGesture.js.map | 1 + .../libx/Gesture/withDynamicListGesture.js | 86 ++++++++ .../Gesture/withDynamicListGesture.js.map | 1 + packages/a11y/libx/Gesture/withListGesture.js | 80 +++++++ .../a11y/libx/Gesture/withListGesture.js.map | 1 + .../libx/Gesture/withMonthCalendarGesture.js | 65 ++++++ .../Gesture/withMonthCalendarGesture.js.map | 1 + packages/a11y/libx/Gesture/withTreeGesture.js | 148 +++++++++++++ .../a11y/libx/Gesture/withTreeGesture.js.map | 1 + packages/a11y/libx/index.js | 3 + packages/a11y/libx/index.js.map | 1 + packages/a11y/libx/test-setup.js | 2 + packages/a11y/libx/test-setup.js.map | 1 + packages/a11y/package.json | 2 + packages/a11y/tsup.config.ts | 8 + packages/assets-api/libx/index.d.ts | 50 +++++ packages/assets-api/libx/index.js | 156 ++++++++++++++ packages/assets-api/libx/index.js.map | 1 + packages/assets-api/package.json | 2 + packages/assets-api/tsup.config.ts | 8 + packages/cmf-cqrs/package.json | 2 + packages/cmf-cqrs/tsup.config.ts | 8 + packages/cmf-router/package.json | 2 + packages/cmf-router/tsup.config.ts | 8 + packages/cmf/package.json | 2 + packages/cmf/tsup.config.ts | 8 + packages/components/package.json | 2 + packages/components/tsup.config.ts | 9 + packages/containers/package.json | 2 + packages/containers/tsup.config.ts | 9 + packages/dataviz/package.json | 2 + packages/dataviz/tsup.config.ts | 9 + packages/design-system/package.json | 2 + packages/design-system/tsup.config.ts | 11 + packages/design-tokens/package.json | 2 + packages/design-tokens/tsup.config.ts | 11 + .../faceted-search-query-client/package.json | 2 + .../tsup.config.ts | 8 + packages/faceted-search/package.json | 2 + packages/faceted-search/tsup.config.ts | 9 + packages/flow-designer/package.json | 2 + packages/flow-designer/tsup.config.ts | 8 + packages/forms/package.json | 2 + packages/forms/tsup.config.ts | 9 + packages/http/package.json | 2 + packages/http/tsup.config.ts | 8 + packages/router-bridge/package.json | 2 + packages/router-bridge/tsup.config.ts | 8 + packages/sagas/package.json | 2 + packages/sagas/tsup.config.ts | 8 + packages/stepper/libx/Stepper.constants.js | 16 ++ .../stepper/libx/Stepper.constants.js.map | 1 + .../StepFooter/StepFooter.component.js | 43 ++++ .../StepFooter/StepFooter.component.js.map | 1 + .../StepperForm/StepFooter/index.js | 3 + .../StepperForm/StepFooter/index.js.map | 1 + .../StepHeader/StepHeader.component.js | 19 ++ .../StepHeader/StepHeader.component.js.map | 1 + .../StepHeader/StepHeader.types.js | 1 + .../StepHeader/StepHeader.types.js.map | 1 + .../StepperForm/StepHeader/index.js | 3 + .../StepperForm/StepHeader/index.js.map | 1 + .../StepperForm/StepperForm.component.js | 51 +++++ .../StepperForm/StepperForm.component.js.map | 1 + .../StepperForm/StepperForm.context.js | 29 +++ .../StepperForm/StepperForm.context.js.map | 1 + .../StepperForm/StepperForm.module.css | 41 ++++ .../StepperForm/StepperForm.types.js | 1 + .../StepperForm/StepperForm.types.js.map | 1 + .../StepperForm/StepperForm.utils.js | 26 +++ .../StepperForm/StepperForm.utils.js.map | 1 + .../StepperFormContainer.component.js | 14 ++ .../StepperFormContainer.component.js.map | 1 + .../StepperForm/StepperFormContainer/index.js | 3 + .../StepperFormContainer/index.js.map | 1 + .../libx/components/StepperForm/index.js | 10 + .../libx/components/StepperForm/index.js.map | 1 + packages/stepper/libx/components/index.js | 4 + packages/stepper/libx/components/index.js.map | 1 + packages/stepper/libx/constants/i18n.js | 6 + packages/stepper/libx/constants/i18n.js.map | 1 + .../libx/containers/Stepper.connect.js | 9 + .../libx/containers/Stepper.connect.js.map | 1 + .../useStepperForm/useStepperForm.hook.js | 105 ++++++++++ .../useStepperForm/useStepperForm.hook.js.map | 1 + .../useStepperForm/useStepperForm.types.js | 7 + .../useStepperForm.types.js.map | 1 + packages/stepper/libx/index.js | 47 +++++ packages/stepper/libx/index.js.map | 1 + .../stepper/libx/service/Stepper.actions.js | 42 ++++ .../libx/service/Stepper.actions.js.map | 1 + .../stepper/libx/service/Stepper.reducer.js | 119 +++++++++++ .../libx/service/Stepper.reducer.js.map | 1 + .../stepper/libx/service/Stepper.selectors.js | 12 ++ .../libx/service/Stepper.selectors.js.map | 1 + .../stepper/libx/service/Stepper.utils.js | 3 + .../stepper/libx/service/Stepper.utils.js.map | 1 + .../libx/stories/Stepper.components.js | 186 +++++++++++++++++ .../libx/stories/Stepper.components.js.map | 1 + packages/stepper/libx/translate.js | 11 + packages/stepper/libx/translate.js.map | 1 + packages/stepper/package.json | 2 + packages/stepper/tsup.config.ts | 9 + packages/storybook-cmf/package.json | 2 + packages/storybook-cmf/tsup.config.ts | 8 + packages/storybook-docs/package.json | 2 + packages/storybook-docs/tsup.config.ts | 11 + packages/utils/package.json | 2 + packages/utils/tsup.config.ts | 8 + tools/scripts-config-tsup/package.json | 20 ++ tools/scripts-config-tsup/src/index.ts | 137 ++++++++++++ yarn.lock | 195 ++++++++++++++++-- 125 files changed, 2357 insertions(+), 14 deletions(-) create mode 100644 docs/plan-tsup-migration.md create mode 100644 packages/a11y/libx/Gesture/constants.js create mode 100644 packages/a11y/libx/Gesture/constants.js.map create mode 100644 packages/a11y/libx/Gesture/focus.js create mode 100644 packages/a11y/libx/Gesture/focus.js.map create mode 100644 packages/a11y/libx/Gesture/index.js create mode 100644 packages/a11y/libx/Gesture/index.js.map create mode 100644 packages/a11y/libx/Gesture/preventScroll.js create mode 100644 packages/a11y/libx/Gesture/preventScroll.js.map create mode 100644 packages/a11y/libx/Gesture/propTypes.js create mode 100644 packages/a11y/libx/Gesture/propTypes.js.map create mode 100644 packages/a11y/libx/Gesture/withCalendarGesture.js create mode 100644 packages/a11y/libx/Gesture/withCalendarGesture.js.map create mode 100644 packages/a11y/libx/Gesture/withDynamicListGesture.js create mode 100644 packages/a11y/libx/Gesture/withDynamicListGesture.js.map create mode 100644 packages/a11y/libx/Gesture/withListGesture.js create mode 100644 packages/a11y/libx/Gesture/withListGesture.js.map create mode 100644 packages/a11y/libx/Gesture/withMonthCalendarGesture.js create mode 100644 packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map create mode 100644 packages/a11y/libx/Gesture/withTreeGesture.js create mode 100644 packages/a11y/libx/Gesture/withTreeGesture.js.map create mode 100644 packages/a11y/libx/index.js create mode 100644 packages/a11y/libx/index.js.map create mode 100644 packages/a11y/libx/test-setup.js create mode 100644 packages/a11y/libx/test-setup.js.map create mode 100644 packages/a11y/tsup.config.ts create mode 100644 packages/assets-api/libx/index.d.ts create mode 100644 packages/assets-api/libx/index.js create mode 100644 packages/assets-api/libx/index.js.map create mode 100644 packages/assets-api/tsup.config.ts create mode 100644 packages/cmf-cqrs/tsup.config.ts create mode 100644 packages/cmf-router/tsup.config.ts create mode 100644 packages/cmf/tsup.config.ts create mode 100644 packages/components/tsup.config.ts create mode 100644 packages/containers/tsup.config.ts create mode 100644 packages/dataviz/tsup.config.ts create mode 100644 packages/design-system/tsup.config.ts create mode 100644 packages/design-tokens/tsup.config.ts create mode 100644 packages/faceted-search-query-client/tsup.config.ts create mode 100644 packages/faceted-search/tsup.config.ts create mode 100644 packages/flow-designer/tsup.config.ts create mode 100644 packages/forms/tsup.config.ts create mode 100644 packages/http/tsup.config.ts create mode 100644 packages/router-bridge/tsup.config.ts create mode 100644 packages/sagas/tsup.config.ts create mode 100644 packages/stepper/libx/Stepper.constants.js create mode 100644 packages/stepper/libx/Stepper.constants.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js create mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/index.js create mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/index.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js create mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js create mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/index.js create mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/index.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.component.js create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.component.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.context.js create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.context.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.module.css create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.types.js create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.types.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.utils.js create mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js create mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map create mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js create mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map create mode 100644 packages/stepper/libx/components/StepperForm/index.js create mode 100644 packages/stepper/libx/components/StepperForm/index.js.map create mode 100644 packages/stepper/libx/components/index.js create mode 100644 packages/stepper/libx/components/index.js.map create mode 100644 packages/stepper/libx/constants/i18n.js create mode 100644 packages/stepper/libx/constants/i18n.js.map create mode 100644 packages/stepper/libx/containers/Stepper.connect.js create mode 100644 packages/stepper/libx/containers/Stepper.connect.js.map create mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js create mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map create mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js create mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map create mode 100644 packages/stepper/libx/index.js create mode 100644 packages/stepper/libx/index.js.map create mode 100644 packages/stepper/libx/service/Stepper.actions.js create mode 100644 packages/stepper/libx/service/Stepper.actions.js.map create mode 100644 packages/stepper/libx/service/Stepper.reducer.js create mode 100644 packages/stepper/libx/service/Stepper.reducer.js.map create mode 100644 packages/stepper/libx/service/Stepper.selectors.js create mode 100644 packages/stepper/libx/service/Stepper.selectors.js.map create mode 100644 packages/stepper/libx/service/Stepper.utils.js create mode 100644 packages/stepper/libx/service/Stepper.utils.js.map create mode 100644 packages/stepper/libx/stories/Stepper.components.js create mode 100644 packages/stepper/libx/stories/Stepper.components.js.map create mode 100644 packages/stepper/libx/translate.js create mode 100644 packages/stepper/libx/translate.js.map create mode 100644 packages/stepper/tsup.config.ts create mode 100644 packages/storybook-cmf/tsup.config.ts create mode 100644 packages/storybook-docs/tsup.config.ts create mode 100644 packages/utils/tsup.config.ts create mode 100644 tools/scripts-config-tsup/package.json create mode 100644 tools/scripts-config-tsup/src/index.ts diff --git a/docs/plan-tsup-migration.md b/docs/plan-tsup-migration.md new file mode 100644 index 00000000000..a9cff9d3ab5 --- /dev/null +++ b/docs/plan-tsup-migration.md @@ -0,0 +1,182 @@ +# Migration Plan: Replace `talend-scripts build` with `tsup` (ESM-only) + +## Overview + +Migrate all library packages from the current `talend-scripts build` pipeline +(Babel + tsc) to **tsup** while simultaneously dropping CommonJS support. +Output will be ESM-only. + +A parallel `build:libx` script outputting to `libx/` allows side-by-side comparison +with the current `lib-esm/` before cutting over. + +## Key Decisions + +| Decision | Choice | +| ---------------------------------------------------------- | ------------------------------------------------------------- | +| Module format | **ESM-only** — no more `lib/` (CJS) | +| Build tool | **tsup** (esbuild-based, ~10× faster than Babel) | +| TypeScript declarations | **tsup `dts: true`** (Phase 3, after comparison) | +| CSS/SCSS/JSON assets | **Copied as-is** via `onSuccess` — not bundled | +| Babel custom plugins (`import-from-index`, `assets-api`) | **Dropped** — no longer needed | +| Fork packages (`react-bootstrap`, `json-schema-form-core`) | **Out of scope** — stay on talend-scripts | +| `icons` (Vite), `theme` (Webpack) | **Out of scope** — already use other tools | +| Comparison directory | `libx/` (tsup Phase 1 output) vs `lib-esm/` (current) | +| Shared config package | `@talend/scripts-config-tsup` in `tools/scripts-config-tsup/` | + +--- + +## Phases + +### Phase 0 — Setup ✅ DONE + +- [x] Add `tsup` to root `devDependencies` +- [x] Create `tools/scripts-config-tsup/` workspace package + - [x] Exports `baseConfig()` helper — common tsup options + - [x] Exports `copyAssets()` helper — replaces `cpx2` copy step + - [x] Exports `SOURCE_PATTERNS` and `EXCLUDE_PATTERNS` glob arrays + +### Phase 1 — Add `build:libx` per package (in progress) + +For each package: created `tsup.config.ts` + added `"build:libx": "tsup"` script. + +Run `yarn workspace run build:libx` to produce `libx/` output for comparison. + +#### Batch 1 — Pure TS, no assets + +| Package | tsup.config.ts | build:libx script | Compare | Validate | +| --------------------- | :------------: | :---------------: | :-----: | :------: | +| `packages/a11y` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/assets-api` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/http` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/utils` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/cmf-cqrs` | ✅ | ✅ | ⬜ | ⬜ | + +#### Batch 2 — JS/JSX, no assets + +| Package | tsup.config.ts | build:libx script | Compare | Validate | +| -------------------------------------- | :------------: | :---------------: | :-----: | :------: | +| `packages/cmf` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/cmf-router` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/sagas` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/router-bridge` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/storybook-cmf` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/faceted-search-query-client` | ✅ | ✅ | ⬜ | ⬜ | + +#### Batch 3 — TS + CSS assets + +| Package | tsup.config.ts | build:libx script | Compare | Validate | +| ------------------------ | :------------: | :---------------: | :-----: | :------: | +| `packages/stepper` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/forms` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/dataviz` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/containers` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/flow-designer` | ✅ | ✅ | ⬜ | ⬜ | + +#### Batch 4 — CSS/SCSS assets + +| Package | tsup.config.ts | build:libx script | Compare | Validate | +| ------------------------- | :------------: | :---------------: | :-----: | :------: | +| `packages/components` | ✅ | ✅ | ⬜ | ⬜ | +| `packages/faceted-search` | ✅ | ✅ | ⬜ | ⬜ | + +#### Batch 5 — Special cases + +| Package | tsup.config.ts | build:libx script | Compare | Validate | Notes | +| ------------------------- | :------------: | :---------------: | :-----: | :------: | ---------------------------------------------- | +| `packages/design-system` | ✅ | ✅ | ⬜ | ⬜ | Also copies SVG images from `src/images/` | +| `packages/design-tokens` | ✅ | ✅ | ⬜ | ⬜ | `build:css` (SCSS→CSS) remains a separate step | +| `packages/storybook-docs` | ✅ | ✅ | ⬜ | ⬜ | `build:styles` remains a separate step | + +--- + +### Phase 2 — Validate & fix (TODO) + +For each package above, check `✅` when done: + +- [ ] Run `yarn workspace run build:libx` — build succeeds +- [ ] `diff -rq lib-esm/ libx/` — compare current vs tsup output + - [ ] JS files use ESM syntax (`import`/`export`) + - [ ] `.css`, `.scss`, `.json` assets are present + - [ ] Source maps (`.js.map`) are present + - [ ] Package content is equivalent (no missing/extra files) +- [ ] Run `yarn workspace test` to confirm no regressions +- [ ] Confirm the two dropped Babel plugins have no runtime impact: + - `babel-plugin-import-from-index` — consumers import from package root + - `babel-plugin-assets-api` — CDN version injection no longer needed +- [ ] Compare bundle sizes (`lib-esm/` vs `libx/`) + +### Phase 3 — Cutover (TODO) + +For each package: + +- [ ] Enable `dts: true` in `tsup.config.ts` (TypeScript declarations via tsup) +- [ ] Verify `.d.ts` files are generated correctly in `libx/` +- [ ] Update `package.json`: + - Change `outDir` from `libx` to the final directory (`lib` after dropping CJS) + - Change `"build:lib"` script to `"tsup"` (or keep alias) + - Remove `"build:lib:esm"` script + - Update `"main"` → ESM output path + - Update `"types"` → new declaration file path + - Remove `"module"` (redundant once ESM is main) + - Update `"exports"` → single ESM entry: + ```json + "exports": { + ".": { + "import": "./lib/index.js", + "types": "./lib/index.d.ts" + } + } + ``` + - Add `"type": "module"` if needed +- [ ] Remove `@talend/scripts-config-babel` from `devDependencies` (if only used for build) +- [ ] Remove `@talend/scripts-core` from `devDependencies` (if only used for `build:lib`) + +After all packages are migrated: + +- [ ] Update root `package.json` `postinstall` — single `talend-yarn-workspace run build:lib` +- [ ] Remove `libx/` from `.gitignore` (or add it if not there already) +- [ ] Run full monorepo test suite: `yarn test` +- [ ] Verify Storybook builds (`yarn start-storybook`) +- [ ] Verify playground apps work +- [ ] Submit PR and add a changeset with `@changesets/cli` + +--- + +## How to Compare Outputs + +```bash +# Build current output (if lib-esm/ doesn't exist yet): +yarn workspace @talend/react-a11y run build:lib:esm + +# Build tsup output: +yarn workspace @talend/react-a11y run build:libx + +# Compare: +diff -rq packages/a11y/lib-esm/ packages/a11y/libx/ +``` + +--- + +## Relevant Files + +| File | Purpose | +| ----------------------------------------------- | --------------------------------------- | +| `tools/scripts-config-tsup/src/index.ts` | Shared `baseConfig()` + `copyAssets()` | +| `tools/scripts-core/src/scripts/build-lib.js` | Legacy build (reference) | +| `tools/scripts-config-babel/babel.config.js` | Legacy Babel config (reference) | +| `tools/scripts-config-typescript/tsconfig.json` | Base TS config used by packages | +| Root `package.json` | `postinstall` / workspace orchestration | + +--- + +## Notes + +- **`bundle: false`** (file-per-file transform) matches current Babel behavior and + preserves tree-shaking for consumers. With `bundle: true`, all entry points would + need to be explicitly listed. +- **Deep imports** (`exports["./lib/*"]`) continue to work with file-per-file output. + The `exports` map will need updating in Phase 3 to point to the new directory. +- **`design-tokens`** and **`storybook-docs`** have secondary build steps (`build:css`, + `build:styles`) that are independent from the JS compilation and should be kept. +- **`utils`** previously used `build:lib: "talend-scripts build --tsc"` (TypeScript-only, + no Babel). tsup/esbuild handles TypeScript natively — no special treatment needed. diff --git a/package.json b/package.json index ee01a897cc8..a908dd68782 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "@changesets/cli": "^2.29.8", "@talend/eslint-config": "^14.0.0", "@talend/scripts-config-babel": "^13.8.0", + "tsup": "^8.3.0", "@talend/scripts-config-prettier": "^12.5.0", "@talend/scripts-core": "^18.0.0", "@talend/scripts-yarn-workspace": "^2.3.0", diff --git a/packages/a11y/libx/Gesture/constants.js b/packages/a11y/libx/Gesture/constants.js new file mode 100644 index 00000000000..5e03d15ab47 --- /dev/null +++ b/packages/a11y/libx/Gesture/constants.js @@ -0,0 +1,4 @@ +const FIRST = 0; +const LAST = Number.POSITIVE_INFINITY; +export { FIRST, LAST }; +//# sourceMappingURL=constants.js.map diff --git a/packages/a11y/libx/Gesture/constants.js.map b/packages/a11y/libx/Gesture/constants.js.map new file mode 100644 index 00000000000..02184b023bb --- /dev/null +++ b/packages/a11y/libx/Gesture/constants.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/constants.ts"],"sourcesContent":["export const FIRST = 0;\nexport const LAST = Number.POSITIVE_INFINITY;\n"],"mappings":"AAAO,MAAM,QAAQ;AACd,MAAM,OAAO,OAAO;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/focus.js b/packages/a11y/libx/Gesture/focus.js new file mode 100644 index 00000000000..213a7eb36e3 --- /dev/null +++ b/packages/a11y/libx/Gesture/focus.js @@ -0,0 +1,52 @@ +import { FIRST, LAST } from './constants'; +function focusOn(element) { + if (element) { + element.focus(); + } +} +function getAllItems(calendarRef) { + return calendarRef.querySelectorAll('td > button[data-value]'); +} +function getDay(calendarRef, offset) { + const allItems = getAllItems(calendarRef); + const index = offset >= 0 ? offset : allItems.length + offset; + return allItems[index]; +} +function focusWithinCurrentCalendar(calendarRef, indexToFocus = 0) { + const allItems = getAllItems(calendarRef); + if (indexToFocus === FIRST || indexToFocus < 0) { + focusOn(allItems[0]); + } else if (indexToFocus === LAST || indexToFocus > allItems.length - 1) { + focusOn(allItems[allItems.length - 1]); + } else { + focusOn(allItems[indexToFocus]); + } +} +function focusOnDay(calendarRef, indexToFocus, props) { + const allItems = getAllItems(calendarRef); + if (indexToFocus < 0) { + props.goToPreviousMonth(() => { + focusOn(getDay(calendarRef, indexToFocus)); + }); + } else if (indexToFocus > allItems.length - 1) { + props.goToNextMonth(() => { + focusOn(getDay(calendarRef, indexToFocus - allItems.length)); + }); + } else { + focusOn(allItems[indexToFocus]); + } +} +function focusOnCalendar(containerRef) { + let target = containerRef.querySelector('td[aria-current="date"] > button'); + if (!target) { + target = containerRef.querySelector('td > button[disabled=false]'); + } + if (!target) { + target = containerRef.querySelector('td > button[data-value]'); + } + if (target) { + target.focus(); + } +} +export { focusOn, focusOnCalendar, focusOnDay, focusWithinCurrentCalendar }; +//# sourceMappingURL=focus.js.map diff --git a/packages/a11y/libx/Gesture/focus.js.map b/packages/a11y/libx/Gesture/focus.js.map new file mode 100644 index 00000000000..86d9838e830 --- /dev/null +++ b/packages/a11y/libx/Gesture/focus.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/focus.ts"],"sourcesContent":["import { FIRST, LAST } from './constants';\nimport { CalendarGestureProps } from './propTypes';\n\nexport interface WithFocus {\n\tfocus: HTMLElement['focus'];\n}\n\nexport function focusOn(element?: WithFocus | null) {\n\tif (element) {\n\t\telement.focus();\n\t}\n}\n\n/**\n * Select all items in current calendar\n */\nfunction getAllItems(calendarRef: HTMLElement) {\n\treturn calendarRef.querySelectorAll('td > button[data-value]');\n}\n\n/**\n * Get the day corresponding to the offset.\n * - positive offset : we count from the beginning of the month. Ex : days 1-31 + offset 5 = day 5\n * - negative offset < 0 : we count from the end of the month. \t Ex : days 1-31 + offset -2 = day 29\n */\nfunction getDay(calendarRef: HTMLElement, offset: number): HTMLElement {\n\tconst allItems = getAllItems(calendarRef);\n\tconst index = offset >= 0 ? offset : allItems.length + offset;\n\treturn allItems[index];\n}\n\n/**\n * Focus on the item within the current calendar.\n * If the day index is out of the calendar's limits, it focuses on the limits.\n */\nexport function focusWithinCurrentCalendar(calendarRef: HTMLElement, indexToFocus = 0) {\n\tconst allItems = getAllItems(calendarRef);\n\tif (indexToFocus === FIRST || indexToFocus < 0) {\n\t\tfocusOn(allItems[0]);\n\t} else if (indexToFocus === LAST || indexToFocus > allItems.length - 1) {\n\t\tfocusOn(allItems[allItems.length - 1]);\n\t} else {\n\t\tfocusOn(allItems[indexToFocus]);\n\t}\n}\n\n/**\n * Focus on the day, managing the switch to previous/next month\n */\nexport function focusOnDay(\n\tcalendarRef: HTMLElement,\n\tindexToFocus: number,\n\tprops: CalendarGestureProps,\n) {\n\tconst allItems = getAllItems(calendarRef);\n\n\tif (indexToFocus < 0) {\n\t\tprops.goToPreviousMonth(() => {\n\t\t\tfocusOn(getDay(calendarRef, indexToFocus));\n\t\t});\n\t} else if (indexToFocus > allItems.length - 1) {\n\t\tprops.goToNextMonth(() => {\n\t\t\tfocusOn(getDay(calendarRef, indexToFocus - allItems.length));\n\t\t});\n\t} else {\n\t\tfocusOn(allItems[indexToFocus] as HTMLElement);\n\t}\n}\n\n/**\n * Focus management on calendar.\n * - try to focus on the selected item\n * - try to focus on the 1st not disabled item\n * - try to focus on the 1st item\n */\nexport function focusOnCalendar(containerRef: HTMLElement) {\n\tlet target = containerRef.querySelector('td[aria-current=\"date\"] > button');\n\tif (!target) {\n\t\ttarget = containerRef.querySelector('td > button[disabled=false]');\n\t}\n\tif (!target) {\n\t\ttarget = containerRef.querySelector('td > button[data-value]');\n\t}\n\tif (target) {\n\t\ttarget.focus();\n\t}\n}\n"],"mappings":"AAAA,SAAS,OAAO,YAAY;AAOrB,SAAS,QAAQ,SAA4B;AACnD,MAAI,SAAS;AACZ,YAAQ,MAAM;AAAA,EACf;AACD;AAKA,SAAS,YAAY,aAA0B;AAC9C,SAAO,YAAY,iBAAoC,yBAAyB;AACjF;AAOA,SAAS,OAAO,aAA0B,QAA6B;AACtE,QAAM,WAAW,YAAY,WAAW;AACxC,QAAM,QAAQ,UAAU,IAAI,SAAS,SAAS,SAAS;AACvD,SAAO,SAAS,KAAK;AACtB;AAMO,SAAS,2BAA2B,aAA0B,eAAe,GAAG;AACtF,QAAM,WAAW,YAAY,WAAW;AACxC,MAAI,iBAAiB,SAAS,eAAe,GAAG;AAC/C,YAAQ,SAAS,CAAC,CAAC;AAAA,EACpB,WAAW,iBAAiB,QAAQ,eAAe,SAAS,SAAS,GAAG;AACvE,YAAQ,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,EACtC,OAAO;AACN,YAAQ,SAAS,YAAY,CAAC;AAAA,EAC/B;AACD;AAKO,SAAS,WACf,aACA,cACA,OACC;AACD,QAAM,WAAW,YAAY,WAAW;AAExC,MAAI,eAAe,GAAG;AACrB,UAAM,kBAAkB,MAAM;AAC7B,cAAQ,OAAO,aAAa,YAAY,CAAC;AAAA,IAC1C,CAAC;AAAA,EACF,WAAW,eAAe,SAAS,SAAS,GAAG;AAC9C,UAAM,cAAc,MAAM;AACzB,cAAQ,OAAO,aAAa,eAAe,SAAS,MAAM,CAAC;AAAA,IAC5D,CAAC;AAAA,EACF,OAAO;AACN,YAAQ,SAAS,YAAY,CAAgB;AAAA,EAC9C;AACD;AAQO,SAAS,gBAAgB,cAA2B;AAC1D,MAAI,SAAS,aAAa,cAA2B,kCAAkC;AACvF,MAAI,CAAC,QAAQ;AACZ,aAAS,aAAa,cAA2B,6BAA6B;AAAA,EAC/E;AACA,MAAI,CAAC,QAAQ;AACZ,aAAS,aAAa,cAA2B,yBAAyB;AAAA,EAC3E;AACA,MAAI,QAAQ;AACX,WAAO,MAAM;AAAA,EACd;AACD;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/index.js b/packages/a11y/libx/Gesture/index.js new file mode 100644 index 00000000000..b749e53e12b --- /dev/null +++ b/packages/a11y/libx/Gesture/index.js @@ -0,0 +1,16 @@ +import { withListGesture } from './withListGesture'; +import { withTreeGesture } from './withTreeGesture'; +import { WithDynamicListGesture } from './withDynamicListGesture'; +import { withCalendarGesture } from './withCalendarGesture'; +import { withMonthCalendarGesture } from './withMonthCalendarGesture'; +import * as focus from './focus'; +const Gesture = { + withMonthCalendarGesture, + withListGesture, + withTreeGesture, + WithDynamicListGesture, + withCalendarGesture, +}; +var Gesture_default = Gesture; +export { Gesture_default as default, focus }; +//# sourceMappingURL=index.js.map diff --git a/packages/a11y/libx/Gesture/index.js.map b/packages/a11y/libx/Gesture/index.js.map new file mode 100644 index 00000000000..351e2331e89 --- /dev/null +++ b/packages/a11y/libx/Gesture/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/index.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { withListGesture } from './withListGesture';\nimport { withTreeGesture } from './withTreeGesture';\nimport { WithDynamicListGesture } from './withDynamicListGesture';\nimport { withCalendarGesture } from './withCalendarGesture';\nimport { withMonthCalendarGesture } from './withMonthCalendarGesture';\nimport * as focus from './focus';\n\nconst Gesture = {\n\twithMonthCalendarGesture,\n\twithListGesture,\n\twithTreeGesture,\n\tWithDynamicListGesture,\n\twithCalendarGesture,\n};\n\nexport { focus };\nexport default Gesture;\n"],"mappings":"AACA,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,gCAAgC;AACzC,YAAY,WAAW;AAEvB,MAAM,UAAU;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAGA,IAAO,kBAAQ;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/preventScroll.js b/packages/a11y/libx/Gesture/preventScroll.js new file mode 100644 index 00000000000..2823e19836f --- /dev/null +++ b/packages/a11y/libx/Gesture/preventScroll.js @@ -0,0 +1,21 @@ +function preventScroll(evt) { + const arrows = [ + 'ArrowLeft', + 'ArrowRight', + 'ArrowUp', + 'ArrowDown', + 'Home', + 'PageUp', + 'PageDown', + // Arrow key management for old browsers + 'Left', + 'Right', + 'Up', + 'Down', + ]; + if (arrows.includes(evt.key)) { + evt.preventDefault(); + } +} +export { preventScroll }; +//# sourceMappingURL=preventScroll.js.map diff --git a/packages/a11y/libx/Gesture/preventScroll.js.map b/packages/a11y/libx/Gesture/preventScroll.js.map new file mode 100644 index 00000000000..6e80f7afc04 --- /dev/null +++ b/packages/a11y/libx/Gesture/preventScroll.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/preventScroll.ts"],"sourcesContent":["import { KeyboardEvent } from 'react';\n\nexport function preventScroll(evt: KeyboardEvent) {\n\tconst arrows = [\n\t\t'ArrowLeft',\n\t\t'ArrowRight',\n\t\t'ArrowUp',\n\t\t'ArrowDown',\n\t\t'Home',\n\t\t'PageUp',\n\t\t'PageDown',\n\t\t// Arrow key management for old browsers\n\t\t'Left',\n\t\t'Right',\n\t\t'Up',\n\t\t'Down',\n\t];\n\tif (arrows.includes(evt.key)) {\n\t\tevt.preventDefault();\n\t}\n}\n"],"mappings":"AAEO,SAAS,cAAc,KAAiC;AAC9D,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,MAAI,OAAO,SAAS,IAAI,GAAG,GAAG;AAC7B,QAAI,eAAe;AAAA,EACpB;AACD;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/propTypes.js b/packages/a11y/libx/Gesture/propTypes.js new file mode 100644 index 00000000000..edcb19df5b4 --- /dev/null +++ b/packages/a11y/libx/Gesture/propTypes.js @@ -0,0 +1 @@ +//# sourceMappingURL=propTypes.js.map diff --git a/packages/a11y/libx/Gesture/propTypes.js.map b/packages/a11y/libx/Gesture/propTypes.js.map new file mode 100644 index 00000000000..84c51b288c4 --- /dev/null +++ b/packages/a11y/libx/Gesture/propTypes.js.map @@ -0,0 +1 @@ +{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withCalendarGesture.js b/packages/a11y/libx/Gesture/withCalendarGesture.js new file mode 100644 index 00000000000..0c8ff8148a1 --- /dev/null +++ b/packages/a11y/libx/Gesture/withCalendarGesture.js @@ -0,0 +1,78 @@ +import { jsx } from 'react/jsx-runtime'; +import { Component, createRef } from 'react'; +import { FIRST, LAST } from './constants'; +import { focusOnDay, focusWithinCurrentCalendar } from './focus'; +import { preventScroll } from './preventScroll'; +function switchMonth(calendarRef, indexToFocus, monthSwitcher) { + monthSwitcher(() => { + focusWithinCurrentCalendar(calendarRef, indexToFocus); + }); +} +function withCalendarGesture(WrappedComponent) { + var _a; + return ( + (_a = class extends Component { + constructor(props) { + super(props); + this.ref = createRef(); + this.onKeyDown = this.onKeyDown.bind(this); + } + onKeyDown(event, calendarRef, dayIndex) { + switch (event.key) { + case 'Left': + case 'ArrowLeft': + event.stopPropagation(); + focusOnDay(calendarRef, dayIndex - 1, this.props); + break; + case 'Right': + case 'ArrowRight': + event.stopPropagation(); + focusOnDay(calendarRef, dayIndex + 1, this.props); + break; + case 'Up': + case 'ArrowUp': + event.stopPropagation(); + focusOnDay(calendarRef, dayIndex - 7, this.props); + break; + case 'Down': + case 'ArrowDown': + event.stopPropagation(); + focusOnDay(calendarRef, dayIndex + 7, this.props); + break; + case 'Home': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, FIRST); + break; + case 'End': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, LAST); + break; + case 'PageUp': + event.stopPropagation(); + switchMonth(calendarRef, dayIndex, this.props.goToPreviousMonth); + break; + case 'PageDown': + event.stopPropagation(); + switchMonth(calendarRef, dayIndex, this.props.goToNextMonth); + break; + default: + break; + } + } + render() { + return /* @__PURE__ */ jsx('div', { + ref: this.ref, + onKeyDown: preventScroll, + children: /* @__PURE__ */ jsx(WrappedComponent, { + ...this.props, + onKeyDown: this.onKeyDown, + }), + }); + } + }), + (_a.displayName = `CalendarGesture(${WrappedComponent.displayName})`), + _a + ); +} +export { withCalendarGesture }; +//# sourceMappingURL=withCalendarGesture.js.map diff --git a/packages/a11y/libx/Gesture/withCalendarGesture.js.map b/packages/a11y/libx/Gesture/withCalendarGesture.js.map new file mode 100644 index 00000000000..21af31d6be2 --- /dev/null +++ b/packages/a11y/libx/Gesture/withCalendarGesture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/withCalendarGesture.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n\n/* eslint-disable react/no-multi-comp,class-methods-use-this */\nimport { Component, ComponentType, createRef, KeyboardEvent } from 'react';\n\nimport { FIRST, LAST } from './constants';\nimport { focusOnDay, focusWithinCurrentCalendar } from './focus';\nimport { preventScroll } from './preventScroll';\nimport { WithCalendarGestureInjectedProps } from './propTypes';\n\n/**\n * Switch month and focus on the same focused day or the month's limits if it's out of the limits\n */\nfunction switchMonth(\n\tcalendarRef: HTMLElement,\n\tindexToFocus: number,\n\tmonthSwitcher: (cb?: () => void) => void,\n) {\n\tmonthSwitcher(() => {\n\t\tfocusWithinCurrentCalendar(calendarRef, indexToFocus);\n\t});\n}\n\n// T is the type of data\n// P is the props of the wrapped component that is inferred\n// C is the actual interface of the wrapped component (used to grab defaultProps from it)\n\nexport function withCalendarGesture

(\n\tWrappedComponent: ComponentType

,\n) {\n\t// the magic is here: JSX.LibraryManagedAttributes will take the type of WrapedComponent and resolve its default props\n\t// against the props of WithData, which is just the original P type with 'data' removed from its requirements\n\ttype Props = Omit;\n\n\treturn class CalendarGesture extends Component {\n\t\tstatic displayName = `CalendarGesture(${WrappedComponent.displayName})`;\n\n\t\tref = createRef();\n\n\t\tconstructor(props: Props) {\n\t\t\tsuper(props);\n\t\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t\t}\n\n\t\tonKeyDown(event: KeyboardEvent, calendarRef: HTMLElement, dayIndex: number) {\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'Left':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex - 1, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Right':\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex + 1, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Up':\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex - 7, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Down':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex + 7, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, FIRST);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, LAST);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'PageUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tswitchMonth(calendarRef, dayIndex, this.props.goToPreviousMonth);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'PageDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tswitchMonth(calendarRef, dayIndex, this.props.goToNextMonth);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\treturn (\n\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t);\n\t\t}\n\t};\n}\n"],"mappings":"AA4FK;AAvFL,SAAS,WAA0B,iBAAgC;AAEnE,SAAS,OAAO,YAAY;AAC5B,SAAS,YAAY,kCAAkC;AACvD,SAAS,qBAAqB;AAM9B,SAAS,YACR,aACA,cACA,eACC;AACD,gBAAc,MAAM;AACnB,+BAA2B,aAAa,YAAY;AAAA,EACrD,CAAC;AACF;AAMO,SAAS,oBACf,kBACC;AA/BF;AAoCC,SAAO,mBAA8B,UAAiB;AAAA,IAKrD,YAAY,OAAc;AACzB,YAAM,KAAK;AAHZ,iBAAM,UAA0B;AAI/B,WAAK,YAAY,KAAK,UAAU,KAAK,IAAI;AAAA,IAC1C;AAAA,IAEA,UAAU,OAAwC,aAA0B,UAAkB;AAC7F,cAAQ,MAAM,KAAK;AAAA,QAClB,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,KAAK;AAC7C;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,IAAI;AAC5C;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,sBAAY,aAAa,UAAU,KAAK,MAAM,iBAAiB;AAC/D;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,sBAAY,aAAa,UAAU,KAAK,MAAM,aAAa;AAC3D;AAAA,QACD;AACC;AAAA,MACF;AAAA,IACD;AAAA,IAEA,SAAS;AACR,aACC,oBAAC,SAAI,KAAK,KAAK,KAAK,WAAW,eAC9B,8BAAC,oBAAkB,GAAI,KAAK,OAAe,WAAW,KAAK,WAAW,GACvE;AAAA,IAEF;AAAA,EACD,GA5DO,GACC,cAAc,mBAAmB,iBAAiB,WAAW,KAD9D;AA6DR;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withDynamicListGesture.js b/packages/a11y/libx/Gesture/withDynamicListGesture.js new file mode 100644 index 00000000000..b0ade17018f --- /dev/null +++ b/packages/a11y/libx/Gesture/withDynamicListGesture.js @@ -0,0 +1,86 @@ +import { jsx } from 'react/jsx-runtime'; +import { Component, createRef } from 'react'; +import { focusOn } from './focus'; +function getAllItems(ref) { + return ref.querySelectorAll('li > button'); +} +function focusOnListItem(ref, index) { + const listItem = getAllItems(ref)[index]; + focusOn(listItem); +} +function focusOnPreviousItem(ref, { index, size }, goToPreviousPage) { + const nextIndex = index - 1; + if (nextIndex < 0 && size) { + goToPreviousPage(() => { + focusOnListItem(ref, size - 1); + }); + } + focusOnListItem(ref, nextIndex); +} +function focusOnNextItem(ref, { index, size }, goToNextPage) { + const nextIndex = index + 1; + if (size && nextIndex >= size) { + goToNextPage(() => { + focusOnListItem(ref, 0); + }); + } + focusOnListItem(ref, nextIndex); +} +function focusOnNextPage(ref, { index }, goToNextPage) { + goToNextPage(() => focusOnListItem(ref, index)); +} +function focusOnPreviousPage(ref, { index }, goToPreviousPage) { + goToPreviousPage(() => focusOnListItem(ref, index)); +} +class WithDynamicListGesture extends Component { + constructor(props) { + super(props); + this.myRef = createRef(); + this.onKeyDown = this.onKeyDown.bind(this); + } + onKeyDown(event, options) { + switch (event.key) { + case 'Up': + case 'ArrowUp': + event.preventDefault(); + event.stopPropagation(); + if (this.myRef?.current) { + focusOnPreviousItem(this.myRef.current, options, this.props.goToPreviousPage); + } + break; + case 'Down': + case 'ArrowDown': + event.preventDefault(); + event.stopPropagation(); + if (this.myRef?.current) { + focusOnNextItem(this.myRef.current, options, this.props.goToNextPage); + } + break; + case 'PageUp': + event.preventDefault(); + event.stopPropagation(); + if (this.myRef?.current) { + focusOnNextPage(this.myRef.current, options, this.props.goToPreviousPage); + } + break; + case 'PageDown': + event.preventDefault(); + event.stopPropagation(); + if (this.myRef?.current) { + focusOnPreviousPage(this.myRef.current, options, this.props.goToNextPage); + } + break; + default: + break; + } + } + render() { + return /* @__PURE__ */ jsx('div', { + ref: this.myRef, + className: this.props.className, + children: this.props.children(this.onKeyDown), + }); + } +} +export { WithDynamicListGesture }; +//# sourceMappingURL=withDynamicListGesture.js.map diff --git a/packages/a11y/libx/Gesture/withDynamicListGesture.js.map b/packages/a11y/libx/Gesture/withDynamicListGesture.js.map new file mode 100644 index 00000000000..6b722c28ba6 --- /dev/null +++ b/packages/a11y/libx/Gesture/withDynamicListGesture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/withDynamicListGesture.tsx"],"sourcesContent":["import { Component, createRef } from 'react';\n\nimport { focusOn, WithFocus } from './focus';\n\nfunction getAllItems(ref: HTMLElement): NodeListOf {\n\treturn ref.querySelectorAll('li > button');\n}\n\nfunction focusOnListItem(ref: HTMLElement, index: number) {\n\tconst listItem = getAllItems(ref)[index] as WithFocus;\n\tfocusOn(listItem);\n}\n\nexport type FocusOnOption = {\n\tindex: number;\n\tsize?: number;\n};\n\nfunction focusOnPreviousItem(\n\tref: HTMLElement,\n\t{ index, size }: FocusOnOption,\n\tgoToPreviousPage: (fn?: () => void) => void,\n) {\n\tconst nextIndex = index - 1;\n\tif (nextIndex < 0 && size) {\n\t\tgoToPreviousPage(() => {\n\t\t\tfocusOnListItem(ref, size - 1);\n\t\t});\n\t}\n\tfocusOnListItem(ref, nextIndex);\n}\n\nfunction focusOnNextItem(\n\tref: HTMLElement,\n\t{ index, size }: FocusOnOption,\n\tgoToNextPage: (fn?: () => void) => void,\n) {\n\tconst nextIndex = index + 1;\n\tif (size && nextIndex >= size) {\n\t\tgoToNextPage(() => {\n\t\t\tfocusOnListItem(ref, 0);\n\t\t});\n\t}\n\tfocusOnListItem(ref, nextIndex);\n}\n\nfunction focusOnNextPage(\n\tref: HTMLElement,\n\t{ index }: FocusOnOption,\n\tgoToNextPage: (fn?: () => void) => void,\n) {\n\tgoToNextPage(() => focusOnListItem(ref, index));\n}\n\nfunction focusOnPreviousPage(\n\tref: HTMLElement,\n\t{ index }: FocusOnOption,\n\tgoToPreviousPage: (fn?: () => void) => void,\n) {\n\tgoToPreviousPage(() => focusOnListItem(ref, index));\n}\n\nexport interface WithDynamicListGestureProps {\n\tclassName: string;\n\tgoToPreviousPage: () => void;\n\tgoToNextPage: () => void;\n\tchildren: (fn: (event: KeyboardEvent, options: FocusOnOption) => void) => JSX.Element;\n}\n\nexport class WithDynamicListGesture extends Component {\n\tmyRef = createRef();\n\n\tconstructor(props: WithDynamicListGestureProps) {\n\t\tsuper(props);\n\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t}\n\n\tonKeyDown(event: KeyboardEvent, options: FocusOnOption) {\n\t\tswitch (event.key) {\n\t\t\tcase 'Up':\n\t\t\tcase 'ArrowUp':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnPreviousItem(this.myRef.current, options, this.props.goToPreviousPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'Down':\n\t\t\tcase 'ArrowDown':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnNextItem(this.myRef.current, options, this.props.goToNextPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'PageUp':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnNextPage(this.myRef.current, options, this.props.goToPreviousPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'PageDown':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnPreviousPage(this.myRef.current, options, this.props.goToNextPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t
\n\t\t\t\t{this.props.children(this.onKeyDown)}\n\t\t\t
\n\t\t);\n\t}\n}\n"],"mappings":"AAqHG;AArHH,SAAS,WAAW,iBAAiB;AAErC,SAAS,eAA0B;AAEnC,SAAS,YAAY,KAAiD;AACrE,SAAO,IAAI,iBAAiB,aAAa;AAC1C;AAEA,SAAS,gBAAgB,KAAkB,OAAe;AACzD,QAAM,WAAW,YAAY,GAAG,EAAE,KAAK;AACvC,UAAQ,QAAQ;AACjB;AAOA,SAAS,oBACR,KACA,EAAE,OAAO,KAAK,GACd,kBACC;AACD,QAAM,YAAY,QAAQ;AAC1B,MAAI,YAAY,KAAK,MAAM;AAC1B,qBAAiB,MAAM;AACtB,sBAAgB,KAAK,OAAO,CAAC;AAAA,IAC9B,CAAC;AAAA,EACF;AACA,kBAAgB,KAAK,SAAS;AAC/B;AAEA,SAAS,g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,SAAS,SAAS,KAAK,MAAM,YAAY;AAAA,QACzE;AACA;AAAA,MAED;AACC;AAAA,IACF;AAAA,EACD;AAAA,EAEA,SAAS;AACR,WACC,oBAAC,SAAI,KAAK,KAAK,OAAO,WAAW,KAAK,MAAM,WAC1C,eAAK,MAAM,SAAS,KAAK,SAAS,GACpC;AAAA,EAEF;AACD;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withListGesture.js b/packages/a11y/libx/Gesture/withListGesture.js new file mode 100644 index 00000000000..a5fcf8e2039 --- /dev/null +++ b/packages/a11y/libx/Gesture/withListGesture.js @@ -0,0 +1,80 @@ +import { jsx } from 'react/jsx-runtime'; +import { focusOn } from './focus'; +function getAllItems(ref) { + const closest = ref.closest('[role="list"]'); + if (!closest) { + return new NodeList(); + } + return closest.querySelectorAll('[role="listitem"]'); +} +function getNextItem(ref, loop) { + let nextElement; + let currentFound; + let hasNext; + const nodes = getAllItems(ref); + const iterator = nodes.values(); + if (loop && ref === nodes.item(nodes.length - 1)) { + return nodes.item(0); + } + do { + const { value, done } = iterator.next(); + if (currentFound) { + nextElement = value; + hasNext = false; + } else { + currentFound = value === ref; + hasNext = !done; + } + } while (hasNext); + return nextElement; +} +function getPreviousItem(ref, loop) { + let previousElement; + let hasNext; + const nodes = getAllItems(ref); + const iterator = nodes.values(); + if (loop && ref === nodes.item(0)) { + return nodes.item(nodes.length - 1); + } + do { + const { value, done } = iterator.next(); + const currentFound = value === ref; + if (currentFound) { + hasNext = false; + } else { + previousElement = value; + hasNext = !done; + } + } while (hasNext); + return previousElement; +} +function onKeyDown(event, ref, loop) { + switch (event.key) { + case 'Down': + case 'ArrowDown': + event.stopPropagation(); + event.preventDefault(); + focusOn(getNextItem(ref, loop)); + break; + case 'Up': + case 'ArrowUp': + event.stopPropagation(); + event.preventDefault(); + focusOn(getPreviousItem(ref, loop)); + break; + default: + break; + } +} +function withListGesture(WrappedComponent, loop = false) { + function ListGesture(props) { + return /* @__PURE__ */ jsx(WrappedComponent, { + ...props, + onKeyDown: (event, ref) => onKeyDown(event, ref, loop), + }); + } + ListGesture.displayName = `ListGesture(${WrappedComponent.displayName})`; + return ListGesture; +} +export { withListGesture }; +//# sourceMappingURL=withListGesture.js.map diff --git a/packages/a11y/libx/Gesture/withListGesture.js.map b/packages/a11y/libx/Gesture/withListGesture.js.map new file mode 100644 index 00000000000..a9aa1b72de7 --- /dev/null +++ b/packages/a11y/libx/Gesture/withListGesture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/withListGesture.tsx"],"sourcesContent":["import { focusOn } from './focus';\n\nfunction getAllItems(ref: HTMLElement): NodeList {\n\tconst closest = ref.closest('[role=\"list\"]');\n\tif (!closest) {\n\t\treturn new NodeList();\n\t}\n\treturn closest.querySelectorAll('[role=\"listitem\"]');\n}\n\nfunction getNextItem(ref: HTMLElement, loop: boolean) {\n\tlet nextElement;\n\tlet currentFound;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref);\n\tconst iterator = nodes.values();\n\n\tif (loop && ref === nodes.item(nodes.length - 1)) {\n\t\treturn nodes.item(0);\n\t}\n\n\tdo {\n\t\tconst { value, done } = iterator.next();\n\n\t\tif (currentFound) {\n\t\t\tnextElement = value;\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tcurrentFound = value === ref;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn nextElement;\n}\n\nfunction getPreviousItem(ref: HTMLElement, loop: boolean) {\n\tlet previousElement;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref);\n\tconst iterator = nodes.values();\n\n\tif (loop && ref === nodes.item(0)) {\n\t\treturn nodes.item(nodes.length - 1);\n\t}\n\n\tdo {\n\t\tconst { value, done } = iterator.next();\n\t\tconst currentFound = value === ref;\n\n\t\tif (currentFound) {\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tpreviousElement = value;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn previousElement;\n}\n\nfunction onKeyDown(event: KeyboardEvent, ref: HTMLElement, loop: boolean) {\n\tswitch (event.key) {\n\t\tcase 'Down':\n\t\tcase 'ArrowDown':\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tfocusOn(getNextItem(ref, loop));\n\t\t\tbreak;\n\t\tcase 'Up':\n\t\tcase 'ArrowUp':\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tfocusOn(getPreviousItem(ref, loop));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\nexport function withListGesture(WrappedComponent: React.ComponentType, loop = false) {\n\tfunction ListGesture(props: T) {\n\t\treturn (\n\t\t\t onKeyDown(event, ref, loop)}\n\t\t\t/>\n\t\t);\n\t}\n\n\tListGesture.displayName = `ListGesture(${WrappedComponent.displayName})`;\n\n\treturn ListGesture;\n}\n"],"mappings":"AAqFG;AArFH,SAAS,eAAe;AAExB,SAAS,YAAY,KAA4B;AAChD,QAAM,UAAU,IAAI,QAAQ,eAAe;AAC3C,MAAI,CAAC,SAAS;AACb,WAAO,IAAI,SAAS;AAAA,EACrB;AACA,SAAO,QAAQ,iBAAiB,mBAAmB;AACpD;AAEA,SAAS,YAAY,KAAkB,MAAe;AACrD,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,QAAM,QAAQ,YAAY,GAAG;AAC7B,QAAM,WAAW,MAAM,OAAO;AAE9B,MAAI,QAAQ,QAAQ,MAAM,KAAK,MAAM,SAAS,CAAC,GAAG;AACjD,WAAO,MAAM,KAAK,CAAC;AAAA,EACpB;AAEA,KAAG;AACF,UAAM,EAAE,OAAO,KAAK,IAAI,SAAS,KAAK;AAEtC,QAAI,cAAc;AACjB,oBAAc;AACd,gBAAU;AAAA,IACX,OAAO;AACN,qBAAe,UAAU;AACzB,gBAAU,CAAC;AAAA,IACZ;AAAA,EACD,SAAS;AAET,SAAO;AACR;AAEA,SAAS,gBAAgB,KAAkB,MAAe;AACzD,MAAI;AACJ,MAAI;AAEJ,QAAM,QAAQ,YAAY,GAAG;AAC7B,QAAM,WAAW,MAAM,OAAO;AAE9B,MAAI,QAAQ,QAAQ,MAAM,KAAK,CAAC,GAAG;AAClC,WAAO,MAAM,KAAK,MAAM,SAAS,CAAC;AAAA,EACnC;AAEA,KAAG;AACF,UAAM,EAAE,OAAO,KAAK,IAAI,SAAS,KAAK;AACtC,UAAM,eAAe,UAAU;AAE/B,QAAI,cAAc;AACjB,gBAAU;AAAA,IACX,OAAO;AACN,wBAAkB;AAClB,gBAAU,CAAC;AAAA,IACZ;AAAA,EACD,SAAS;AAET,SAAO;AACR;AAEA,SAAS,UAAU,OAAsB,KAAkB,MAAe;AACzE,UAAQ,MAAM,KAAK;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACJ,YAAM,gBAAgB;AACtB,YAAM,eAAe;AACrB,cAAQ,YAAY,KAAK,IAAI,CAAC;AAC9B;AAAA,IACD,KAAK;AAAA,IACL,KAAK;AACJ,YAAM,gBAAgB;AACtB,YAAM,eAAe;AACrB,cAAQ,gBAAgB,KAAK,IAAI,CAAC;AAClC;AAAA,IACD;AACC;AAAA,EACF;AACD;AAEO,SAAS,gBAAmB,kBAA0C,OAAO,OAAO;AAC1F,WAAS,YAAY,OAAU;AAC9B,WACC;AAAA,MAAC;AAAA;AAAA,QACC,GAAG;AAAA,QACJ,WAAW,CAAC,OAAsB,QAAqB,UAAU,OAAO,KAAK,IAAI;AAAA;AAAA,IAClF;AAAA,EAEF;AAEA,cAAY,cAAc,eAAe,iBAAiB,WAAW;AAErE,SAAO;AACR;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withMonthCalendarGesture.js b/packages/a11y/libx/Gesture/withMonthCalendarGesture.js new file mode 100644 index 00000000000..8dad8ec68d9 --- /dev/null +++ b/packages/a11y/libx/Gesture/withMonthCalendarGesture.js @@ -0,0 +1,65 @@ +import { jsx } from 'react/jsx-runtime'; +import { Component, createRef } from 'react'; +import { FIRST, LAST } from './constants'; +import { focusWithinCurrentCalendar } from './focus'; +import { preventScroll } from './preventScroll'; +function withMonthCalendarGesture(WrappedComponent, rowSize) { + var _a; + return ( + (_a = class extends Component { + constructor(props) { + super(props); + this.ref = createRef(); + this.onKeyDown = this.onKeyDown.bind(this); + } + onKeyDown(event, calendarRef, monthIndex) { + switch (event.key) { + case 'Left': + case 'ArrowLeft': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, monthIndex - 1); + break; + case 'Right': + case 'ArrowRight': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, monthIndex + 1); + break; + case 'Up': + case 'ArrowUp': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, monthIndex - rowSize); + break; + case 'Down': + case 'ArrowDown': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, monthIndex + rowSize); + break; + case 'Home': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, FIRST); + break; + case 'End': + event.stopPropagation(); + focusWithinCurrentCalendar(calendarRef, LAST); + break; + default: + break; + } + } + render() { + return /* @__PURE__ */ jsx('div', { + ref: this.ref, + onKeyDown: preventScroll, + children: /* @__PURE__ */ jsx(WrappedComponent, { + ...this.props, + onKeyDown: this.onKeyDown, + }), + }); + } + }), + (_a.displayName = `MonthCalendarGesture(${WrappedComponent.displayName})`), + _a + ); +} +export { withMonthCalendarGesture }; +//# sourceMappingURL=withMonthCalendarGesture.js.map diff --git a/packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map b/packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map new file mode 100644 index 00000000000..dfc55c5c894 --- /dev/null +++ b/packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/withMonthCalendarGesture.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n\n/* eslint-disable react/no-multi-comp,class-methods-use-this */\nimport { Component, ComponentType, createRef, KeyboardEvent as ReactKeyboardEvent } from 'react';\n\nimport { FIRST, LAST } from './constants';\nimport { focusWithinCurrentCalendar } from './focus';\nimport { preventScroll } from './preventScroll';\nimport { WithCalendarGestureInjectedProps } from './propTypes';\n\nexport function withMonthCalendarGesture

(\n\tWrappedComponent: ComponentType

,\n\trowSize: number,\n) {\n\ttype Props = Omit;\n\n\treturn class MonthCalendarGesture extends Component {\n\t\tstatic displayName = `MonthCalendarGesture(${WrappedComponent.displayName})`;\n\n\t\tref = createRef();\n\n\t\tconstructor(props: Props) {\n\t\t\tsuper(props);\n\t\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t\t}\n\n\t\tonKeyDown(\n\t\t\tevent: ReactKeyboardEvent,\n\t\t\tcalendarRef: HTMLElement,\n\t\t\tmonthIndex: number,\n\t\t) {\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'Left':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex - 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Right':\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex + 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Up':\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex - rowSize);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Down':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex + rowSize);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, FIRST);\n\t\t\t\t\tbreak;\n\t\t\t\tcase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AC9B,8BAAC,oBAAkB,GAAI,KAAK,OAAe,WAAW,KAAK,WAAW,GACvE;AAAA,IAEF;AAAA,EACD,GAxDO,GACC,cAAc,wBAAwB,iBAAiB,WAAW,KADnE;AAyDR;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withTreeGesture.js b/packages/a11y/libx/Gesture/withTreeGesture.js new file mode 100644 index 00000000000..08220efae8e --- /dev/null +++ b/packages/a11y/libx/Gesture/withTreeGesture.js @@ -0,0 +1,148 @@ +import { jsx } from 'react/jsx-runtime'; +import { Component } from 'react'; +import { focusOn } from './focus'; +function getAllItems(ref) { + const nodes = ref.closest('ul[role="tree"]'); + if (nodes) { + return nodes.querySelectorAll('li[role="treeitem"]'); + } + return null; +} +function getFirstItem(ref) { + const nodes = ref.closest('ul[role="tree"]'); + if (nodes) { + return nodes.querySelector('li[role="treeitem"]'); + } + return null; +} +function getLastItem(ref) { + const nodes = getAllItems(ref); + if (nodes && nodes.length > 0) { + return nodes.item(nodes.length - 1); + } + return null; +} +function getParentItem(ref) { + const parentElement = ref.parentElement; + if (parentElement) { + return parentElement.closest('li[role="treeitem"]'); + } + return null; +} +function getFirstChildItem(ref) { + return ref.querySelector('li[role="treeitem"]'); +} +function getNextItem(ref) { + let nextElement = null; + let currentFound; + let hasNext; + const nodes = getAllItems(ref)?.values(); + if (!nodes) { + return nextElement; + } + do { + const { value, done } = nodes.next(); + if (currentFound) { + nextElement = value; + hasNext = false; + } else { + currentFound = value === ref; + hasNext = !done; + } + } while (hasNext); + return nextElement; +} +function getPreviousItem(ref) { + let previousElement = null; + let hasNext; + const nodes = getAllItems(ref)?.values(); + if (!nodes) { + return previousElement; + } + do { + const { value, done } = nodes.next(); + const currentFound = value === ref; + if (currentFound) { + hasNext = false; + } else { + previousElement = value; + hasNext = !done; + } + } while (hasNext); + return previousElement; +} +function withTreeGesture(WrappedComponent) { + var _a; + return ( + (_a = class extends Component { + constructor(props) { + super(props); + this.onKeyDown = this.onKeyDown.bind(this); + } + onKeyDown(event, ref, item) { + const { hasChildren, isOpened, siblings } = item; + switch (event.key) { + case 'Enter': + case ' ': + case 'Spacebar': + event.stopPropagation(); + this.props.onSelect(event, item); + break; + case 'Left': + case 'ArrowLeft': + if (hasChildren && isOpened) { + event.stopPropagation(); + this.props.onToggle(event, item); + } else if (!hasChildren || !isOpened) { + event.stopPropagation(); + focusOn(getParentItem(ref)); + } + break; + case 'Right': + case 'ArrowRight': + if (hasChildren && !isOpened) { + event.stopPropagation(); + this.props.onToggle(event, item); + } else if (hasChildren && isOpened) { + event.stopPropagation(); + focusOn(getFirstChildItem(ref)); + } + break; + case 'Down': + case 'ArrowDown': + event.stopPropagation(); + focusOn(getNextItem(ref)); + break; + case 'Up': + case 'ArrowUp': + event.stopPropagation(); + focusOn(getPreviousItem(ref)); + break; + case 'Home': + event.stopPropagation(); + focusOn(getFirstItem(ref)); + break; + case 'End': + event.stopPropagation(); + focusOn(getLastItem(ref)); + break; + default: + break; + } + if (event.nativeEvent.key === '*' || event.nativeEvent.key === 'Multiply') { + event.stopPropagation(); + this.props.onToggleAllSiblings(event, siblings); + } + } + render() { + const props = { ...this.props }; + props.onKeyDown = this.onKeyDown; + return /* @__PURE__ */ jsx(WrappedComponent, { ...props }); + } + }), + (_a.displayName = `TreeGesture(${WrappedComponent.displayName})`), + _a + ); +} +export { withTreeGesture }; +//# sourceMappingURL=withTreeGesture.js.map diff --git a/packages/a11y/libx/Gesture/withTreeGesture.js.map b/packages/a11y/libx/Gesture/withTreeGesture.js.map new file mode 100644 index 00000000000..6b906236281 --- /dev/null +++ b/packages/a11y/libx/Gesture/withTreeGesture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/Gesture/withTreeGesture.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, ComponentType, KeyboardEvent } from 'react';\n\nimport { focusOn } from './focus';\n\nfunction getAllItems(ref: HTMLElement) {\n\tconst nodes = ref.closest('ul[role=\"tree\"]');\n\tif (nodes) {\n\t\treturn nodes.querySelectorAll('li[role=\"treeitem\"]');\n\t}\n\treturn null;\n}\n\nfunction getFirstItem(ref: HTMLElement): HTMLElement | null {\n\tconst nodes = ref.closest('ul[role=\"tree\"]');\n\tif (nodes) {\n\t\treturn nodes.querySelector('li[role=\"treeitem\"]');\n\t}\n\treturn null;\n}\n\nfunction getLastItem(ref: HTMLElement): HTMLElement | null {\n\tconst nodes = getAllItems(ref);\n\tif (nodes && nodes.length > 0) {\n\t\treturn nodes.item(nodes.length - 1) as HTMLElement;\n\t}\n\treturn null;\n}\n\nfunction getParentItem(ref: HTMLElement): HTMLElement | null {\n\tconst parentElement = ref.parentElement;\n\tif (parentElement) {\n\t\treturn parentElement.closest('li[role=\"treeitem\"]');\n\t}\n\treturn null;\n}\n\nfunction getFirstChildItem(ref: HTMLElement): HTMLElement | null {\n\treturn ref.querySelector('li[role=\"treeitem\"]');\n}\n\nfunction getNextItem(ref: HTMLElement): HTMLElement | null {\n\tlet nextElement = null;\n\tlet currentFound;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref)?.values();\n\tif (!nodes) {\n\t\treturn nextElement;\n\t}\n\n\tdo {\n\t\tconst { value, done } = nodes.next();\n\n\t\tif (currentFound) {\n\t\t\tnextElement = value;\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tcurrentFound = value === ref;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn nextElement;\n}\n\nfunction getPreviousItem(ref: HTMLElement) {\n\tlet previousElement = null;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref)?.values();\n\tif (!nodes) {\n\t\treturn previousElement;\n\t}\n\n\tdo {\n\t\tconst { value, done } = nodes.next();\n\t\tconst currentFound = value === ref;\n\n\t\tif (currentFound) {\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tpreviousElement = value;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn previousElement;\n}\n\nexport type TreeGestureProps = {\n\tonSelect: (e: KeyboardEvent, item: any) => void;\n\tonToggle: (e: KeyboardEvent, item: any) => void;\n\tonToggleAllSiblings: (e: KeyboardEvent, siblings: any) => void;\n};\n\nexport type WithTreeInjectedProps = TreeGestureProps & {\n\tonKeyDown: (e: KeyboardEvent, ref: any, item: any) => void;\n};\n\nexport function withTreeGesture(\n\tWrappedComponent: ComponentType,\n) {\n\ttype Props = Omit;\n\n\treturn class TreeGesture extends Component {\n\t\tstatic displayName = `TreeGesture(${WrappedComponent.displayName})`;\n\n\t\tconstructor(props: Props) {\n\t\t\tsuper(props);\n\t\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t\t}\n\n\t\tonKeyDown(event: KeyboardEvent, ref: any, item: any) {\n\t\t\tconst { hasChildren, isOpened, siblings } = item;\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'Enter':\n\t\t\t\tcase ' ':\n\t\t\t\tcase 'Spacebar':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tthis.props.onSelect(event, item);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Left':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tif (hasChildren && isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tthis.props.onToggle(event, item);\n\t\t\t\t\t} else if (!hasChildren || !isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tfocusOn(getParentItem(ref));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Right':\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tif (hasChildren && !isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tthis.props.onToggle(event, item);\n\t\t\t\t\t} else if (hasChildren && isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tfocusOn(getFirstChildItem(ref));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Down':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getNextItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Up':\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getPreviousItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getFirstItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getLastItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (event.nativeEvent.key === '*' || event.nativeEvent.key === 'Multiply') {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tthis.props.onToggleAllSiblings(event, siblings);\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\tconst props = { ...(this.props as any) };\n\t\t\tprops.onKeyDown = this.onKeyDown;\n\t\t\treturn ;\n\t\t}\n\t};\n}\n"],"mappings":"AA4KU;AA3KV,SAAS,iBAA+C;AAExD,SAAS,eAAe;AAExB,SAAS,YAAY,KAAkB;AACtC,QAAM,QAAQ,IAAI,QAAQ,iBAAiB;AAC3C,MAAI,OAAO;AACV,WAAO,MAAM,iBAAiB,qBAAqB;AAAA,EACpD;AACA,SAAO;AACR;AAEA,SAAS,aAAa,KAAsC;AAC3D,QAAM,QAAQ,IAAI,QAAQ,iBAAiB;AAC3C,MAAI,OAAO;AACV,WAAO,MAAM,cAAc,qBAAqB;AAAA,EACjD;AACA,SAAO;AACR;AAEA,SAAS,YAAY,KAAsC;AAC1D,QAAM,QAAQ,YAAY,GAAG;AAC7B,MAAI,SAAS,MAAM,SAAS,GAAG;AAC9B,WAAO,MAAM,KAAK,MAAM,SAAS,CAAC;AAAA,EACnC;AACA,SAAO;AACR;AAEA,SAAS,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sER;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/index.js b/packages/a11y/libx/index.js new file mode 100644 index 00000000000..b625cf50ef5 --- /dev/null +++ b/packages/a11y/libx/index.js @@ -0,0 +1,3 @@ +import Gesture, { focus } from './Gesture'; +export { Gesture, focus }; +//# sourceMappingURL=index.js.map diff --git a/packages/a11y/libx/index.js.map b/packages/a11y/libx/index.js.map new file mode 100644 index 00000000000..803684f71ec --- /dev/null +++ b/packages/a11y/libx/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import Gesture, { focus } from './Gesture';\n\nexport { Gesture, focus };\n"],"mappings":"AAAA,OAAO,WAAW,aAAa;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/test-setup.js b/packages/a11y/libx/test-setup.js new file mode 100644 index 00000000000..e178fbc0b35 --- /dev/null +++ b/packages/a11y/libx/test-setup.js @@ -0,0 +1,2 @@ +import '@testing-library/jest-dom/vitest'; +//# sourceMappingURL=test-setup.js.map diff --git a/packages/a11y/libx/test-setup.js.map b/packages/a11y/libx/test-setup.js.map new file mode 100644 index 00000000000..1f6c75df7d0 --- /dev/null +++ b/packages/a11y/libx/test-setup.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/test-setup.ts"],"sourcesContent":["import '@testing-library/jest-dom/vitest';\n"],"mappings":"AAAA,OAAO;","names":[]} \ No newline at end of file diff --git a/packages/a11y/package.json b/packages/a11y/package.json index d314eb6ffd6..18e3d205762 100644 --- a/packages/a11y/package.json +++ b/packages/a11y/package.json @@ -14,6 +14,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "test": "vitest run", "lint": "eslint -o eslint-report.json --format json .", @@ -37,6 +38,7 @@ "@talend/utils": "^3.7.1" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/a11y/tsup.config.ts b/packages/a11y/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/a11y/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/assets-api/libx/index.d.ts b/packages/assets-api/libx/index.d.ts new file mode 100644 index 00000000000..6057b38d4f8 --- /dev/null +++ b/packages/assets-api/libx/index.d.ts @@ -0,0 +1,50 @@ +declare global { + interface Window { + Talend: any; + } +} +interface Asset { + name: string; + version: string; + path: string; +} +interface Script { + src: string; + integrity?: string; + onload?: () => void; + onerror?: (e: Error) => void; +} +interface StyleAsset { + href: string; + integrity: string; +} +interface TypedResponse extends Response { + /** + * this will override `json` method from `Body` that is extended by `Response` + * interface Body { + * json(): Promise; + * } + */ + json

(): Promise

; +} +declare function getURL(path: string, name?: string, version?: string): any; +declare function addScript({ src, integrity, ...attr }: Script): void; +declare function toDefaultModule(value: any): any; +declare function getUMD( + name: string, + version?: string, + varName?: string, + path?: string, +): Promise; +declare function getJSON(path: string, name?: string, version?: string): Promise; +declare function addStyle({ href, integrity, ...attr }: StyleAsset): void; +declare const _default: { + getURL: typeof getURL; + getUMD: typeof getUMD; + getJSON: typeof getJSON; + addScript: typeof addScript; + addStyle: typeof addStyle; + toDefaultModule: typeof toDefaultModule; +}; + +export { type Asset, type Script, type StyleAsset, type TypedResponse, _default as default }; diff --git a/packages/assets-api/libx/index.js b/packages/assets-api/libx/index.js new file mode 100644 index 00000000000..83fdd8fcd92 --- /dev/null +++ b/packages/assets-api/libx/index.js @@ -0,0 +1,156 @@ +function getPackageVersion(name, version) { + if (name) { + const sessionVersion = sessionStorage.getItem(name); + if (sessionVersion) { + return sessionVersion; + } + const metas = document.querySelectorAll(`meta[name="${name}"]`); + if (metas.length > 1) { + console.warn(`Package ${name} is installed multiple times`); + } + if (metas.length > 0) { + return metas[0].getAttribute('content') || version; + } + } + return version; +} +function getURL(path, name, version) { + const overriddenVersion = getPackageVersion(name, version); + if (!overriddenVersion) { + throw new Error(`Version not found for ${name}`); + } + return window.Talend.getCDNUrl({ name, version: overriddenVersion, path }); +} +const TIMEOUT = 1e4; +function addScript({ src, integrity, ...attr }) { + const found = !!document.querySelector(`script[src="${src}"]`); + if (found) { + return; + } + const script = document.createElement('script'); + script.setAttribute('src', src); + script.setAttribute('type', 'text/javascript'); + script.setAttribute('crossorigin', 'anonymous'); + if (integrity) { + script.setAttribute('integrity', integrity); + } + script.async = false; + Object.assign(script, attr); + document.body.appendChild(script); +} +function toDefaultModule(value) { + return Object.create(null, { + default: { + value, + enumerable: true, + }, + __esModule: { + value: true, + }, + [Symbol.toStringTag]: { + value: 'Module', + }, + }); +} +function getUMD(name, version, varName, path) { + const cache = { resolved: false }; + function loaded() { + if (!varName) { + return false; + } + return !!window[varName]; + } + if (loaded() && varName) { + return Promise.resolve(window[varName]); + } + const src = getURL(path || '/undefined', name, version); + console.log('getUMD', src, varName); + return new Promise((resolve, reject) => { + function onload() { + if (!varName) { + cache.resolved = true; + resolve(void 0); + } else { + console.log(`${varName} onload ok`); + } + } + function onerror(e) { + console.error(e); + reject(e); + } + addScript({ src, onload, onerror }); + if (varName) { + const intervalId = setInterval(() => { + if (loaded()) { + cache.resolved = true; + clearInterval(intervalId); + resolve(window[varName]); + } + }, 200); + setTimeout(() => { + if (!cache.resolved) { + clearInterval(intervalId); + reject(new Error(`UMD from ${src}, ${varName} not found in ${TIMEOUT}`)); + } + }, TIMEOUT); + } + }); +} +async function getJSON(path, name, version) { + const url = getURL(path, name, version); + const response = await fetch(url); + if (response.ok) { + return response.json(); + } + console.error(`Response not ok: ${response.status} ${response.statusText} from ${url}`); + return void 0; +} +function addStyle({ href, integrity, ...attr }) { + const found = !!document.querySelector(`link[href="${href}"]`); + if (found) { + return; + } + const style = document.createElement('link'); + style.setAttribute('rel', 'stylesheet'); + style.setAttribute('media', 'print'); + style.setAttribute('onload', 'this.media="all"'); + if (integrity) { + style.setAttribute('integrity', integrity); + style.setAttribute('crossorigin', 'anonymous'); + } + style.setAttribute('href', href); + Object.assign(style, attr); + const title = document.getElementsByTagName('TITLE')[0]; + document.head.insertBefore(style, title); +} +if (!window.Talend) { + window.Talend = {}; +} +if (!window.Talend.getCDNUrl) { + window.Talend.getCDNUrl = info => { + const CDN_URL = window.Talend.CDN_URL; + if (CDN_URL) { + if (CDN_URL.startsWith('/')) { + const baseTag = document.querySelector('base'); + if (baseTag) { + const root = baseTag.getAttribute('href') || ''; + if (root !== '/') { + return `${root}${CDN_URL}/${info.name}/${info.version}${info.path}`; + } + } + } + return `${CDN_URL}/${info.name}/${info.version}${info.path}`; + } + return `https://statics.cloud.talend.com/${info.name}/${info.version}${info.path}`; + }; +} +var index_default = { + getURL, + getUMD, + getJSON, + addScript, + addStyle, + toDefaultModule, +}; +export { index_default as default }; +//# sourceMappingURL=index.js.map diff --git a/packages/assets-api/libx/index.js.map b/packages/assets-api/libx/index.js.map new file mode 100644 index 00000000000..e4e90ea596d --- /dev/null +++ b/packages/assets-api/libx/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable no-console */\ndeclare global {\n\tinterface Window {\n\t\tTalend: any;\n\t}\n}\n\nexport interface Asset {\n\tname: string;\n\tversion: string;\n\tpath: string;\n}\nexport interface Script {\n\tsrc: string;\n\tintegrity?: string;\n\tonload?: () => void;\n\tonerror?: (e: Error) => void;\n}\nexport interface StyleAsset {\n\thref: string;\n\tintegrity: string;\n}\n\nexport interface TypedResponse extends Response {\n\t/**\n\t * this will override `json` method from `Body` that is extended by `Response`\n\t * interface Body {\n\t * json(): Promise;\n\t * }\n\t */\n\tjson

(): Promise

;\n}\n\n/**\n *\n * Most of the parameters are optional but in fact they are not optional.\n * They are optional for dev experience because injected by a babel plugin\n */\n\nfunction getPackageVersion(name?: string, version?: string): string | undefined {\n\tif (name) {\n\t\tconst sessionVersion = sessionStorage.getItem(name);\n\t\tif (sessionVersion) {\n\t\t\treturn sessionVersion;\n\t\t}\n\n\t\tconst metas = document.querySelectorAll(`meta[name=\"${name}\"]`);\n\t\tif (metas.length > 1) {\n\t\t\tconsole.warn(`Package ${name} is installed multiple times`);\n\t\t}\n\t\tif (metas.length > 0) {\n\t\t\treturn metas[0].getAttribute('content') || version;\n\t\t}\n\t}\n\treturn version;\n}\n\nfunction getURL(path: string, name?: string, version?: string) {\n\tconst overriddenVersion = getPackageVersion(name, version);\n\tif (!overriddenVersion) {\n\t\tthrow new Error(`Version not found for ${name}`);\n\t}\n\treturn window.Talend.getCDNUrl({ name, version: overriddenVersion, path });\n}\n\nconst TIMEOUT = 10000;\n\nfunction addScript({ src, integrity, ...attr }: Script) {\n\tconst found = !!document.querySelector(`script[src=\"${src}\"]`);\n\tif (found) {\n\t\treturn;\n\t}\n\tconst script = document.createElement('script');\n\tscript.setAttribute('src', src);\n\tscript.setAttribute('type', 'text/javascript');\n\tscript.setAttribute('crossorigin', 'anonymous');\n\tif (integrity) {\n\t\tscript.setAttribute('integrity', integrity);\n\t}\n\tscript.async = false;\n\tObject.assign(script, attr);\n\tdocument.body.appendChild(script);\n}\n\nfunction toDefaultModule(value: any) {\n\treturn Object.create(null, {\n\t\tdefault: {\n\t\t\tvalue,\n\t\t\tenumerable: true,\n\t\t},\n\t\t__esModule: {\n\t\t\tvalue: true,\n\t\t},\n\t\t[Symbol.toStringTag]: {\n\t\t\tvalue: 'Module',\n\t\t},\n\t});\n}\n\nfunction getUMD(name: string, version?: string, varName?: string, path?: string) {\n\tconst cache = { resolved: false };\n\tfunction loaded() {\n\t\tif (!varName) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !!(window as any)[varName];\n\t}\n\tif (loaded() && varName) {\n\t\treturn Promise.resolve((window as any)[varName]);\n\t}\n\tconst src = getURL(path || '/undefined', name, version);\n\tconsole.log('getUMD', src, varName);\n\n\treturn new Promise((resolve, reject) => {\n\t\tfunction onload() {\n\t\t\tif (!varName) {\n\t\t\t\tcache.resolved = true;\n\t\t\t\tresolve(undefined);\n\t\t\t} else {\n\t\t\t\tconsole.log(`${varName} onload ok`);\n\t\t\t}\n\t\t}\n\t\tfunction onerror(e: Error) {\n\t\t\tconsole.error(e);\n\t\t\treject(e);\n\t\t}\n\t\taddScript({ src, onload, onerror });\n\t\tif (varName) {\n\t\t\tconst intervalId = setInterval(() => {\n\t\t\t\tif (loaded()) {\n\t\t\t\t\tcache.resolved = true;\n\t\t\t\t\tclearInterval(intervalId);\n\t\t\t\t\tresolve((window as any)[varName]);\n\t\t\t\t}\n\t\t\t}, 200);\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (!cache.resolved) {\n\t\t\t\t\tclearInterval(intervalId);\n\t\t\t\t\treject(new Error(`UMD from ${src}, ${varName} not found in ${TIMEOUT}`));\n\t\t\t\t}\n\t\t\t}, TIMEOUT);\n\t\t}\n\t});\n}\n\nasync function getJSON(path: string, name?: string, version?: string) {\n\tconst url = getURL(path, name, version);\n\tconst response: TypedResponse = await fetch(url);\n\tif (response.ok) {\n\t\treturn response.json();\n\t}\n\tconsole.error(`Response not ok: ${response.status} ${response.statusText} from ${url}`);\n\n\treturn undefined;\n}\n\nfunction addStyle({ href, integrity, ...attr }: StyleAsset) {\n\tconst found = !!document.querySelector(`link[href=\"${href}\"]`);\n\tif (found) {\n\t\treturn;\n\t}\n\tconst style = document.createElement('link');\n\tstyle.setAttribute('rel', 'stylesheet');\n\tstyle.setAttribute('media', 'print');\n\tstyle.setAttribute('onload', 'this.media=\"all\"');\n\tif (integrity) {\n\t\tstyle.setAttribute('integrity', integrity);\n\t\tstyle.setAttribute('crossorigin', 'anonymous');\n\t}\n\tstyle.setAttribute('href', href);\n\tObject.assign(style, attr);\n\tconst title = document.getElementsByTagName('TITLE')[0];\n\tdocument.head.insertBefore(style, title);\n}\n\nif (!window.Talend) {\n\twindow.Talend = {};\n}\nif (!window.Talend.getCDNUrl) {\n\twindow.Talend.getCDNUrl = (info: Asset) => {\n\t\tconst CDN_URL = window.Talend.CDN_URL;\n\t\tif (CDN_URL) {\n\t\t\tif (CDN_URL.startsWith('/')) {\n\t\t\t\tconst baseTag = document.querySelector('base');\n\t\t\t\tif (baseTag) {\n\t\t\t\t\tconst root = baseTag.getAttribute('href') || '';\n\t\t\t\t\tif (root !== '/') {\n\t\t\t\t\t\treturn `${root}${CDN_URL}/${info.name}/${info.version}${info.path}`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn `${CDN_URL}/${info.name}/${info.version}${info.path}`;\n\t\t}\n\t\treturn `https://statics.cloud.talend.com/${info.name}/${info.version}${info.path}`;\n\t};\n}\n\nexport default {\n\tgetURL,\n\tgetUMD,\n\tgetJSON,\n\taddScript,\n\taddStyle,\n\ttoDefaultModule,\n};\n"],"mappings":"AAuCA,SAAS,kBAAkB,MAAe,SAAsC;AAC/E,MAAI,MAAM;AACT,UAAM,iBAAiB,eAAe,QAAQ,IAAI;AAClD,QAAI,gBAAgB;AACnB,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,SAAS,iBAAiB,cAAc,IAAI,IAAI;AAC9D,QAAI,MAAM,SAAS,GAAG;AACrB,cAAQ,KAAK,WAAW,IAAI,8BAA8B;AAAA,IAC3D;AACA,QAAI,MAAM,SAAS,GAAG;AACrB,aAAO,MAAM,CAAC,EAAE,aAAa,SAAS,KAAK;AAAA,IAC5C;AAAA,EACD;AACA,SAAO;AACR;AAEA,SAAS,OAAO,MAAc,MAAe,SAAkB;AAC9D,QAAM,oBAAoB,kBAAkB,MAAM,OAAO;AACzD,MAAI,CAAC,mBAAmB;AACvB,UAAM,IAAI,MAAM,yBAAyB,IAAI,EAAE;AAAA,EAChD;AACA,SAAO,OAAO,OAAO,UAAU,EAAE,MAAM,SAAS,mBAAmB,KAAK,CAAC;AAC1E;AAEA,MAAM,UAAU;AAEhB,SAAS,UAAU,EAAE,KAAK,WAAW,GAAG,K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WAAS,KAAK,aAAa,OAAO,KAAK;AACxC;AAEA,IAAI,CAAC,OAAO,QAAQ;AACnB,SAAO,SAAS,CAAC;AAClB;AACA,IAAI,CAAC,OAAO,OAAO,WAAW;AAC7B,SAAO,OAAO,YAAY,CAAC,SAAgB;AAC1C,UAAM,UAAU,OAAO,OAAO;AAC9B,QAAI,SAAS;AACZ,UAAI,QAAQ,WAAW,GAAG,GAAG;AAC5B,cAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAI,SAAS;AACZ,gBAAM,OAAO,QAAQ,aAAa,MAAM,KAAK;AAC7C,cAAI,SAAS,KAAK;AACjB,mBAAO,GAAG,IAAI,GAAG,OAAO,IAAI,KAAK,IAAI,IAAI,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,UAClE;AAAA,QACD;AAAA,MACD;AACA,aAAO,GAAG,OAAO,IAAI,KAAK,IAAI,IAAI,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,IAC3D;AACA,WAAO,oCAAoC,KAAK,IAAI,IAAI,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,EACjF;AACD;AAEA,IAAO,gBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;","names":[]} \ No newline at end of file diff --git a/packages/assets-api/package.json b/packages/assets-api/package.json index 06a5b755914..7de84259b5e 100644 --- a/packages/assets-api/package.json +++ b/packages/assets-api/package.json @@ -13,6 +13,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "start": "echo nothing to start", "test": "vitest run", @@ -35,6 +36,7 @@ }, "dependencies": {}, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@talend/babel-plugin-import-from-index": "^1.13.1", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/assets-api/tsup.config.ts b/packages/assets-api/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/assets-api/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/cmf-cqrs/package.json b/packages/cmf-cqrs/package.json index af60330ca68..4fb050a0919 100644 --- a/packages/cmf-cqrs/package.json +++ b/packages/cmf-cqrs/package.json @@ -16,6 +16,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "start": "echo nothing to start", "test": "vitest run", @@ -47,6 +48,7 @@ "redux-saga": "^1.4.2" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitest/coverage-v8": "^4.0.18", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/cmf-cqrs/tsup.config.ts b/packages/cmf-cqrs/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/cmf-cqrs/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/cmf-router/package.json b/packages/cmf-router/package.json index 6d617880c01..033e5ab6570 100644 --- a/packages/cmf-router/package.json +++ b/packages/cmf-router/package.json @@ -19,6 +19,7 @@ "scripts": { "build:lib:esm": "talend-scripts build --esm", "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "start": "echo nothing to start", "test": "vitest run", "test:watch": "vitest", @@ -43,6 +44,7 @@ "react-dom": "^18.3.1" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitest/coverage-v8": "^4.0.18", "@redux-saga/testing-utils": "^1.2.1", "@talend/eslint-config": "^14.1.2", diff --git a/packages/cmf-router/tsup.config.ts b/packages/cmf-router/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/cmf-router/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/cmf/package.json b/packages/cmf/package.json index 2e12bd6de07..dc545abdd04 100644 --- a/packages/cmf/package.json +++ b/packages/cmf/package.json @@ -19,6 +19,7 @@ }, "scripts": { "build:lib": "talend-scripts build && talend-scripts build --esm", + "build:libx": "tsup && tsup-postbuild", "start": "echo nothing to start", "test": "vitest run", "test:update": "vitest run --update", @@ -61,6 +62,7 @@ "redux-thunk": "^2.4.2" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@redux-saga/testing-utils": "^1.2.1", diff --git a/packages/cmf/tsup.config.ts b/packages/cmf/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/cmf/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/components/package.json b/packages/components/package.json index 5fdeb746307..dfd190a39bd 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -16,6 +16,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:tsc": "yarn run tsc", "build:lib:esm": "talend-scripts build --esm", "watch": "talend-scripts build --watch", @@ -80,6 +81,7 @@ "warning": "^3.0.0" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/addon-links": "^10.2.1", "@storybook/react": "^10.2.1", diff --git a/packages/components/tsup.config.ts b/packages/components/tsup.config.ts new file mode 100644 index 00000000000..8b745c094f0 --- /dev/null +++ b/packages/components/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/containers/package.json b/packages/containers/package.json index 8b0f12847aa..b790516f12a 100644 --- a/packages/containers/package.json +++ b/packages/containers/package.json @@ -17,6 +17,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "start": "storybook dev -p 6007", "test": "vitest run", @@ -60,6 +61,7 @@ "reselect": "^2.5.4" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/icons": "^8.0.0", diff --git a/packages/containers/tsup.config.ts b/packages/containers/tsup.config.ts new file mode 100644 index 00000000000..8b745c094f0 --- /dev/null +++ b/packages/containers/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/dataviz/package.json b/packages/dataviz/package.json index 730583a2e0e..a037fd2ced8 100644 --- a/packages/dataviz/package.json +++ b/packages/dataviz/package.json @@ -14,6 +14,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "build-storybook": "storybook build", "extract-i18n": "i18next-scanner --config i18next-scanner.config.js", @@ -53,6 +54,7 @@ "topojson-client": "^3.1.0" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/react": "^10.2.1", "@storybook/react-vite": "^10.2.1", diff --git a/packages/dataviz/tsup.config.ts b/packages/dataviz/tsup.config.ts new file mode 100644 index 00000000000..8b745c094f0 --- /dev/null +++ b/packages/dataviz/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/design-system/package.json b/packages/design-system/package.json index 94cf594e9f5..2df1f4c4c5d 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -17,6 +17,7 @@ }, "scripts": { "build:lib": "talend-scripts build && talend-scripts build --esm", + "build:libx": "tsup && tsup-postbuild", "watch": "talend-scripts build --watch", "watch:esm": "talend-scripts build --watch --esm", "test": "vitest run", @@ -57,6 +58,7 @@ "typeface-source-sans-pro": "^1.1.13" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/addon-links": "^10.2.1", "@storybook/react": "^10.2.1", diff --git a/packages/design-system/tsup.config.ts b/packages/design-system/tsup.config.ts new file mode 100644 index 00000000000..d0c1500f7f8 --- /dev/null +++ b/packages/design-system/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +// design-system ships CSS modules AND SVG logo images from src/images/ +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + extraAssetExtensions: ['.svg', '.png', '.jpg', '.jpeg', '.gif', '.webp', '.ico'], + }), +); diff --git a/packages/design-tokens/package.json b/packages/design-tokens/package.json index e6298d8442a..d9054231caf 100644 --- a/packages/design-tokens/package.json +++ b/packages/design-tokens/package.json @@ -29,6 +29,7 @@ }, "scripts": { "build:lib": "talend-scripts build && npm run build:css", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "build:css": "sass src/index.scss dist/TalendDesignTokens.css --no-source-map --style=compressed", "lint": "eslint -o eslint-report.json --format json ." @@ -52,6 +53,7 @@ "access": "public" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "sass": "^1.97.3", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/design-tokens/tsup.config.ts b/packages/design-tokens/tsup.config.ts new file mode 100644 index 00000000000..44954f366cf --- /dev/null +++ b/packages/design-tokens/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +// design-tokens ships SCSS token files alongside the JS output. +// The separate `build:css` script for compiled CSS output is not part of this tsup build. +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/faceted-search-query-client/package.json b/packages/faceted-search-query-client/package.json index d8abdf0dae6..3c1a999fa38 100644 --- a/packages/faceted-search-query-client/package.json +++ b/packages/faceted-search-query-client/package.json @@ -17,6 +17,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "test": "vitest run", "test:watch": "vitest --watch", @@ -46,6 +47,7 @@ "lodash": "^4.17.23" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/react-faceted-search": "22.1.1", diff --git a/packages/faceted-search-query-client/tsup.config.ts b/packages/faceted-search-query-client/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/faceted-search-query-client/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/faceted-search/package.json b/packages/faceted-search/package.json index 0ba4980322a..ea1da270e04 100644 --- a/packages/faceted-search/package.json +++ b/packages/faceted-search/package.json @@ -17,6 +17,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "test": "vitest run", "test:watch": "vitest --watch", @@ -53,6 +54,7 @@ "lodash": "^4.17.23" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@storybook/react": "^10.2.1", diff --git a/packages/faceted-search/tsup.config.ts b/packages/faceted-search/tsup.config.ts new file mode 100644 index 00000000000..8b745c094f0 --- /dev/null +++ b/packages/faceted-search/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/flow-designer/package.json b/packages/flow-designer/package.json index 9ed798a3c10..78d73065883 100644 --- a/packages/flow-designer/package.json +++ b/packages/flow-designer/package.json @@ -17,6 +17,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "lint": "eslint -o eslint-report.json --format json .", "test": "vitest run", @@ -30,6 +31,7 @@ "author": "Talend ", "license": "Apache-2.0", "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/babel-plugin-import-from-index": "^1.13.1", diff --git a/packages/flow-designer/tsup.config.ts b/packages/flow-designer/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/flow-designer/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/forms/package.json b/packages/forms/package.json index f2b656e4147..41648bb0e2c 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -19,6 +19,7 @@ "build:lib:esm": "talend-scripts build --esm", "build-storybook": "storybook build", "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "test": "cross-env TZ=UTC vitest run", "test:watch": "cross-env TZ=UTC vitest", "test:cov": "cross-env TZ=UTC vitest run --coverage", @@ -66,6 +67,7 @@ "tv4": "^1.3.0" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.0", "@vitest/coverage-v8": "^4.0.18", "@talend/locales-tui-forms": "^15.2.0", diff --git a/packages/forms/tsup.config.ts b/packages/forms/tsup.config.ts new file mode 100644 index 00000000000..8b745c094f0 --- /dev/null +++ b/packages/forms/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/http/package.json b/packages/http/package.json index 2035a38c09b..1e7a0a1edcd 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -29,6 +29,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "start": "echo nothing to start", "test": "vitest run", @@ -37,6 +38,7 @@ "test:cov": "vitest run --coverage" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitest/coverage-v8": "^4.0.18", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/http/tsup.config.ts b/packages/http/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/http/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/router-bridge/package.json b/packages/router-bridge/package.json index 070c7f9437f..48cac636775 100644 --- a/packages/router-bridge/package.json +++ b/packages/router-bridge/package.json @@ -15,6 +15,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "build": "talend-scripts build", "lint": "eslint -o eslint-report.json --format json .", @@ -30,6 +31,7 @@ "license": "Apache-2.0", "homepage": "https://github.com/ui/tree/master/packages/router-bridge#readme", "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/router-bridge/tsup.config.ts b/packages/router-bridge/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/router-bridge/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/sagas/package.json b/packages/sagas/package.json index 3de91f425c5..02923794e48 100644 --- a/packages/sagas/package.json +++ b/packages/sagas/package.json @@ -17,6 +17,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "test": "vitest run", "test:watch": "vitest", @@ -50,6 +51,7 @@ "react-dom": "^18.3.1" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/sagas/tsup.config.ts b/packages/sagas/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/sagas/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/stepper/libx/Stepper.constants.js b/packages/stepper/libx/Stepper.constants.js new file mode 100644 index 00000000000..75d028e07b0 --- /dev/null +++ b/packages/stepper/libx/Stepper.constants.js @@ -0,0 +1,16 @@ +import Stepper from '@talend/react-components/lib/Stepper'; +const initialState = {}; +const STATE_KEY = 'stepper'; +const LOADING_STEPS_REMOVE = 'LOADING_STEPS_REMOVE'; +const LOADING_STEPS_INIT = 'LOADING_STEPS_INIT'; +const LOADING_STEPS_PROCEED_EVENT = 'LOADING_STEPS_PROCEED_EVENT'; +const LOADING_STEP_STATUSES = Stepper.LOADING_STEP_STATUSES; +export { + LOADING_STEPS_INIT, + LOADING_STEPS_PROCEED_EVENT, + LOADING_STEPS_REMOVE, + LOADING_STEP_STATUSES, + STATE_KEY, + initialState, +}; +//# sourceMappingURL=Stepper.constants.js.map diff --git a/packages/stepper/libx/Stepper.constants.js.map b/packages/stepper/libx/Stepper.constants.js.map new file mode 100644 index 00000000000..99b11011f90 --- /dev/null +++ b/packages/stepper/libx/Stepper.constants.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/Stepper.constants.js"],"sourcesContent":["import Stepper from '@talend/react-components/lib/Stepper';\n\nexport const initialState = {};\nexport const STATE_KEY = 'stepper';\nexport const LOADING_STEPS_REMOVE = 'LOADING_STEPS_REMOVE';\nexport const LOADING_STEPS_INIT = 'LOADING_STEPS_INIT';\nexport const LOADING_STEPS_PROCEED_EVENT = 'LOADING_STEPS_PROCEED_EVENT';\n\nexport const LOADING_STEP_STATUSES = Stepper.LOADING_STEP_STATUSES;\n"],"mappings":"AAAA,OAAO,aAAa;AAEb,MAAM,eAAe,CAAC;AACtB,MAAM,YAAY;AAClB,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAM,8BAA8B;AAEpC,MAAM,wBAAwB,QAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js b/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js new file mode 100644 index 00000000000..5687595ba86 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js @@ -0,0 +1,43 @@ +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useContext } from 'react'; +import { useTranslation } from 'react-i18next'; +import { ButtonPrimary, ButtonSecondary, Divider, StackHorizontal } from '@talend/design-system'; +import I18N from '../../../constants/i18n'; +import { StepperFormContext } from '../StepperForm.context'; +import style from '../StepperForm.module.css'; +const StepFooter = ({ children, dataFeature, isLoading, onCancel, onPrevious, onNext }) => { + const { t } = useTranslation(I18N.STEPPER_NAMESPACE); + const { currentStep, steps } = useContext(StepperFormContext); + const currentStepNavigation = steps[currentStep].navigation; + return /* @__PURE__ */ jsx('div', { + className: style['stepper-form__footer'], + children: /* @__PURE__ */ jsxs(StackHorizontal, { + gap: 'M', + align: 'center', + children: [ + /* @__PURE__ */ jsx(ButtonSecondary, { + onClick: onCancel, + 'data-feature': dataFeature?.cancel, + children: t('CANCEL', 'Cancel'), + }), + /* @__PURE__ */ jsx(Divider, { orientation: 'vertical' }), + onPrevious && + /* @__PURE__ */ jsx(ButtonSecondary, { + onClick: onPrevious, + 'data-feature': dataFeature?.previous, + children: t('PREVIOUS', 'Previous'), + }), + children, + onNext && + /* @__PURE__ */ jsx(ButtonPrimary, { + onClick: onNext, + 'data-feature': dataFeature?.next, + disabled: isLoading, + children: currentStepNavigation?.next ? t('NEXT', 'Next') : t('VALIDATE', 'Validate'), + }), + ], + }), + }); +}; +export { StepFooter }; +//# sourceMappingURL=StepFooter.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map b/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map new file mode 100644 index 00000000000..ff02e79f656 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/components/StepperForm/StepFooter/StepFooter.component.tsx"],"sourcesContent":["import { ReactNode, useContext } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { ButtonPrimary, ButtonSecondary, Divider, StackHorizontal } from '@talend/design-system';\n\nimport I18N from '../../../constants/i18n';\nimport { StepperFormContext } from '../StepperForm.context';\n\nimport style from '../StepperForm.module.css';\n\ninterface StepFooterProps {\n\tchildren?: ReactNode;\n\tdataFeature?: {\n\t\tcancel?: string;\n\t\tnext?: string;\n\t\tprevious?: string;\n\t\tsubmit?: string;\n\t};\n\tisLoading?: boolean;\n\tonCancel(): void;\n\tonNext?(): void;\n\tonPrevious?(): void;\n}\n\nexport const StepFooter = ({\n\tchildren,\n\tdataFeature,\n\tisLoading,\n\tonCancel,\n\tonPrevious,\n\tonNext,\n}: StepFooterProps) => {\n\tconst { t } = useTranslation(I18N.STEPPER_NAMESPACE);\n\tconst { currentStep, steps } = useContext(StepperFormContext);\n\n\tconst currentStepNavigation = steps[currentStep].navigation;\n\n\treturn (\n\t\t

\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{t('CANCEL', 'Cancel')}\n\t\t\t\t\n\n\t\t\t\t\n\n\t\t\t\t{onPrevious && (\n\t\t\t\t\t\n\t\t\t\t\t\t{t('PREVIOUS', 'Previous')}\n\t\t\t\t\t\n\t\t\t\t)}\n\n\t\t\t\t{children}\n\n\t\t\t\t{onNext && (\n\t\t\t\t\t\n\t\t\t\t\t\t{currentStepNavigation?.next ? t('NEXT', 'Next') : t('VALIDATE', 'Validate')}\n\t\t\t\t\t\n\t\t\t\t)}\n\t\t\t\n\t\t
\n\t);\n};\n"],"mappings":"AAuCG,SACC,KADD;AAvCH,SAAoB,kBAAkB;AACtC,SAAS,sBAAsB;AAE/B,SAAS,eAAe,iBAAiB,SAAS,uBAAuB;AAEzE,OAAO,UAAU;AACjB,SAAS,0BAA0B;AAEnC,OAAO,WAAW;AAgBX,MAAM,aAAa,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAuB;AACtB,QAAM,EAAE,EAAE,IAAI,eAAe,KAAK,iBAAiB;AACnD,QAAM,EAAE,aAAa,MAAM,IAAI,WAAW,kBAAkB;AAE5D,QAAM,wBAAwB,MAAM,WAAW,EAAE;AAEjD,SACC,oBAAC,SAAI,WAAW,MAAM,sBAAsB,GAC3C,+BAAC,mBAAgB,KAAI,KAAI,OAAM,UAC9B;AAAA,wBAAC,mBAAgB,SAAS,UAAU,gBAAc,aAAa,QAC7D,YAAE,UAAU,QAAQ,GACtB;AAAA,IAEA,oBAAC,WAAQ,aAAY,YAAW;AAAA,IAE/B,cACA,oBAAC,mBAAgB,SAAS,YAAY,gBAAc,aAAa,UAC/D,YAAE,YAAY,UAAU,GAC1B;AAAA,IAGA;AAAA,IAEA,UACA,oBAAC,iBAAc,SAAS,QAAQ,gBAAc,aAAa,MAAM,UAAU,WACzE,iCAAuB,OAAO,EAAE,QAAQ,MAAM,IAAI,EAAE,YAAY,UAAU,GAC5E;AAAA,KAEF,GACD;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/index.js b/packages/stepper/libx/components/StepperForm/StepFooter/index.js new file mode 100644 index 00000000000..8dd69385f75 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepFooter/index.js @@ -0,0 +1,3 @@ +import { StepFooter } from './StepFooter.component'; +export { StepFooter }; +//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/index.js.map b/packages/stepper/libx/components/StepperForm/StepFooter/index.js.map new file mode 100644 index 00000000000..f1eb48bed7a --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepFooter/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/components/StepperForm/StepFooter/index.ts"],"sourcesContent":["export { StepFooter } from './StepFooter.component';\n"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js new file mode 100644 index 00000000000..c3f70f7a405 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js @@ -0,0 +1,19 @@ +import { Fragment, jsx, jsxs } from 'react/jsx-runtime'; +import style from '../StepperForm.module.css'; +const StepHeader = ({ title, subtitle }) => { + return /* @__PURE__ */ jsxs(Fragment, { + children: [ + /* @__PURE__ */ jsx('h2', { + className: style['stepper-form__header__title'], + children: title, + }), + subtitle && + /* @__PURE__ */ jsx('span', { + className: style['stepper-form__header__subtitle'], + children: subtitle, + }), + ], + }); +}; +export { StepHeader }; +//# sourceMappingURL=StepHeader.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map new file mode 100644 index 00000000000..e2e183c6e51 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/components/StepperForm/StepHeader/StepHeader.component.tsx"],"sourcesContent":["import { StepHeaderProps } from './StepHeader.types';\n\nimport style from '../StepperForm.module.css';\n\nexport const StepHeader = ({ title, subtitle }: StepHeaderProps) => {\n\treturn (\n\t\t<>\n\t\t\t

{title}

\n\t\t\t{subtitle && {subtitle}}\n\t\t\n\t);\n};\n"],"mappings":"AAME,mBACC,KADD;AAJF,OAAO,WAAW;AAEX,MAAM,aAAa,CAAC,EAAE,OAAO,SAAS,MAAuB;AACnE,SACC,iCACC;AAAA,wBAAC,QAAG,WAAW,MAAM,6BAA6B,GAAI,iBAAM;AAAA,IAC3D,YAAY,oBAAC,UAAK,WAAW,MAAM,gCAAgC,GAAI,oBAAS;AAAA,KAClF;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js new file mode 100644 index 00000000000..61f2add7d5e --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=StepHeader.types.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map new file mode 100644 index 00000000000..84c51b288c4 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map @@ -0,0 +1 @@ +{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/index.js b/packages/stepper/libx/components/StepperForm/StepHeader/index.js new file mode 100644 index 00000000000..f97f33f0dc1 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepHeader/index.js @@ -0,0 +1,3 @@ +import { StepHeader } from './StepHeader.component'; +export { StepHeader }; +//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/index.js.map b/packages/stepper/libx/components/StepperForm/StepHeader/index.js.map new file mode 100644 index 00000000000..d6332baeea9 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepHeader/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/components/StepperForm/StepHeader/index.ts"],"sourcesContent":["export { StepHeader } from './StepHeader.component';\n"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.component.js b/packages/stepper/libx/components/StepperForm/StepperForm.component.js new file mode 100644 index 00000000000..8de08e6f620 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.component.js @@ -0,0 +1,51 @@ +import { jsx, jsxs } from 'react/jsx-runtime'; +import { useContext } from 'react'; +import { Stepper as StepperDS } from '@talend/design-system'; +import { StepHeader } from './StepHeader'; +import { StepperFormContext } from './StepperForm.context'; +import { getStepComponent } from './StepperForm.utils'; +import style from './StepperForm.module.css'; +const StepperForm = ({ isLoading }) => { + const { steps, currentStep } = useContext(StepperFormContext); + const currentStepData = steps[currentStep]; + const Component = currentStepData.component; + return /* @__PURE__ */ jsxs('div', { + className: style['stepper-form'], + children: [ + /* @__PURE__ */ jsx('div', { + className: style['stepper-form__steps'], + children: /* @__PURE__ */ jsx(StepperDS, { + currentStepIndex: currentStep, + loading: isLoading, + children: steps.map((step, index) => { + const { key, navigation, tooltip, name } = step; + const Step = getStepComponent(currentStep, index, !!navigation?.disableCause); + return /* @__PURE__ */ jsx( + Step, + { + tooltip: navigation?.disableCause ?? tooltip, + title: name, + }, + `step-${key}`, + ); + }), + }), + }), + /* @__PURE__ */ jsxs('div', { + className: style['stepper-form__container'], + children: [ + /* @__PURE__ */ jsx(StepHeader, { ...currentStepData.header }), + /* @__PURE__ */ jsx('section', { + className: style['stepper-form__content'], + 'data-testid': currentStepData.key, + children: /* @__PURE__ */ jsx(Component, {}), + }), + ], + }), + ], + }); +}; +StepperForm.displayName = 'StepperForm'; +var StepperForm_component_default = StepperForm; +export { StepperForm_component_default as default }; +//# sourceMappingURL=StepperForm.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.component.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.component.js.map new file mode 100644 index 00000000000..994a1ffe911 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.component.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/components/StepperForm/StepperForm.component.tsx"],"sourcesContent":["import { useContext } from 'react';\n\nimport { Stepper as StepperDS } from '@talend/design-system';\n\nimport { StepHeader } from './StepHeader';\nimport { StepperFormContext } from './StepperForm.context';\nimport { StepperProps } from './StepperForm.types';\nimport { getStepComponent } from './StepperForm.utils';\n\nimport style from './StepperForm.module.css';\n\nconst StepperForm = ({ isLoading }: StepperProps) => {\n\tconst { steps, currentStep } = useContext(StepperFormContext);\n\tconst currentStepData = steps[currentStep];\n\tconst Component = currentStepData.component;\n\n\treturn (\n\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t{steps.map((step, index) => {\n\t\t\t\t\t\tconst { key, navigation, tooltip, name } = step;\n\t\t\t\t\t\tconst Step = getStepComponent(currentStep, index, !!navigation?.disableCause);\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t\n\t\t\t
\n\t\t\t
\n\t\t\t\t\n\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t);\n};\n\nStepperForm.displayName = 'StepperForm';\n\nexport default StepperForm;\n"],"mappings":"AAyBO,cASJ,YATI;AAzBP,SAAS,kBAAkB;AAE3B,SAAS,WAAW,iBAAiB;AAErC,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAEnC,SAAS,wBAAwB;AAEjC,OAAO,WAAW;AAElB,MAAM,cAAc,CAAC,EAAE,UAAU,MAAoB;AACpD,QAAM,EAAE,OAAO,YAAY,IAAI,WAAW,kBAAkB;AAC5D,QAAM,kBAAkB,MAAM,WAAW;AACzC,QAAM,YAAY,gBAAgB;AAElC,SACC,qBAAC,SAAI,WAAW,MAAM,cAAc,GACnC;AAAA,wBAAC,SAAI,WAAW,MAAM,qBAAqB,GAC1C,8BAAC,aAAU,kBAAkB,aAAa,SAAS,WACjD,gBAAM,IAAI,CAAC,MAAM,UAAU;AAC3B,YAAM,EAAE,KAAK,YAAY,SAAS,KAAK,IAAI;AAC3C,YAAM,OAAO,iBAAiB,aAAa,OAAO,CAAC,CAAC,YAAY,YAAY;AAE5E,aACC;AAAA,QAAC;AAAA;AAAA,UAEA,SAAS,YAAY,gBAAgB;AAAA,UACrC,OAAO;AAAA;AAAA,QAFF,QAAQ,GAAG;AAAA,MAGjB;AAAA,IAEF,CAAC,GACF,GACD;AAAA,IACA,qBAAC,SAAI,WAAW,MAAM,yBAAyB,GAC9C;AAAA,0BAAC,cAAY,GAAG,gBAAgB,QAAQ;AAAA,MAExC,oBAAC,aAAQ,WAAW,MAAM,uBAAuB,GAAG,eAAa,gBAAgB,KAChF,8BAAC,aAAU,GACZ;AAAA,OACD;AAAA,KACD;AAEF;AAEA,YAAY,cAAc;AAE1B,IAAO,gCAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.context.js b/packages/stepper/libx/components/StepperForm/StepperForm.context.js new file mode 100644 index 00000000000..11f44bbf198 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.context.js @@ -0,0 +1,29 @@ +import { jsx } from 'react/jsx-runtime'; +import { createContext } from 'react'; +import { useStepperForm } from '../../hooks/useStepperForm/useStepperForm.hook'; +const emptyFn = () => {}; +const StepperFormContext = createContext({ + disableStep: emptyFn, + enableStep: emptyFn, + onNext: emptyFn, + onPrevious: emptyFn, + steps: [], + currentStep: 0, +}); +const StepperFormProvider = ({ children, initialStepIndex = 0, steps, onSubmit }) => { + const { currentStep, disableStep, enableStep, onNextStep, onPreviousStep, stepperSteps } = + useStepperForm(steps, initialStepIndex, onSubmit); + return /* @__PURE__ */ jsx(StepperFormContext.Provider, { + value: { + currentStep, + disableStep, + enableStep, + onNext: onNextStep, + onPrevious: onPreviousStep, + steps: stepperSteps, + }, + children, + }); +}; +export { StepperFormContext, StepperFormProvider }; +//# sourceMappingURL=StepperForm.context.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.context.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.context.js.map new file mode 100644 index 00000000000..cb5fae6806c --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.context.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/components/StepperForm/StepperForm.context.tsx"],"sourcesContent":["import { createContext, ReactNode } from 'react';\n\nimport { useStepperForm } from '../../hooks/useStepperForm/useStepperForm.hook';\nimport { StepperState } from '../../hooks/useStepperForm/useStepperForm.types';\nimport { StepperStep } from './StepperForm.types';\n\nconst emptyFn = () => {};\n\nexport interface StepperFormValues {\n\tcurrentStep: number;\n\tdisableStep: (stepKey: string, cause: string) => void;\n\tenableStep: (stepKey: string) => void;\n\tonNext: () => void;\n\tonPrevious: () => void;\n\tsteps: StepperState;\n}\n\nexport const StepperFormContext = createContext({\n\tdisableStep: emptyFn,\n\tenableStep: emptyFn,\n\tonNext: emptyFn,\n\tonPrevious: emptyFn,\n\tsteps: [],\n\tcurrentStep: 0,\n});\n\nexport interface StepperFormProviderProps {\n\tchildren: ReactNode;\n\tinitialStepIndex?: number;\n\tsteps: StepperStep[];\n\tonSubmit: (currentStep: number) => void;\n}\n\nexport const StepperFormProvider = ({\n\tchildren,\n\tinitialStepIndex = 0,\n\tsteps,\n\tonSubmit,\n}: StepperFormProviderProps) => {\n\tconst { currentStep, disableStep, enableStep, onNextStep, onPreviousStep, stepperSteps } =\n\t\tuseStepperForm(steps, initialStepIndex, onSubmit);\n\n\treturn (\n\t\t\n\t\t\t{children}\n\t\t\n\t);\n};\n"],"mappings":"AA2CE;AA3CF,SAAS,qBAAgC;AAEzC,SAAS,sBAAsB;AAI/B,MAAM,UAAU,MAAM;AAAC;AAWhB,MAAM,qBAAqB,cAAiC;AAAA,EAClE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO,CAAC;AAAA,EACR,aAAa;AACd,CAAC;AASM,MAAM,sBAAsB,CAAC;AAAA,EACnC;AAAA,EACA,mBAAmB;AAAA,EACnB;AAAA,EACA;AACD,MAAgC;AAC/B,QAAM,EAAE,aAAa,aAAa,YAAY,YAAY,gBAAgB,aAAa,IACtF,eAAe,OAAO,kBAAkB,QAAQ;AAEjD,SACC;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACA,OAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,OAAO;AAAA,MACR;AAAA,MAEC;AAAA;AAAA,EACF;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.module.css b/packages/stepper/libx/components/StepperForm/StepperForm.module.css new file mode 100644 index 00000000000..433f2d81523 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.module.css @@ -0,0 +1,41 @@ +.stepper-form { + display: flex; + height: calc(100% - var(--coral-sizing-m, 2.25rem) * 2); + padding: var(--coral-sizing-m, 2.25rem) 0; +} +.stepper-form__header__title { + font: var(--coral-heading-l, 600 1.125rem/140% 'Source Sans Pro'); +} +.stepper-form__header__subtitle { + font: var(--coral-paragraph-m, 400 0.875rem/140% 'Source Sans Pro'); + color: var(--coral-color-neutral-text-weak, hsl(0, 0%, 38%)); +} +.stepper-form__steps { + display: flex; + height: fit-content; + padding-right: var(--coral-spacing-l, 1.75rem); + width: 12.5rem; +} +.stepper-form__container { + display: flex; + flex-direction: column; + flex: 1; + padding-right: var(--coral-spacing-l, 1.75rem); +} +.stepper-form__content { + display: flex; + flex: 1; + flex-direction: column; + height: 100%; + padding-top: var(--coral-spacing-l, 1.75rem); + overflow: hidden; +} +.stepper-form__footer { + display: flex; +} +.stepper-form__footer hr { + max-height: var(--coral-sizing-xxxs, 1rem); +} +.stepper-form__loading { + width: 50%; +} diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.types.js b/packages/stepper/libx/components/StepperForm/StepperForm.types.js new file mode 100644 index 00000000000..74c0d087c9b --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=StepperForm.types.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.types.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.types.js.map new file mode 100644 index 00000000000..84c51b288c4 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.types.js.map @@ -0,0 +1 @@ +{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.utils.js b/packages/stepper/libx/components/StepperForm/StepperForm.utils.js new file mode 100644 index 00000000000..346e25e1fad --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.utils.js @@ -0,0 +1,26 @@ +import { Stepper } from '@talend/design-system'; +const getStepComponent = (current, index, isDisabled = false) => { + if (isDisabled) { + return Stepper.Step.Disabled; + } else if (current === index) { + return Stepper.Step.InProgress; + } else if (current > index) { + return Stepper.Step.Validated; + } + return Stepper.Step.Enabled; +}; +const getStepperState = initialSteps => { + const steps = []; + initialSteps.forEach((step, index) => { + steps.push({ + ...step, + navigation: { + previous: index - 1 >= 0 ? initialSteps[index - 1].key : void 0, + next: index + 1 < initialSteps.length ? initialSteps[index + 1].key : void 0, + }, + }); + }); + return steps; +}; +export { getStepComponent, getStepperState }; +//# sourceMappingURL=StepperForm.utils.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map new file mode 100644 index 00000000000..3ea640a5ef3 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/components/StepperForm/StepperForm.utils.ts"],"sourcesContent":["import type { ElementType } from 'react';\n\nimport { Stepper } from '@talend/design-system';\nimport { StepperStep } from './StepperForm.types';\nimport { StepperState } from '../../hooks/useStepperForm/useStepperForm.types';\n\nexport const getStepComponent = (\n\tcurrent: number,\n\tindex: number,\n\tisDisabled = false,\n): ElementType => {\n\tif (isDisabled) {\n\t\treturn Stepper.Step.Disabled;\n\t} else if (current === index) {\n\t\treturn Stepper.Step.InProgress;\n\t} else if (current > index) {\n\t\treturn Stepper.Step.Validated;\n\t}\n\treturn Stepper.Step.Enabled;\n};\n\nexport const getStepperState = (initialSteps: StepperStep[]) => {\n\tconst steps: StepperState = [];\n\n\tinitialSteps.forEach((step: StepperStep, index: number) => {\n\t\tsteps.push({\n\t\t\t...step,\n\t\t\tnavigation: {\n\t\t\t\tprevious: index - 1 >= 0 ? initialSteps[index - 1].key : undefined,\n\t\t\t\tnext: index + 1 < initialSteps.length ? initialSteps[index + 1].key : undefined,\n\t\t\t},\n\t\t});\n\t});\n\n\treturn steps;\n};\n"],"mappings":"AAEA,SAAS,eAAe;AAIjB,MAAM,mBAAmB,CAC/B,SACA,OACA,aAAa,UACI;AACjB,MAAI,YAAY;AACf,WAAO,QAAQ,KAAK;AAAA,EACrB,WAAW,YAAY,OAAO;AAC7B,WAAO,QAAQ,KAAK;AAAA,EACrB,WAAW,UAAU,OAAO;AAC3B,WAAO,QAAQ,KAAK;AAAA,EACrB;AACA,SAAO,QAAQ,KAAK;AACrB;AAEO,MAAM,kBAAkB,CAAC,iBAAgC;AAC/D,QAAM,QAAsB,CAAC;AAE7B,eAAa,QAAQ,CAAC,MAAmB,UAAkB;AAC1D,UAAM,KAAK;AAAA,MACV,GAAG;AAAA,MACH,YAAY;AAAA,QACX,UAAU,QAAQ,KAAK,IAAI,aAAa,QAAQ,CAAC,EAAE,MAAM;AAAA,QACzD,MAAM,QAAQ,IAAI,aAAa,SAAS,aAAa,QAAQ,CAAC,EAAE,MAAM;AAAA,MACvE;AAAA,IACD,CAAC;AAAA,EACF,CAAC;AAED,SAAO;AACR;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js b/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js new file mode 100644 index 00000000000..a47454994ca --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js @@ -0,0 +1,14 @@ +import { jsx } from 'react/jsx-runtime'; +import StepperForm from '../StepperForm.component'; +import { StepperFormProvider } from '../StepperForm.context'; +const StepperFormContainer = ({ initialStepIndex, steps, onSubmit }) => { + return /* @__PURE__ */ jsx(StepperFormProvider, { + initialStepIndex, + steps, + onSubmit, + children: /* @__PURE__ */ jsx(StepperForm, {}), + }); +}; +StepperFormContainer.displayName = 'StepperFormContainer'; +export { StepperFormContainer }; +//# sourceMappingURL=StepperFormContainer.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map b/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map new file mode 100644 index 00000000000..ecfabca1673 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/components/StepperForm/StepperFormContainer/StepperFormContainer.component.tsx"],"sourcesContent":["import StepperForm from '../StepperForm.component';\nimport { StepperFormProvider } from '../StepperForm.context';\nimport { StepperStep } from '../StepperForm.types';\n\nexport interface StepperFormContainerProps {\n\tinitialStepIndex?: number;\n\tonSubmit: (currentStep: number) => void;\n\tsteps: StepperStep[];\n}\n\nexport const StepperFormContainer = ({\n\tinitialStepIndex,\n\tsteps,\n\tonSubmit,\n}: StepperFormContainerProps) => {\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\n};\n\nStepperFormContainer.displayName = 'StepperFormContainer';\n"],"mappings":"AAiBG;AAjBH,OAAO,iBAAiB;AACxB,SAAS,2BAA2B;AAS7B,MAAM,uBAAuB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACD,MAAiC;AAChC,SACC,oBAAC,uBAAoB,kBAAoC,OAAc,UACtE,8BAAC,eAAY,GACd;AAEF;AAEA,qBAAqB,cAAc;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js b/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js new file mode 100644 index 00000000000..a1e86c34967 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js @@ -0,0 +1,3 @@ +import { StepperFormContainer } from './StepperFormContainer.component'; +export { StepperFormContainer }; +//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map b/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map new file mode 100644 index 00000000000..5fc01882edd --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../src/components/StepperForm/StepperFormContainer/index.ts"],"sourcesContent":["export { StepperFormContainer } from './StepperFormContainer.component';\n"],"mappings":"AAAA,SAAS,4BAA4B;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/index.js b/packages/stepper/libx/components/StepperForm/index.js new file mode 100644 index 00000000000..1a41ba4377c --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/index.js @@ -0,0 +1,10 @@ +import { StepperFormContainer as StepperForm } from './StepperFormContainer'; +import { StepFooter } from './StepFooter'; +import { StepperFormProvider, StepperFormContext } from './StepperForm.context'; +const StepperFormComponent = StepperForm; +StepperFormComponent.Context = StepperFormContext; +StepperFormComponent.Provider = StepperFormProvider; +StepperFormComponent.Footer = StepFooter; +var StepperForm_default = StepperFormComponent; +export { StepperForm_default as default }; +//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/index.js.map b/packages/stepper/libx/components/StepperForm/index.js.map new file mode 100644 index 00000000000..86df7cd4041 --- /dev/null +++ b/packages/stepper/libx/components/StepperForm/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/components/StepperForm/index.ts"],"sourcesContent":["import { StepperFormContainer as StepperForm } from './StepperFormContainer';\nimport { StepFooter } from './StepFooter';\nimport { StepperFormProvider, StepperFormContext } from './StepperForm.context';\n\nconst StepperFormComponent = StepperForm as typeof StepperForm & {\n\tContext: typeof StepperFormContext;\n\tProvider: typeof StepperFormProvider;\n\tFooter: typeof StepFooter;\n};\n\nStepperFormComponent.Context = StepperFormContext;\nStepperFormComponent.Provider = StepperFormProvider;\nStepperFormComponent.Footer = StepFooter;\n\nexport default StepperFormComponent;\n"],"mappings":"AAAA,SAAS,wBAAwB,mBAAmB;AACpD,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB,0BAA0B;AAExD,MAAM,uBAAuB;AAM7B,qBAAqB,UAAU;AAC/B,qBAAqB,WAAW;AAChC,qBAAqB,SAAS;AAE9B,IAAO,sBAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/index.js b/packages/stepper/libx/components/index.js new file mode 100644 index 00000000000..151bd576c5e --- /dev/null +++ b/packages/stepper/libx/components/index.js @@ -0,0 +1,4 @@ +import { Stepper } from '@talend/react-components'; +var components_default = Stepper; +export { components_default as default }; +//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/index.js.map b/packages/stepper/libx/components/index.js.map new file mode 100644 index 00000000000..28558f8ddf6 --- /dev/null +++ b/packages/stepper/libx/components/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["import { Stepper } from '@talend/react-components';\n\nexport default Stepper;\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,IAAO,qBAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/constants/i18n.js b/packages/stepper/libx/constants/i18n.js new file mode 100644 index 00000000000..3f3c29f44b2 --- /dev/null +++ b/packages/stepper/libx/constants/i18n.js @@ -0,0 +1,6 @@ +const STEPPER_NAMESPACE = 'tui-stepper'; +var i18n_default = { + STEPPER_NAMESPACE, +}; +export { i18n_default as default }; +//# sourceMappingURL=i18n.js.map diff --git a/packages/stepper/libx/constants/i18n.js.map b/packages/stepper/libx/constants/i18n.js.map new file mode 100644 index 00000000000..c3f1681cd25 --- /dev/null +++ b/packages/stepper/libx/constants/i18n.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/constants/i18n.ts"],"sourcesContent":["const STEPPER_NAMESPACE = 'tui-stepper';\n\nexport default {\n\tSTEPPER_NAMESPACE,\n};\n"],"mappings":"AAAA,MAAM,oBAAoB;AAE1B,IAAO,eAAQ;AAAA,EACd;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/containers/Stepper.connect.js b/packages/stepper/libx/containers/Stepper.connect.js new file mode 100644 index 00000000000..918496197b2 --- /dev/null +++ b/packages/stepper/libx/containers/Stepper.connect.js @@ -0,0 +1,9 @@ +import { connect } from 'react-redux'; +import Stepper from '@talend/react-components/lib/Stepper'; +import { getStepsForResource } from '../service/Stepper.selectors'; +const mapStateToProps = (state, ownProps) => ({ + steps: getStepsForResource(state, ownProps.resourceType, ownProps.resourceId), +}); +var Stepper_connect_default = connect(mapStateToProps)(Stepper); +export { Stepper_connect_default as default, mapStateToProps }; +//# sourceMappingURL=Stepper.connect.js.map diff --git a/packages/stepper/libx/containers/Stepper.connect.js.map b/packages/stepper/libx/containers/Stepper.connect.js.map new file mode 100644 index 00000000000..57692b8afb6 --- /dev/null +++ b/packages/stepper/libx/containers/Stepper.connect.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/containers/Stepper.connect.js"],"sourcesContent":["import { connect } from 'react-redux';\nimport Stepper from '@talend/react-components/lib/Stepper';\nimport { getStepsForResource } from '../service/Stepper.selectors';\n\nexport const mapStateToProps = (state, ownProps) => ({\n\tsteps: getStepsForResource(state, ownProps.resourceType, ownProps.resourceId),\n});\n\nexport default connect(mapStateToProps)(Stepper);\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,OAAO,aAAa;AACpB,SAAS,2BAA2B;AAE7B,MAAM,kBAAkB,CAAC,OAAO,cAAc;AAAA,EACpD,OAAO,oBAAoB,OAAO,SAAS,cAAc,SAAS,UAAU;AAC7E;AAEA,IAAO,0BAAQ,QAAQ,eAAe,EAAE,OAAO;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js new file mode 100644 index 00000000000..884a9212616 --- /dev/null +++ b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js @@ -0,0 +1,105 @@ +import { useState } from 'react'; +import { getStepperState } from '../../components/StepperForm/StepperForm.utils'; +import { NavigationDirection } from './useStepperForm.types'; +const handleStepChange = (state, navigation, direction) => { + const { from, to } = navigation; + const stepState = state.find(step => step.key === from); + if (!stepState) { + return state; + } + const newState = [...state]; + const index = state.indexOf(stepState); + newState[index].navigation = { + ...stepState.navigation, + ...(direction === NavigationDirection.NEXT ? { next: to } : { previous: to }), + }; + return newState; +}; +const disableStep = (state, stepKey, cause) => { + const stepState = state.find(step => step.key === stepKey); + if (!stepState) { + return state; + } + const nextStep = stepState.navigation?.next; + const previousStep = stepState.navigation?.previous; + const index = state.indexOf(stepState); + let newState = [...state]; + newState[index].navigation = { + ...stepState.navigation, + disableCause: cause, + }; + if (nextStep) { + newState = handleStepChange( + newState, + { from: nextStep, to: previousStep }, + NavigationDirection.PREVIOUS, + ); + } + if (previousStep) { + newState = handleStepChange( + newState, + { from: previousStep, to: nextStep }, + NavigationDirection.NEXT, + ); + } + return newState; +}; +const enableStep = (state, stepKey) => { + const stepState = state.find(step => step.key === stepKey); + if (!stepState) { + return state; + } + const nextStep = stepState.navigation?.next; + const previousStep = stepState.navigation?.previous; + const index = state.indexOf(stepState); + let newState = [...state]; + delete newState[index].navigation?.disableCause; + if (nextStep) { + newState = handleStepChange( + newState, + { from: nextStep, to: stepKey }, + NavigationDirection.PREVIOUS, + ); + } + if (previousStep) { + newState = handleStepChange( + newState, + { from: previousStep, to: stepKey }, + NavigationDirection.NEXT, + ); + } + return newState; +}; +const onChangeStep = (stepperState, stepKey) => { + const stepToGo = stepperState.find(step => step.key === stepKey); + if (stepToGo) { + return stepperState.indexOf(stepToGo); + } + return; +}; +const useStepperForm = (steps, stepIndex, onSubmit) => { + const [currentStep, setCurrentStep] = useState(stepIndex); + const [stepperSteps, setStepperSteps] = useState(getStepperState(steps)); + const currentNavigation = stepperSteps[currentStep].navigation; + return { + currentStep, + disableStep: (stepKey, cause) => setStepperSteps(disableStep(stepperSteps, stepKey, cause)), + enableStep: stepKey => setStepperSteps(enableStep(stepperSteps, stepKey)), + onNextStep: () => { + setCurrentStep( + (currentNavigation && onChangeStep(stepperSteps, currentNavigation.next)) ?? currentStep, + ); + if (!currentNavigation?.next) { + onSubmit(currentStep); + } + }, + onPreviousStep: () => + setCurrentStep( + (currentNavigation && onChangeStep(stepperSteps, currentNavigation.previous)) ?? + currentStep, + ), + stepperSteps, + }; +}; +export { useStepperForm }; +//# sourceMappingURL=useStepperForm.hook.js.map diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map new file mode 100644 index 00000000000..f528b4026d6 --- /dev/null +++ b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/hooks/useStepperForm/useStepperForm.hook.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { StepperStep } from '../../components/StepperForm/StepperForm.types';\nimport { getStepperState } from '../../components/StepperForm/StepperForm.utils';\nimport { NavigationDirection, NavigationStep, StepperState } from './useStepperForm.types';\n\nconst handleStepChange = (\n\tstate: StepperState,\n\tnavigation: NavigationStep,\n\tdirection: NavigationDirection,\n): StepperState => {\n\tconst { from, to } = navigation;\n\tconst stepState = state.find(step => step.key === from);\n\n\tif (!stepState) {\n\t\treturn state;\n\t}\n\n\tconst newState: StepperState = [...state];\n\tconst index = state.indexOf(stepState);\n\n\tnewState[index].navigation = {\n\t\t...stepState.navigation,\n\t\t...(direction === NavigationDirection.NEXT ? { next: to } : { previous: to }),\n\t};\n\n\treturn newState;\n};\n\nconst disableStep = (state: StepperState, stepKey: string, cause: string): StepperState => {\n\tconst stepState = state.find(step => step.key === stepKey);\n\n\tif (!stepState) {\n\t\treturn state;\n\t}\n\n\tconst nextStep = stepState.navigation?.next;\n\tconst previousStep = stepState.navigation?.previous;\n\tconst index = state.indexOf(stepState);\n\tlet newState: StepperState = [...state];\n\n\tnewState[index].navigation = {\n\t\t...stepState.navigation,\n\t\tdisableCause: cause,\n\t};\n\n\tif (nextStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: nextStep, to: previousStep },\n\t\t\tNavigationDirection.PREVIOUS,\n\t\t);\n\t}\n\n\tif (previousStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: previousStep, to: nextStep },\n\t\t\tNavigationDirection.NEXT,\n\t\t);\n\t}\n\n\treturn newState;\n};\n\nconst enableStep = (state: StepperState, stepKey: string): StepperState => {\n\tconst stepState = state.find(step => step.key === stepKey);\n\n\tif (!stepState) {\n\t\treturn state;\n\t}\n\n\tconst nextStep = stepState.navigation?.next;\n\tconst previousStep = stepState.navigation?.previous;\n\tconst index = state.indexOf(stepState);\n\tlet newState: StepperState = [...state];\n\n\tdelete newState[index].navigation?.disableCause;\n\n\tif (nextStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: nextStep, to: stepKey },\n\t\t\tNavigationDirection.PREVIOUS,\n\t\t);\n\t}\n\n\tif (previousStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: previousStep, to: stepKey },\n\t\t\tNavigationDirection.NEXT,\n\t\t);\n\t}\n\n\treturn newState;\n};\n\nconst onChangeStep = (stepperState: StepperState, stepKey?: string) => {\n\tconst stepToGo = stepperState.find(step => step.key === stepKey);\n\n\tif (stepToGo) {\n\t\treturn stepperState.indexOf(stepToGo);\n\t}\n\n\treturn;\n};\n\nexport const useStepperForm = (\n\tsteps: StepperStep[],\n\tstepIndex: number,\n\tonSubmit: (currentStep: number) => void,\n) => {\n\tconst [currentStep, setCurrentStep] = useState(stepIndex);\n\tconst [stepperSteps, setStepperSteps] = useState(getStepperState(steps));\n\n\tconst currentNavigation = stepperSteps[currentStep].navigation;\n\n\treturn {\n\t\tcurrentStep,\n\t\tdisableStep: (stepKey: string, cause: string) =>\n\t\t\tsetStepperSteps(disableStep(stepperSteps, stepKey, cause)),\n\n\t\tenableStep: (stepKey: string) => setStepperSteps(enableStep(stepperSteps, stepKey)),\n\t\tonNextStep: () => {\n\t\t\tsetCurrentStep(\n\t\t\t\t(currentNavigation && onChangeStep(stepperSteps, currentNavigation.next)) ?? currentStep,\n\t\t\t);\n\n\t\t\tif (!currentNavigation?.next) {\n\t\t\t\tonSubmit(currentStep);\n\t\t\t}\n\t\t},\n\t\tonPreviousStep: () =>\n\t\t\tsetCurrentStep(\n\t\t\t\t(currentNavigation && onChangeStep(stepperSteps, currentNavigation.previous)) ??\n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;AAAA,IACD;AAAA,IACA,gBAAgB,MACf;AAAA,OACE,qBAAqB,aAAa,cAAc,kBAAkB,QAAQ,MAC1E;AAAA,IACF;AAAA,IACD;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js new file mode 100644 index 00000000000..c446eae5224 --- /dev/null +++ b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js @@ -0,0 +1,7 @@ +var NavigationDirection = /* @__PURE__ */ (NavigationDirection2 => { + NavigationDirection2['NEXT'] = 'next'; + NavigationDirection2['PREVIOUS'] = 'previous'; + return NavigationDirection2; +})(NavigationDirection || {}); +export { NavigationDirection }; +//# sourceMappingURL=useStepperForm.types.js.map diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map new file mode 100644 index 00000000000..51ce6fe1702 --- /dev/null +++ b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/hooks/useStepperForm/useStepperForm.types.ts"],"sourcesContent":["import { StepperStep, StepperStepNavigation } from '../../components/StepperForm/StepperForm.types';\n\nexport interface StepState extends StepperStep {\n\tnavigation?: StepperStepNavigation;\n}\n\nexport type StepperState = StepState[];\nexport type NavigationStep = { from: string; to?: string };\nexport enum NavigationDirection {\n\tNEXT = 'next',\n\tPREVIOUS = 'previous',\n}\n"],"mappings":"AAQO,IAAK,sBAAL,kBAAKA,yBAAL;AACN,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,cAAW;AAFA,SAAAA;AAAA,GAAA;","names":["NavigationDirection"]} \ No newline at end of file diff --git a/packages/stepper/libx/index.js b/packages/stepper/libx/index.js new file mode 100644 index 00000000000..6a13d182f99 --- /dev/null +++ b/packages/stepper/libx/index.js @@ -0,0 +1,47 @@ +import { Stepper } from '@talend/react-components'; +import * as constants from './Stepper.constants'; +import StepperForm from './components/StepperForm'; +import StepperContainer from './containers/Stepper.connect'; +import { useStepperForm } from './hooks/useStepperForm/useStepperForm.hook'; +import { initStepper, proceedLoadingEvent, removeStepper } from './service/Stepper.actions'; +import stepperReducer from './service/Stepper.reducer'; +import { getStepsForResource, isResourceLoading } from './service/Stepper.selectors'; +import { getStepperKey } from './service/Stepper.utils'; +const { isAllSuccessful, isStepsLoading, isErrorInSteps } = Stepper; +const cmfModule = { + id: 'dataset-stepper', + reducer: { + [constants.STATE_KEY]: stepperReducer, + }, +}; +const StepperActions = { + initStepper, + proceedLoadingEvent, + removeStepper, +}; +const StepperSelectors = { + getStepsForResource, + isResourceLoading, +}; +const StepperComponents = { + Stepper: StepperContainer, +}; +const StepperUtils = { + isAllSuccessful, + isErrorInSteps, + isStepsLoading, + getStepperKey, +}; +const StepperConstants = constants; +var index_default = { ...cmfModule }; +export { + StepperActions, + StepperComponents, + StepperConstants, + StepperForm, + StepperSelectors, + StepperUtils, + index_default as default, + useStepperForm, +}; +//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/index.js.map b/packages/stepper/libx/index.js.map new file mode 100644 index 00000000000..90a032c4875 --- /dev/null +++ b/packages/stepper/libx/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Stepper } from '@talend/react-components';\n\nimport * as constants from './Stepper.constants';\nimport StepperForm from './components/StepperForm';\nimport StepperContainer from './containers/Stepper.connect';\nimport { useStepperForm } from './hooks/useStepperForm/useStepperForm.hook';\nimport { initStepper, proceedLoadingEvent, removeStepper } from './service/Stepper.actions';\nimport stepperReducer from './service/Stepper.reducer';\nimport { getStepsForResource, isResourceLoading } from './service/Stepper.selectors';\nimport { getStepperKey } from './service/Stepper.utils';\n\nconst { isAllSuccessful, isStepsLoading, isErrorInSteps } = Stepper;\n\nconst cmfModule = {\n\tid: 'dataset-stepper',\n\treducer: {\n\t\t[constants.STATE_KEY]: stepperReducer,\n\t},\n};\n\nexport const StepperActions = {\n\tinitStepper,\n\tproceedLoadingEvent,\n\tremoveStepper,\n};\n\nexport const StepperSelectors = {\n\tgetStepsForResource,\n\tisResourceLoading,\n};\n\nexport const StepperComponents = {\n\tStepper: StepperContainer,\n};\n\nexport const StepperUtils = {\n\tisAllSuccessful,\n\tisErrorInSteps,\n\tisStepsLoading,\n\tgetStepperKey,\n};\n\nexport const StepperConstants = constants;\n\nexport { StepperForm, useStepperForm };\nexport default { ...cmfModule };\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,YAAY,eAAe;AAC3B,OAAO,iBAAiB;AACxB,OAAO,sBAAsB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,aAAa,qBAAqB,qBAAqB;AAChE,OAAO,oBAAoB;AAC3B,SAAS,qBAAqB,yBAAyB;AACvD,SAAS,qBAAqB;AAE9B,MAAM,EAAE,iBAAiB,gBAAgB,eAAe,IAAI;AAE5D,MAAM,YAAY;AAAA,EACjB,IAAI;AAAA,EACJ,SAAS;AAAA,IACR,CAAC,UAAU,SAAS,GAAG;AAAA,EACxB;AACD;AAEO,MAAM,iBAAiB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA;AACD;AAEO,MAAM,oBAAoB;AAAA,EAChC,SAAS;AACV;AAEO,MAAM,eAAe;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,mBAAmB;AAGhC,IAAO,gBAAQ,EAAE,GAAG,UAAU;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.actions.js b/packages/stepper/libx/service/Stepper.actions.js new file mode 100644 index 00000000000..09495e430c0 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.actions.js @@ -0,0 +1,42 @@ +import { + LOADING_STEPS_INIT, + LOADING_STEPS_PROCEED_EVENT, + LOADING_STEPS_REMOVE, +} from '../Stepper.constants'; +function checkResourceParameters(resourceType, resourceId) { + if (!resourceType) { + throw new Error('Stepper Reducer : resourceType should be present in the action'); + } + if (!resourceId) { + throw new Error('Stepper Reducer : resourceId should be present in the action'); + } +} +function initStepper(resourceType, resourceId, steps = []) { + checkResourceParameters(resourceType, resourceId); + return { + type: LOADING_STEPS_INIT, + resourceType, + resourceId, + steps, + }; +} +function proceedLoadingEvent(resourceType, resourceId, event, messageLabel) { + checkResourceParameters(resourceType, resourceId); + return { + type: LOADING_STEPS_PROCEED_EVENT, + resourceType, + resourceId, + event, + message: { label: messageLabel }, + }; +} +function removeStepper(resourceType, resourceId) { + checkResourceParameters(resourceType, resourceId); + return { + type: LOADING_STEPS_REMOVE, + resourceType, + resourceId, + }; +} +export { initStepper, proceedLoadingEvent, removeStepper }; +//# sourceMappingURL=Stepper.actions.js.map diff --git a/packages/stepper/libx/service/Stepper.actions.js.map b/packages/stepper/libx/service/Stepper.actions.js.map new file mode 100644 index 00000000000..f1a6cf065a4 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.actions.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/service/Stepper.actions.js"],"sourcesContent":["import {\n\tLOADING_STEPS_INIT,\n\tLOADING_STEPS_PROCEED_EVENT,\n\tLOADING_STEPS_REMOVE,\n} from '../Stepper.constants';\n\nfunction checkResourceParameters(resourceType, resourceId) {\n\tif (!resourceType) {\n\t\tthrow new Error('Stepper Reducer : resourceType should be present in the action');\n\t}\n\tif (!resourceId) {\n\t\tthrow new Error('Stepper Reducer : resourceId should be present in the action');\n\t}\n}\n\n/**\n * This function init the store for some loading steps component\n * @param {string} resourceType the resource type we load\n * @param {string} resourceId the id of the resource we load\n * @param {array} steps the steps we have to load\n */\nexport function initStepper(resourceType, resourceId, steps = []) {\n\tcheckResourceParameters(resourceType, resourceId);\n\treturn {\n\t\ttype: LOADING_STEPS_INIT,\n\t\tresourceType,\n\t\tresourceId,\n\t\tsteps,\n\t};\n}\n\n/**\n * This function generate an action to tell the loading that we have\n * intercept some event to proceed in the loading process\n * @param {string} resourceType the resource type we load\n * @param {string} resourceId the id of the resource we load\n * @param {string} event event catch\n */\nexport function proceedLoadingEvent(resourceType, resourceId, event, messageLabel) {\n\tcheckResourceParameters(resourceType, resourceId);\n\treturn {\n\t\ttype: LOADING_STEPS_PROCEED_EVENT,\n\t\tresourceType,\n\t\tresourceId,\n\t\tevent,\n\t\tmessage: { label: messageLabel },\n\t};\n}\n\n/**\n * This function return an action to remove a loading from the store\n * @param {string} resourceType the resource type we load\n * @param {string} resourceId the id of the resource we load\n */\nexport function removeStepper(resourceType, resourceId) {\n\tcheckResourceParameters(resourceType, resourceId);\n\treturn {\n\t\ttype: LOADING_STEPS_REMOVE,\n\t\tresourceType,\n\t\tresourceId,\n\t};\n}\n"],"mappings":"AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,wBAAwB,cAAc,YAAY;AAC1D,MAAI,CAAC,cAAc;AAClB,UAAM,IAAI,MAAM,gEAAgE;AAAA,EACjF;AACA,MAAI,CAAC,YAAY;AAChB,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAC/E;AACD;AAQO,SAAS,YAAY,cAAc,YAAY,QAAQ,CAAC,GAAG;AACjE,0BAAwB,cAAc,UAAU;AAChD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AASO,SAAS,oBAAoB,cAAc,YAAY,OAAO,cAAc;AAClF,0BAAwB,cAAc,UAAU;AAChD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,EAAE,OAAO,aAAa;AAAA,EAChC;AACD;AAOO,SAAS,cAAc,cAAc,YAAY;AACvD,0BAAwB,cAAc,UAAU;AAChD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.reducer.js b/packages/stepper/libx/service/Stepper.reducer.js new file mode 100644 index 00000000000..9057c52c5a3 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.reducer.js @@ -0,0 +1,119 @@ +import omit from 'lodash/omit'; +import get from 'lodash/get'; +import invariant from 'invariant'; +import Stepper from '@talend/react-components/lib/Stepper'; +import { + LOADING_STEP_STATUSES, + initialState, + LOADING_STEPS_INIT, + LOADING_STEPS_REMOVE, + LOADING_STEPS_PROCEED_EVENT, +} from '../Stepper.constants'; +import { getStepperKey } from './Stepper.utils'; +const isInStepAttribute = (stepAttribute, value) => + (typeof stepAttribute === 'string' && stepAttribute === value) || + (Array.isArray(stepAttribute) && stepAttribute.includes(value)); +const checkAttribute = attributeName => (step, event) => + isInStepAttribute(step[attributeName], event); +const isEventTriggerFail = checkAttribute('failureOn'); +const isEventTriggerSuccess = checkAttribute('successOn'); +const isEventTriggerLoading = checkAttribute('loadingOn'); +function mapStepWithNoError(step, action) { + if (isEventTriggerSuccess(step, action.event)) { + return { + ...step, + status: LOADING_STEP_STATUSES.SUCCESS, + }; + } + if (isEventTriggerLoading(step, action.event) && step.status !== LOADING_STEP_STATUSES.SUCCESS) { + return { + ...step, + status: LOADING_STEP_STATUSES.LOADING, + }; + } + return step; +} +function getNewStepsWithError(steps, action) { + let errorHandled = false; + return steps.map(step => { + if (step.status !== LOADING_STEP_STATUSES.SUCCESS) { + if (!errorHandled && isEventTriggerFail(step, action.event)) { + errorHandled = true; + return { + ...step, + status: LOADING_STEP_STATUSES.FAILURE, + message: action.message, + }; + } + return { + ...step, + status: LOADING_STEP_STATUSES.ABORTED, + }; + } + return step; + }); +} +const hasAttribute = (step, attribute) => + step[attribute] || (Array.isArray(step[attribute]) && step[attribute].length > 0); +const hasStepFailure = step => hasAttribute(step, 'failureOn'); +const hasStepSuccess = step => hasAttribute(step, 'successOn'); +const hasStepLoading = step => hasAttribute(step, 'loadingOn'); +function checkSteps(steps) { + return steps.map(step => { + if (!hasStepFailure(step)) { + invariant( + process.env.NODE_ENV === 'production', + `Stepper : No failureOn step for ${step.label} step`, + ); + } + if (!hasStepSuccess(step)) { + invariant( + process.env.NODE_ENV === 'production', + `Stepper : No successOn step for ${step.label} step`, + ); + } + if (!hasStepLoading(step) && !step.status) { + invariant( + process.env.NODE_ENV === 'production', + `Stepper : No loadingOn step or initial status for ${step.label} step`, + ); + } + if (!step.status) { + return { ...step, status: LOADING_STEP_STATUSES.PENDING }; + } + return step; + }); +} +function handleEvent(state, action) { + const loadingKey = getStepperKey(action); + const loadingResource = get(state, [loadingKey], {}); + const steps = get(loadingResource, 'steps', []); + if (!Stepper.isStepsLoading(steps)) { + return state; + } + const isErrorTriggered = !!steps.find(step => isInStepAttribute(step.failureOn, action.event)); + let newSteps; + if (isErrorTriggered) { + newSteps = getNewStepsWithError(steps, action); + } else { + newSteps = steps.map(step => mapStepWithNoError(step, action)); + } + return { + ...state, + [loadingKey]: { ...loadingResource, steps: newSteps }, + }; +} +function stepperReducer(state = initialState, action) { + switch (action.type) { + case LOADING_STEPS_INIT: + return { ...state, [getStepperKey(action)]: { steps: checkSteps(action.steps) } }; + case LOADING_STEPS_REMOVE: + return omit(state, getStepperKey(action)); + case LOADING_STEPS_PROCEED_EVENT: + return handleEvent(state, action); + default: + return state; + } +} +export { stepperReducer as default }; +//# sourceMappingURL=Stepper.reducer.js.map diff --git a/packages/stepper/libx/service/Stepper.reducer.js.map b/packages/stepper/libx/service/Stepper.reducer.js.map new file mode 100644 index 00000000000..d81d527ff9a --- /dev/null +++ b/packages/stepper/libx/service/Stepper.reducer.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/service/Stepper.reducer.js"],"sourcesContent":["import omit from 'lodash/omit';\nimport get from 'lodash/get';\nimport invariant from 'invariant';\nimport Stepper from '@talend/react-components/lib/Stepper';\nimport {\n\tLOADING_STEP_STATUSES,\n\tinitialState,\n\tLOADING_STEPS_INIT,\n\tLOADING_STEPS_REMOVE,\n\tLOADING_STEPS_PROCEED_EVENT,\n} from '../Stepper.constants';\nimport { getStepperKey } from './Stepper.utils';\n\nconst isInStepAttribute = (stepAttribute, value) =>\n\t(typeof stepAttribute === 'string' && stepAttribute === value) ||\n\t(Array.isArray(stepAttribute) && stepAttribute.includes(value));\n\nconst checkAttribute = attributeName => (step, event) =>\n\tisInStepAttribute(step[attributeName], event);\n\nconst isEventTriggerFail = checkAttribute('failureOn');\nconst isEventTriggerSuccess = checkAttribute('successOn');\nconst isEventTriggerLoading = checkAttribute('loadingOn');\n\nfunction mapStepWithNoError(step, action) {\n\tif (isEventTriggerSuccess(step, action.event)) {\n\t\treturn {\n\t\t\t...step,\n\t\t\tstatus: LOADING_STEP_STATUSES.SUCCESS,\n\t\t};\n\t}\n\tif (isEventTriggerLoading(step, action.event) && step.status !== LOADING_STEP_STATUSES.SUCCESS) {\n\t\treturn {\n\t\t\t...step,\n\t\t\tstatus: LOADING_STEP_STATUSES.LOADING,\n\t\t};\n\t}\n\treturn step;\n}\n\nfunction getNewStepsWithError(steps, action) {\n\tlet errorHandled = false;\n\treturn steps.map(step => {\n\t\tif (step.status !== LOADING_STEP_STATUSES.SUCCESS) {\n\t\t\tif (!errorHandled && isEventTriggerFail(step, action.event)) {\n\t\t\t\terrorHandled = true;\n\t\t\t\treturn {\n\t\t\t\t\t...step,\n\t\t\t\t\tstatus: LOADING_STEP_STATUSES.FAILURE,\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...step,\n\t\t\t\tstatus: LOADING_STEP_STATUSES.ABORTED,\n\t\t\t};\n\t\t}\n\t\treturn step;\n\t});\n}\n\nconst hasAttribute = (step, attribute) =>\n\tstep[attribute] || (Array.isArray(step[attribute]) && step[attribute].length > 0);\n\nconst hasStepFailure = step => hasAttribute(step, 'failureOn');\nconst hasStepSuccess = step => hasAttribute(step, 'successOn');\nconst hasStepLoading = step => hasAttribute(step, 'loadingOn');\n\n/**\n * This function check & mutate the steps\n * @param {array} steps the loading steps\n */\nfunction checkSteps(steps) {\n\treturn steps.map(step => {\n\t\tif (!hasStepFailure(step)) {\n\t\t\tinvariant(\n\t\t\t\tprocess.env.NODE_ENV === 'production',\n\t\t\t\t`Stepper : No failureOn step for ${step.label} step`,\n\t\t\t);\n\t\t}\n\t\tif (!hasStepSuccess(step)) {\n\t\t\tinvariant(\n\t\t\t\tprocess.env.NODE_ENV === 'production',\n\t\t\t\t`Stepper : No successOn step for ${step.label} step`,\n\t\t\t);\n\t\t}\n\t\tif (!hasStepLoading(step) && !step.status) {\n\t\t\tinvariant(\n\t\t\t\tprocess.env.NODE_ENV === 'production',\n\t\t\t\t`Stepper : No loadingOn step or initial status for ${step.label} step`,\n\t\t\t);\n\t\t}\n\t\tif (!step.status) {\n\t\t\treturn { ...step, status: LOADING_STEP_STATUSES.PENDING };\n\t\t}\n\t\treturn step;\n\t});\n}\n\n/**\n * This function change the status of the steps in order to reflect the event\n * @param {object} state redux state\n * @param {object} action the redux action\n */\nfunction handleEvent(state, action) {\n\tconst loadingKey = getStepperKey(action);\n\tconst loadingResource = get(state, [loadingKey], {});\n\tconst steps = get(loadingResource, 'steps', []);\n\tif (!Stepper.isStepsLoading(steps)) {\n\t\treturn state;\n\t}\n\tconst isErrorTriggered = !!steps.find(step => isInStepAttribute(step.failureOn, action.event));\n\tlet newSteps;\n\tif (isErrorTriggered) {\n\t\tnewSteps = getNewStepsWithError(steps, action);\n\t} else {\n\t\tnewSteps = steps.map(step => mapStepWithNoError(step, action));\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[loadingKey]: { ...loadingResource, steps: newSteps },\n\t};\n}\n\n/**\n * This function is a classic reducer\n * It handle the Loading Steps of a resource\n * @param {object} state Redux state\n * @param {object} action Redux Action\n */\nexport default function stepperReducer(state = initialState, action) {\n\tswitch (action.type) {\n\t\tcase LOADING_STEPS_INIT:\n\t\t\treturn { ...state, [getStepperKey(action)]: { steps: checkSteps(action.steps) } };\n\t\tcase LOADING_STEPS_REMOVE:\n\t\t\treturn omit(state, getStepperKey(action));\n\t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,KAAK,CAAC;AAC7F,MAAI;AACJ,MAAI,kBAAkB;AACrB,eAAW,qBAAqB,OAAO,MAAM;AAAA,EAC9C,OAAO;AACN,eAAW,MAAM,IAAI,UAAQ,mBAAmB,MAAM,MAAM,CAAC;AAAA,EAC9D;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAC,UAAU,GAAG,EAAE,GAAG,iBAAiB,OAAO,SAAS;AAAA,EACrD;AACD;AAQe,SAAR,eAAgC,QAAQ,cAAc,QAAQ;AACpE,UAAQ,OAAO,MAAM;AAAA,IACpB,KAAK;AACJ,aAAO,EAAE,GAAG,OAAO,CAAC,cAAc,MAAM,CAAC,GAAG,EAAE,OAAO,WAAW,OAAO,KAAK,EAAE,EAAE;AAAA,IACjF,KAAK;AACJ,aAAO,KAAK,OAAO,cAAc,MAAM,CAAC;AAAA,IACzC,KAAK;AACJ,aAAO,YAAY,OAAO,MAAM;AAAA,IACjC;AACC,aAAO;AAAA,EACT;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.selectors.js b/packages/stepper/libx/service/Stepper.selectors.js new file mode 100644 index 00000000000..052d29b5350 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.selectors.js @@ -0,0 +1,12 @@ +import get from 'lodash/get'; +import Stepper from '@talend/react-components/lib/Stepper'; +import { STATE_KEY } from '../Stepper.constants'; +import { getStepperKey } from './Stepper.utils'; +function getStepsForResource(store, resourceType, resourceId) { + return get(store, [STATE_KEY, getStepperKey({ resourceType, resourceId }), 'steps'], []); +} +function isResourceLoading(store, resourceType, resourceId) { + return Stepper.isStepsLoading(getStepsForResource(store, resourceType, resourceId)); +} +export { getStepsForResource, isResourceLoading }; +//# sourceMappingURL=Stepper.selectors.js.map diff --git a/packages/stepper/libx/service/Stepper.selectors.js.map b/packages/stepper/libx/service/Stepper.selectors.js.map new file mode 100644 index 00000000000..e9fa235d655 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.selectors.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/service/Stepper.selectors.js"],"sourcesContent":["import get from 'lodash/get';\nimport Stepper from '@talend/react-components/lib/Stepper';\nimport { STATE_KEY } from '../Stepper.constants';\nimport { getStepperKey } from './Stepper.utils';\n\nexport function getStepsForResource(store, resourceType, resourceId) {\n\treturn get(store, [STATE_KEY, getStepperKey({ resourceType, resourceId }), 'steps'], []);\n}\n\nexport function isResourceLoading(store, resourceType, resourceId) {\n\treturn Stepper.isStepsLoading(getStepsForResource(store, resourceType, resourceId));\n}\n"],"mappings":"AAAA,OAAO,SAAS;AAChB,OAAO,aAAa;AACpB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAEvB,SAAS,oBAAoB,OAAO,cAAc,YAAY;AACpE,SAAO,IAAI,OAAO,CAAC,WAAW,cAAc,EAAE,cAAc,WAAW,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC;AACxF;AAEO,SAAS,kBAAkB,OAAO,cAAc,YAAY;AAClE,SAAO,QAAQ,eAAe,oBAAoB,OAAO,cAAc,UAAU,CAAC;AACnF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.utils.js b/packages/stepper/libx/service/Stepper.utils.js new file mode 100644 index 00000000000..6f9c0bf23f5 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.utils.js @@ -0,0 +1,3 @@ +const getStepperKey = action => `${action.resourceType}-${action.resourceId}`; +export { getStepperKey }; +//# sourceMappingURL=Stepper.utils.js.map diff --git a/packages/stepper/libx/service/Stepper.utils.js.map b/packages/stepper/libx/service/Stepper.utils.js.map new file mode 100644 index 00000000000..82d2a5c7ee7 --- /dev/null +++ b/packages/stepper/libx/service/Stepper.utils.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/service/Stepper.utils.js"],"sourcesContent":["/**\n * This function returns the key to point the loading step in the store\n * It's based on the resourceType / resourceId\n * internally usage only in the loading step service\n * @param {object} action redux action\n */\n// eslint-disable-next-line\nexport const getStepperKey = action => `${action.resourceType}-${action.resourceId}`;\n"],"mappings":"AAOO,MAAM,gBAAgB,YAAU,GAAG,OAAO,YAAY,IAAI,OAAO,UAAU;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/stories/Stepper.components.js b/packages/stepper/libx/stories/Stepper.components.js new file mode 100644 index 00000000000..c494f4fcad9 --- /dev/null +++ b/packages/stepper/libx/stories/Stepper.components.js @@ -0,0 +1,186 @@ +import { jsx, jsxs } from 'react/jsx-runtime'; +import { createContext, useContext, useEffect } from 'react'; +import { FormProvider, useController, useForm } from 'react-hook-form'; +import { Form, InlineMessageDestructive } from '@talend/design-system'; +import StepperForm from '../components/StepperForm'; +const BusinessContext = createContext({}); +const FormComponentStep1 = () => { + const { disableStep, enableStep, onNext } = useContext(StepperForm.Context); + const { stepsData, setStepsData } = useContext(BusinessContext); + const rhf = useForm({ + defaultValues: { ...stepsData[0] }, + }); + const { field, fieldState } = useController({ + control: rhf.control, + name: 'randomInput', + rules: { + required: true, + }, + }); + useEffect(() => { + const data = stepsData; + data[0] = { [field.name]: field.value }; + setStepsData(data); + }, [field]); + return /* @__PURE__ */ jsx(FormProvider, { + ...rhf, + children: /* @__PURE__ */ jsxs(Form, { + children: [ + /* @__PURE__ */ jsxs(Form.Fieldset, { + children: [ + /* @__PURE__ */ jsx(Form.Checkbox, { + id: 'disable1', + name: 'disable-steps', + label: 'Disable step 2', + onChange: e => { + if (e.target.checked) { + disableStep('STEP2', 'Disabled cause'); + } else { + enableStep('STEP2'); + } + }, + }), + /* @__PURE__ */ jsx(Form.Checkbox, { + id: 'disable2', + name: 'disable-steps', + label: 'Disable step 3', + onChange: e => { + if (e.target.checked) { + disableStep('STEP3', 'Just because'); + } else { + enableStep('STEP3'); + } + }, + }), + fieldState.invalid && + /* @__PURE__ */ jsx(InlineMessageDestructive, { + description: 'This field is required', + withBackground: true, + }), + /* @__PURE__ */ jsx(Form.Input, { + id: 'randomInput', + label: 'Random input', + name: field.name, + onChange: e => { + field.onChange(e); + }, + value: field.value, + }), + ], + }), + /* @__PURE__ */ jsx(StepperForm.Footer, { + onCancel: () => alert('Cancel action'), + onNext: () => rhf.handleSubmit(onNext)(), + }), + ], + }), + }); +}; +const FormComponentStep2 = () => { + const { disableStep, enableStep, onNext, onPrevious } = useContext(StepperForm.Context); + const { stepsData, setStepsData } = useContext(BusinessContext); + const rhf = useForm({ + defaultValues: { ...stepsData[1] }, + }); + const { field, fieldState } = useController({ + control: rhf.control, + name: 'randomInput', + rules: { + required: true, + }, + }); + useEffect(() => { + const data = stepsData; + data[1] = { [field.name]: field.value }; + setStepsData(data); + }, [field]); + return /* @__PURE__ */ jsx(FormProvider, { + ...rhf, + children: /* @__PURE__ */ jsxs(Form, { + children: [ + /* @__PURE__ */ jsxs(Form.Fieldset, { + children: [ + /* @__PURE__ */ jsx(Form.Checkbox, { + id: 'disable1', + name: 'disable-steps', + label: 'Disable step 3', + onChange: e => { + if (e.target.checked) { + disableStep('STEP3', 'Disabled cause'); + } else { + enableStep('STEP3'); + } + }, + }), + fieldState.invalid && + /* @__PURE__ */ jsx(InlineMessageDestructive, { + description: 'This field is required', + withBackground: true, + }), + /* @__PURE__ */ jsx(Form.Input, { + id: 'randomInput', + label: 'Random input', + name: field.name, + onChange: field.onChange, + value: field.value, + }), + ], + }), + /* @__PURE__ */ jsx(StepperForm.Footer, { + onCancel: () => alert('Cancel action'), + onNext: () => rhf.handleSubmit(onNext)(), + onPrevious, + }), + ], + }), + }); +}; +const FormComponentStep3 = () => { + const { onNext, onPrevious } = useContext(StepperForm.Context); + const { stepsData, setStepsData } = useContext(BusinessContext); + const rhf = useForm({ + defaultValues: { ...stepsData[2] }, + }); + const { field, fieldState } = useController({ + control: rhf.control, + name: 'randomInput', + rules: { + required: true, + }, + }); + useEffect(() => { + const data = stepsData; + data[2] = { [field.name]: field.value }; + setStepsData(data); + }, [field]); + return /* @__PURE__ */ jsx(FormProvider, { + ...rhf, + children: /* @__PURE__ */ jsxs(Form, { + children: [ + /* @__PURE__ */ jsxs(Form.Fieldset, { + children: [ + fieldState.invalid && + /* @__PURE__ */ jsx(InlineMessageDestructive, { + description: 'This field is required', + withBackground: true, + }), + /* @__PURE__ */ jsx(Form.Input, { + id: 'randomInput', + label: 'Random input', + name: field.name, + onChange: field.onChange, + value: field.value, + }), + ], + }), + /* @__PURE__ */ jsx(StepperForm.Footer, { + onCancel: () => alert('Cancel action'), + onNext: () => rhf.handleSubmit(onNext)(), + onPrevious, + }), + ], + }), + }); +}; +export { BusinessContext, FormComponentStep1, FormComponentStep2, FormComponentStep3 }; +//# sourceMappingURL=Stepper.components.js.map diff --git a/packages/stepper/libx/stories/Stepper.components.js.map b/packages/stepper/libx/stories/Stepper.components.js.map new file mode 100644 index 00000000000..5d764ed9f78 --- /dev/null +++ b/packages/stepper/libx/stories/Stepper.components.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/stories/Stepper.components.tsx"],"sourcesContent":["import { createContext, useContext, useEffect } from 'react';\nimport { FormProvider, useController, useForm } from 'react-hook-form';\n\nimport { Form, InlineMessageDestructive } from '@talend/design-system';\n\nimport StepperForm from '../components/StepperForm';\n\ninterface BusinessContextApi {\n\tsetStepsData: (stepData: any) => void;\n\tstepsData: any[];\n}\n\nexport const BusinessContext = createContext({} as BusinessContextApi);\n\nexport const FormComponentStep1 = () => {\n\tconst { disableStep, enableStep, onNext } = useContext(StepperForm.Context);\n\tconst { stepsData, setStepsData } = useContext(BusinessContext);\n\n\tconst rhf = useForm({\n\t\tdefaultValues: { ...stepsData[0] },\n\t});\n\n\tconst { field, fieldState } = useController({\n\t\tcontrol: rhf.control,\n\t\tname: 'randomInput',\n\t\trules: {\n\t\t\trequired: true,\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst data = stepsData;\n\t\tdata[0] = { [field.name]: field.value };\n\t\tsetStepsData(data);\n\t}, [field]);\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (e.target.checked) {\n\t\t\t\t\t\t\t\tdisableStep('STEP2', 'Disabled cause');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableStep('STEP2');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (e.target.checked) {\n\t\t\t\t\t\t\t\tdisableStep('STEP3', 'Just because');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableStep('STEP3');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{fieldState.invalid && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\t {\n\t\t\t\t\t\t\tfield.onChange(e);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tvalue={field.value}\n\t\t\t\t\t/>\n\t\t\t\t\n\t\t\t\t alert('Cancel action')}\n\t\t\t\t\tonNext={() => rhf.handleSubmit(onNext)()}\n\t\t\t\t/>\n\t\t\t\n\t\t
\n\t);\n};\n\nexport const FormComponentStep2 = () => {\n\tconst { disableStep, enableStep, onNext, onPrevious } = useContext(StepperForm.Context);\n\tconst { stepsData, setStepsData } = useContext(BusinessContext);\n\n\tconst rhf = useForm<{ randomInput: string }>({\n\t\tdefaultValues: { ...stepsData[1] },\n\t});\n\n\tconst { field, fieldState } = useController({\n\t\tcontrol: rhf.control,\n\t\tname: 'randomInput',\n\t\trules: {\n\t\t\trequired: true,\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst data = stepsData;\n\t\tdata[1] = { [field.name]: field.value };\n\t\tsetStepsData(data);\n\t}, [field]);\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (e.target.checked) {\n\t\t\t\t\t\t\t\tdisableStep('STEP3', 'Disabled cause');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableStep('STEP3');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{fieldState.invalid && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t alert('Cancel action')}\n\t\t\t\t\tonNext={() => rhf.handleSubmit(onNext)()}\n\t\t\t\t\tonPrevious={onPrevious}\n\t\t\t\t/>\n\t\t\t\n\t\t
\n\t);\n};\n\nexport const FormComponentStep3 = () => {\n\tconst { onNext, onPrevious } = useContext(StepperForm.Context);\n\tconst { stepsData, setStepsData } = useContext(BusinessContext);\n\n\tconst rhf = useForm<{ randomInput: string }>({\n\t\tdefaultValues: { ...stepsData[2] },\n\t});\n\n\tconst { field, fieldState } = useController({\n\t\tcontrol: rhf.control,\n\t\tname: 'randomInput',\n\t\trules: {\n\t\t\trequired: true,\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst data = stepsData;\n\t\tdata[2] = { [field.name]: field.value };\n\t\tsetStepsData(data);\n\t}, [field]);\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t{fieldState.invalid && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t alert('Cancel action')}\n\t\t\t\t\tonNext={() => rhf.handleSubmit(onNext)()}\n\t\t\t\t\tonPrevious={onPrevious}\n\t\t\t\t/>\n\t\t\t\n\t\t
\n\t);\n};\n"],"mappings":"AAuCI,SACC,KADD;AAvCJ,SAAS,eAAe,YAAY,iBAAiB;AACrD,SAAS,cAAc,eAAe,eAAe;AAErD,SAAS,MAAM,gCAAgC;AAE/C,OAAO,iBAAiB;AAOjB,MAAM,kBAAkB,cAAc,CAAC,CAAuB;AAE9D,MAAM,qBAAqB,MAAM;AACvC,QAAM,EAAE,aAAa,YAAY,OAAO,IAAI,WAAW,YAAY,OAAO;AAC1E,QAAM,EAAE,WAAW,aAAa,IAAI,WAAW,eAAe;AAE9D,QAAM,MAAM,QAAa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/stepper/libx/translate.js b/packages/stepper/libx/translate.js new file mode 100644 index 00000000000..5e1fd4f589a --- /dev/null +++ b/packages/stepper/libx/translate.js @@ -0,0 +1,11 @@ +import i18next from 'i18next'; +import { setI18n, getI18n } from 'react-i18next'; +function getDefaultT() { + return getI18n().t.bind(getI18n()); +} +if (!getI18n()) { + console.warn('@talend/react-stepper used without i18n host.'); + setI18n(i18next.createInstance({}, () => {})); +} +export { getDefaultT as default }; +//# sourceMappingURL=translate.js.map diff --git a/packages/stepper/libx/translate.js.map b/packages/stepper/libx/translate.js.map new file mode 100644 index 00000000000..3c7ce19ab37 --- /dev/null +++ b/packages/stepper/libx/translate.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/translate.js"],"sourcesContent":["import i18next from 'i18next';\nimport { setI18n, getI18n } from 'react-i18next';\n\nexport default function getDefaultT() {\n\treturn getI18n().t.bind(getI18n());\n}\n\nif (!getI18n()) {\n\t// eslint-disable-next-line no-console\n\tconsole.warn('@talend/react-stepper used without i18n host.');\n\tsetI18n(i18next.createInstance({}, () => {}));\n}\n"],"mappings":"AAAA,OAAO,aAAa;AACpB,SAAS,SAAS,eAAe;AAElB,SAAR,cAA+B;AACrC,SAAO,QAAQ,EAAE,EAAE,KAAK,QAAQ,CAAC;AAClC;AAEA,IAAI,CAAC,QAAQ,GAAG;AAEf,UAAQ,KAAK,+CAA+C;AAC5D,UAAQ,QAAQ,eAAe,CAAC,GAAG,MAAM;AAAA,EAAC,CAAC,CAAC;AAC7C;","names":[]} \ No newline at end of file diff --git a/packages/stepper/package.json b/packages/stepper/package.json index 842ad47716f..f42f8e4f3f4 100644 --- a/packages/stepper/package.json +++ b/packages/stepper/package.json @@ -17,6 +17,7 @@ }, "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "extract-i18n": "i18next-scanner --config i18next-scanner.config.js", "test": "vitest run", @@ -52,6 +53,7 @@ "lodash": "^4.17.23" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/icons": "^8.0.0", diff --git a/packages/stepper/tsup.config.ts b/packages/stepper/tsup.config.ts new file mode 100644 index 00000000000..8b745c094f0 --- /dev/null +++ b/packages/stepper/tsup.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/storybook-cmf/package.json b/packages/storybook-cmf/package.json index 12f897a8b53..681c383bf4d 100644 --- a/packages/storybook-cmf/package.json +++ b/packages/storybook-cmf/package.json @@ -18,6 +18,7 @@ ], "scripts": { "build:lib": "talend-scripts build", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "test": "vitest run", "lint": "eslint -o eslint-report.json --format json .", @@ -34,6 +35,7 @@ } }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/eslint-config": "^14.1.2", diff --git a/packages/storybook-cmf/tsup.config.ts b/packages/storybook-cmf/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/storybook-cmf/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/packages/storybook-docs/package.json b/packages/storybook-docs/package.json index bf2e668585d..e9a375a1dac 100644 --- a/packages/storybook-docs/package.json +++ b/packages/storybook-docs/package.json @@ -8,6 +8,7 @@ "scripts": { "build:styles": "webpack --config webpack.custom.js --mode=production", "build:lib": "talend-scripts build && npm run build:styles", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "start": "npm run storybook", "lint:js": "eslint -o eslint-report.json --format json .", @@ -40,6 +41,7 @@ "react": "^18.3.1" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@figma/rest-api-spec": "^0.36.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/react-vite": "^10.2.1", diff --git a/packages/storybook-docs/tsup.config.ts b/packages/storybook-docs/tsup.config.ts new file mode 100644 index 00000000000..3e9883b8150 --- /dev/null +++ b/packages/storybook-docs/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +// storybook-docs ships CSS module files alongside the JS output. +// The separate `build:styles` script is not part of this tsup build. +export default defineConfig( + baseConfig({ + outDir: 'libx', + copyStaticAssets: true, + }), +); diff --git a/packages/utils/package.json b/packages/utils/package.json index 9c26d1f764f..19ce09c8a2c 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -23,6 +23,7 @@ "license": "Apache-2.0", "scripts": { "build:lib": "talend-scripts build --tsc", + "build:libx": "tsup && tsup-postbuild", "build:lib:esm": "talend-scripts build --esm", "lint": "eslint -o eslint-report.json --format json .", "test": "vitest run", @@ -33,6 +34,7 @@ "test:update": "vitest run --update" }, "devDependencies": { + "@talend/scripts-config-tsup": "^1.0.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/utils/tsup.config.ts b/packages/utils/tsup.config.ts new file mode 100644 index 00000000000..d6f898b7f35 --- /dev/null +++ b/packages/utils/tsup.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'tsup'; +import { baseConfig } from '@talend/scripts-config-tsup'; + +export default defineConfig( + baseConfig({ + outDir: 'libx', + }), +); diff --git a/tools/scripts-config-tsup/package.json b/tools/scripts-config-tsup/package.json new file mode 100644 index 00000000000..a1bfec221c3 --- /dev/null +++ b/tools/scripts-config-tsup/package.json @@ -0,0 +1,20 @@ +{ + "name": "@talend/scripts-config-tsup", + "version": "1.0.0", + "description": "Shared tsup configuration for Talend library packages", + "license": "Apache-2.0", + "type": "module", + "main": "./src/index.ts", + "exports": { + ".": "./src/index.ts" + }, + "bin": { + "tsup-postbuild": "./bin/postbuild.js" + }, + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "tsup": ">=8.0.0" + } +} diff --git a/tools/scripts-config-tsup/src/index.ts b/tools/scripts-config-tsup/src/index.ts new file mode 100644 index 00000000000..285d0ca76c3 --- /dev/null +++ b/tools/scripts-config-tsup/src/index.ts @@ -0,0 +1,137 @@ +import { copyFileSync, existsSync, mkdirSync, readdirSync, renameSync } from 'fs'; +import { dirname, extname, join, relative } from 'path'; +import type { Options } from 'tsup'; + +export const SOURCE_PATTERNS = ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.js', 'src/**/*.jsx']; + +export const EXCLUDE_PATTERNS = [ + '!src/**/*.test.ts', + '!src/**/*.test.tsx', + '!src/**/*.test.js', + '!src/**/*.test.jsx', + '!src/**/*.spec.ts', + '!src/**/*.spec.tsx', + '!src/**/*.spec.js', + '!src/**/*.spec.jsx', + '!src/**/*.stories.ts', + '!src/**/*.stories.tsx', + '!src/**/*.stories.js', + '!src/**/*.stories.jsx', + '!src/**/__mocks__/**', + '!src/**/__tests__/**', +]; + +const DEFAULT_COPY_EXTENSIONS = ['.css', '.scss', '.json']; + +function walkFiles(dir: string): string[] { + if (!existsSync(dir)) return []; + const results: string[] = []; + for (const entry of readdirSync(dir, { withFileTypes: true })) { + const fullPath = join(dir, entry.name); + if (entry.isDirectory()) { + results.push(...walkFiles(fullPath)); + } else { + results.push(fullPath); + } + } + return results; +} + +/** + * Copy static assets (CSS, SCSS, JSON, and any extra extensions) from srcDir to outDir, + * preserving the directory structure. Mirrors the cpx2 copy step in the legacy build. + */ +export function copyAssets(srcDir: string, outDir: string, extraExtensions: string[] = []): void { + const extensions = new Set([...DEFAULT_COPY_EXTENSIONS, ...extraExtensions]); + for (const srcPath of walkFiles(srcDir)) { + if (!extensions.has(extname(srcPath))) continue; + const destPath = join(outDir, relative(srcDir, srcPath)); + mkdirSync(dirname(destPath), { recursive: true }); + copyFileSync(srcPath, destPath); + } +} + +/** + * Rename .d.mts → .d.ts (and .d.mts.map → .d.ts.map) in the output directory. + * + * tsup v8 generates .d.mts for ESM format regardless of the outExtension setting, + * but we use .js (not .mjs) to match the legacy lib-esm/ output. Renaming keeps + * declaration files consistent with the JS output extension. + */ +export function renameDtsFiles(outDir: string): void { + for (const file of walkFiles(outDir)) { + if (file.endsWith('.d.mts')) { + renameSync(file, file.replace(/\.d\.mts$/, '.d.ts')); + } else if (file.endsWith('.d.mts.map')) { + renameSync(file, file.replace(/\.d\.mts\.map$/, '.d.ts.map')); + } + } +} + +export interface BaseConfigOptions { + /** Output directory. Defaults to 'libx' for the parallel comparison build. */ + outDir?: string; + /** + * Copy CSS/SCSS/JSON assets from src/ to outDir after build. + * Mirrors the cpx2 copy step in the legacy talend-scripts build. + */ + copyStaticAssets?: boolean; + /** + * Extra file extensions to copy alongside the defaults (.css, .scss, .json). + * Useful for design-system which ships SVG/image assets. + */ + extraAssetExtensions?: string[]; + /** Any other tsup options to merge/override. */ + [key: string]: unknown; +} + +/** + * Returns a tsup Options object with sensible defaults for Talend library packages. + * - ESM-only output (no CommonJS) + * - File-per-file transform mode (bundle: false), matching the legacy Babel pipeline + * - Source maps enabled + * - .d.ts declaration generation (tsup dts, then normalized from .d.mts → .d.ts) + * - Optional static asset copying (CSS/SCSS/JSON/images) + * + * @example + * // Simple TS package: + * export default defineConfig(baseConfig({ outDir: 'libx' })); + * + * // Package with CSS modules: + * export default defineConfig(baseConfig({ outDir: 'libx', copyStaticAssets: true })); + * + * // design-system (CSS + SVG images): + * export default defineConfig(baseConfig({ + * outDir: 'libx', + * copyStaticAssets: true, + * extraAssetExtensions: ['.svg', '.png'], + * })); + */ +export function baseConfig({ + outDir = 'libx', + copyStaticAssets = false, + extraAssetExtensions = [], + ...rest +}: BaseConfigOptions = {}): Options { + return { + entry: [...SOURCE_PATTERNS, ...EXCLUDE_PATTERNS], + format: ['esm'], + target: 'es2020', + sourcemap: true, + dts: true, + bundle: false, + clean: true, + outDir, + // Force .js extension (not .mjs) to match the existing lib-esm/ output and + // consumer package.json exports entries which reference .js files. + outExtension: () => ({ js: '.js' }), + async onSuccess() { + // tsup v8 generates .d.mts for ESM — normalize to .d.ts to match legacy output. + renameDtsFiles(outDir); + if (copyStaticAssets) { + copyAssets('src', outDir, extraAssetExtensions); + } + }, + ...(rest as Partial), + }; +} diff --git a/yarn.lock b/yarn.lock index d21bc218e0c..91532fbe91d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2393,7 +2393,7 @@ glob "^13.0.1" react-docgen-typescript "^2.2.2" -"@jridgewell/gen-mapping@^0.3.12", "@jridgewell/gen-mapping@^0.3.5": +"@jridgewell/gen-mapping@^0.3.12", "@jridgewell/gen-mapping@^0.3.2", "@jridgewell/gen-mapping@^0.3.5": version "0.3.13" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz#6342a19f44347518c93e43b1ac69deb3c4656a1f" integrity sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA== @@ -3558,6 +3558,15 @@ raf "^3.4.1" regenerator-runtime "^0.13.11" +"@talend/scripts-config-stylelint@^4.5.0": + version "4.5.1" + resolved "https://npm.pkg.github.com/download/@talend/scripts-config-stylelint/4.5.1/df7b6c06a47504b0c65fcac0508b7efd8357b70f#df7b6c06a47504b0c65fcac0508b7efd8357b70f" + integrity sha512-irjusFPw/LRsyUg6NPqiwykpxrX1fHRZ43Yrjb6SUjcPrVuPRqOMvDzEuRqwXEGlmpNbFIstxdg761zGnvo0WQ== + dependencies: + stylelint "^15.11.0" + stylelint-config-sass-guidelines "^10.0.0" + stylelint-config-standard "^34.0.0" + "@talend/scripts-core@^18.0.0": version "18.0.0" resolved "https://npm.pkg.github.com/download/@talend/scripts-core/18.0.0/1272cbee7eca7082519b4bbbb4b3c64e023f9ea1#1272cbee7eca7082519b4bbbb4b3c64e023f9ea1" @@ -5709,6 +5718,13 @@ bundle-require@^4.0.1: dependencies: load-tsconfig "^0.2.3" +bundle-require@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/bundle-require/-/bundle-require-5.1.0.tgz#8db66f41950da3d77af1ef3322f4c3e04009faee" + integrity sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA== + dependencies: + load-tsconfig "^0.2.3" + bytes@3.1.2, bytes@~3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" @@ -5719,6 +5735,11 @@ bytestreamjs@^2.0.1: resolved "https://registry.yarnpkg.com/bytestreamjs/-/bytestreamjs-2.0.1.tgz#a32947c7ce389a6fa11a09a9a563d0a45889535e" integrity sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ== +cac@^6.7.14: + version "6.7.14" + resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" + integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== + cacache@^19.0.1: version "19.0.1" resolved "https://registry.yarnpkg.com/cacache/-/cacache-19.0.1.tgz#3370cc28a758434c85c2585008bd5bdcff17d6cd" @@ -5945,7 +5966,7 @@ chokidar@^3.5.3, chokidar@^3.6.0: optionalDependencies: fsevents "~2.3.2" -chokidar@^4.0.0, chokidar@^4.0.1: +chokidar@^4.0.0, chokidar@^4.0.1, chokidar@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.3.tgz#7be37a4c03c9aee1ecfe862a4a23b2c70c205d30" integrity sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA== @@ -6179,6 +6200,11 @@ commander@^13.1.0: resolved "https://registry.yarnpkg.com/commander/-/commander-13.1.0.tgz#776167db68c78f38dcce1f9b8d7b8b9a488abf46" integrity sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw== +commander@^4.0.0, commander@~4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" + integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== + commander@^6.2.0, commander@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" @@ -6194,11 +6220,6 @@ commander@^9.0.0: resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== -commander@~4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" - integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== - common-path-prefix@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0" @@ -6259,6 +6280,11 @@ concurrently@^8.2.2: tree-kill "^1.2.2" yargs "^17.7.2" +confbox@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/confbox/-/confbox-0.1.8.tgz#820d73d3b3c82d9bd910652c5d4d599ef8ff8b06" + integrity sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w== + connect-history-api-fallback@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz#647264845251a0daf25b97ce87834cace0f5f1c8" @@ -6285,6 +6311,11 @@ connected-react-router@^6.9.3: immutable "^3.8.1 || ^4.0.0" seamless-immutable "^7.1.3" +consola@^3.4.0: + version "3.4.2" + resolved "https://registry.yarnpkg.com/consola/-/consola-3.4.2.tgz#5af110145397bb67afdab77013fdc34cae590ea7" + integrity sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA== + content-disposition@~0.5.4: version "0.5.4" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" @@ -8531,6 +8562,15 @@ find-up@^6.3.0: locate-path "^7.1.0" path-exists "^5.0.0" +fix-dts-default-cjs-exports@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fix-dts-default-cjs-exports/-/fix-dts-default-cjs-exports-1.0.1.tgz#955cb6b3d519691c57828b078adadf2cb92e9549" + integrity sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg== + dependencies: + magic-string "^0.30.17" + mlly "^1.7.4" + rollup "^4.34.8" + flat-cache@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" @@ -10631,6 +10671,11 @@ jiti@^2.5.1: resolved "https://registry.yarnpkg.com/jiti/-/jiti-2.6.1.tgz#178ef2fc9a1a594248c20627cd820187a4d78d92" integrity sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ== +joycon@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" + integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== + js-cookie@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" @@ -10925,7 +10970,7 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -lilconfig@^3.1.3: +lilconfig@^3.1.1, lilconfig@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.3.tgz#a1bcfd6257f9585bf5ae14ceeebb7b559025e4c4" integrity sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw== @@ -11159,7 +11204,7 @@ lz-string@^1.5.0: resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.5.0.tgz#c1ab50f77887b712621201ba9fd4e3a6ed099941" integrity sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ== -magic-string@^0.30.0, magic-string@^0.30.21: +magic-string@^0.30.0, magic-string@^0.30.17, magic-string@^0.30.21: version "0.30.21" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.21.tgz#56763ec09a0fa8091df27879fd94d19078c00d91" integrity sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ== @@ -11932,6 +11977,16 @@ mkdirp@^1.0.4: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +mlly@^1.7.4: + version "1.8.1" + resolved "https://registry.yarnpkg.com/mlly/-/mlly-1.8.1.tgz#2ed89f4fbbbde26db9fcc86df5bfa3153cfacea1" + integrity sha512-SnL6sNutTwRWWR/vcmCYHSADjiEesp5TGQQ0pXyLhW5IoeibRlF/CbSLailbB3CNqJUk9cVJ9dUDnbD7GrcHBQ== + dependencies: + acorn "^8.16.0" + pathe "^2.0.3" + pkg-types "^1.3.1" + ufo "^1.6.3" + mock-socket@^9.3.1: version "9.3.1" resolved "https://registry.yarnpkg.com/mock-socket/-/mock-socket-9.3.1.tgz#24fb00c2f573c84812aa4a24181bb025de80cc8e" @@ -12716,7 +12771,7 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== -pathe@^2.0.3: +pathe@^2.0.1, pathe@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/pathe/-/pathe-2.0.3.tgz#3ecbec55421685b70a9da872b2cff3e1cbed1716" integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w== @@ -12783,7 +12838,7 @@ pinkie@^2.0.0: resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" integrity sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg== -pirates@^4.0.4: +pirates@^4.0.1, pirates@^4.0.4: version "4.0.7" resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.7.tgz#643b4a18c4257c8a65104b73f3049ce9a0a15e22" integrity sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA== @@ -12802,6 +12857,15 @@ pkg-dir@^7.0.0: dependencies: find-up "^6.3.0" +pkg-types@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/pkg-types/-/pkg-types-1.3.1.tgz#bd7cc70881192777eef5326c19deb46e890917df" + integrity sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ== + dependencies: + confbox "^0.1.8" + mlly "^1.7.4" + pathe "^2.0.1" + pkijs@^3.3.3: version "3.3.3" resolved "https://registry.yarnpkg.com/pkijs/-/pkijs-3.3.3.tgz#b3f04d7b2eaacb05c81675f882be374e591626ec" @@ -12989,6 +13053,13 @@ postcss-lab-function@^4.2.1: "@csstools/postcss-progressive-custom-properties" "^1.1.0" postcss-value-parser "^4.2.0" +postcss-load-config@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-6.0.1.tgz#6fd7dcd8ae89badcf1b2d644489cbabf83aa8096" + integrity sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g== + dependencies: + lilconfig "^3.1.1" + postcss-loader@^8.2.0: version "8.2.1" resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-8.2.1.tgz#c3d9b35498af906fe6c25eb62583c06f619f92fc" @@ -13008,6 +13079,11 @@ postcss-media-minmax@^5.0.0: resolved "https://registry.yarnpkg.com/postcss-media-minmax/-/postcss-media-minmax-5.0.0.tgz#7140bddec173e2d6d657edbd8554a55794e2a5b5" integrity sha512-yDUvFf9QdFZTuCUg0g0uNSHVlJ5X1lSzDZjPSFaiCWvjgsvu8vEVxtahPrLMinIDEEGnx6cBe6iqdx5YWz08wQ== +postcss-media-query-parser@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz#27b39c6f4d94f81b1a73b8f76351c609e5cef244" + integrity sha512-3sOlxmbKcSHMjlUXQZKQ06jOswE7oVkXPxmZdoB1r5l0q6gTFTQSHxNxOrCccElbW7dxNytifNEo8qidX2Vsig== + postcss-merge-longhand@^7.0.5: version "7.0.5" resolved "https://registry.yarnpkg.com/postcss-merge-longhand/-/postcss-merge-longhand-7.0.5.tgz#e1b126e92f583815482e8b1e82c47d2435a20421" @@ -13286,6 +13362,11 @@ postcss-safe-parser@^7.0.1: resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-7.0.1.tgz#36e4f7e608111a0ca940fd9712ce034718c40ec0" integrity sha512-0AioNCJZ2DPYz5ABT6bddIqlhgwhpHZ/l65YAYo0BCIn0xiDpsnTHz0gnoTGk0OXZW0JRs+cDwL8u/teRdz+8A== +postcss-scss@^4.0.6: + version "4.0.9" + resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-4.0.9.tgz#a03c773cd4c9623cb04ce142a52afcec74806685" + integrity sha512-AjKOeiwAitL/MXxQW2DliT28EKukvvbEWx3LBmJIRN8KfBGZbRTxNYW0kSqi1COiTZ57nZ9NW06S6ux//N1c9A== + postcss-selector-not@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/postcss-selector-not/-/postcss-selector-not-6.0.1.tgz#8f0a709bf7d4b45222793fc34409be407537556d" @@ -13293,7 +13374,7 @@ postcss-selector-not@^6.0.1: dependencies: postcss-selector-parser "^6.0.10" -postcss-selector-parser@^6.0.10, postcss-selector-parser@^6.0.13, postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.9: +postcss-selector-parser@^6.0.10, postcss-selector-parser@^6.0.11, postcss-selector-parser@^6.0.13, postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.9: version "6.1.2" resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz#27ecb41fb0e3b6ba7a1ec84fff347f734c7929de" integrity sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg== @@ -14454,7 +14535,7 @@ robust-predicates@^3.0.2: resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.2.tgz#d5b28528c4824d20fc48df1928d41d9efa1ad771" integrity sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg== -rollup@^4.43.0: +rollup@^4.34.8, rollup@^4.43.0: version "4.59.0" resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.59.0.tgz#cf74edac17c1486f562d728a4d923a694abdf06f" integrity sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg== @@ -15037,6 +15118,11 @@ source-map@^0.5.0: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ== +source-map@^0.7.6: + version "0.7.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.6.tgz#a3658ab87e5b6429c8a1f3ba0083d4c61ca3ef02" + integrity sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ== + spawn-command@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2.tgz#9544e1a43ca045f8531aac1a48cb29bdae62338e" @@ -15462,11 +15548,31 @@ stylehacks@^7.0.5: browserslist "^4.28.1" postcss-selector-parser "^7.1.1" +stylelint-config-recommended@^13.0.0: + version "13.0.0" + resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-13.0.0.tgz#c48a358cc46b629ea01f22db60b351f703e00597" + integrity sha512-EH+yRj6h3GAe/fRiyaoO2F9l9Tgg50AOFhaszyfov9v6ayXJ1IkSHwTxd7lB48FmOeSGDPLjatjO11fJpmarkQ== + stylelint-config-recommended@^18.0.0: version "18.0.0" resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-18.0.0.tgz#1d86be73565c3cd5e6babb8abcc932012a86bd76" integrity sha512-mxgT2XY6YZ3HWWe3Di8umG6aBmWmHTblTgu/f10rqFXnyWxjKWwNdjSWkgkwCtxIKnqjSJzvFmPT5yabVIRxZg== +stylelint-config-sass-guidelines@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/stylelint-config-sass-guidelines/-/stylelint-config-sass-guidelines-10.0.0.tgz#ace99689eb6769534c9b40d62e2a8562b1ddc9f2" + integrity sha512-+Rr2Dd4b72CWA4qoj1Kk+y449nP/WJsrD0nzQAWkmPPIuyVcy2GMIcfNr0Z8JJOLjRvtlkKxa49FCNXMePBikQ== + dependencies: + postcss-scss "^4.0.6" + stylelint-scss "^4.4.0" + +stylelint-config-standard@^34.0.0: + version "34.0.0" + resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-34.0.0.tgz#309f3c48118a02aae262230c174282e40e766cf4" + integrity sha512-u0VSZnVyW9VSryBG2LSO+OQTjN7zF9XJaAJRX/4EwkmU0R2jYwmBSN10acqZisDitS0CLiEiGjX7+Hrq8TAhfQ== + dependencies: + stylelint-config-recommended "^13.0.0" + stylelint-config-standard@^40.0.0: version "40.0.0" resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-40.0.0.tgz#6bb72b94f8be434cdf2902ba26b2167d572c5414" @@ -15474,6 +15580,16 @@ stylelint-config-standard@^40.0.0: dependencies: stylelint-config-recommended "^18.0.0" +stylelint-scss@^4.4.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/stylelint-scss/-/stylelint-scss-4.7.0.tgz#f986bf8c5a4b93eae2b67d3a3562eef822657908" + integrity sha512-TSUgIeS0H3jqDZnby1UO1Qv3poi1N8wUYIJY6D1tuUq2MN3lwp/rITVo0wD+1SWTmRm0tNmGO0b7nKInnqF6Hg== + dependencies: + postcss-media-query-parser "^0.2.3" + postcss-resolve-nested-selector "^0.1.1" + postcss-selector-parser "^6.0.11" + postcss-value-parser "^4.2.0" + stylelint@^15.11.0: version "15.11.0" resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-15.11.0.tgz#3ff8466f5f5c47362bc7c8c9d382741c58bc3292" @@ -15575,6 +15691,19 @@ subarg@^1.0.0: dependencies: minimist "^1.1.0" +sucrase@^3.35.0: + version "3.35.1" + resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.35.1.tgz#4619ea50393fe8bd0ae5071c26abd9b2e346bfe1" + integrity sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw== + dependencies: + "@jridgewell/gen-mapping" "^0.3.2" + commander "^4.0.0" + lines-and-columns "^1.1.6" + mz "^2.7.0" + pirates "^4.0.1" + tinyglobby "^0.2.11" + ts-interface-checker "^0.1.9" + superagent@^7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/superagent/-/superagent-7.1.6.tgz#64f303ed4e4aba1e9da319f134107a54cacdc9c6" @@ -15880,12 +16009,17 @@ tinybench@^2.9.0: resolved "https://registry.yarnpkg.com/tinybench/-/tinybench-2.9.0.tgz#103c9f8ba6d7237a47ab6dd1dcff77251863426b" integrity sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg== +tinyexec@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.2.tgz#941794e657a85e496577995c6eef66f53f42b3d2" + integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA== + tinyexec@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-1.0.2.tgz#bdd2737fe2ba40bd6f918ae26642f264b99ca251" integrity sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg== -tinyglobby@^0.2.12, tinyglobby@^0.2.15: +tinyglobby@^0.2.11, tinyglobby@^0.2.12, tinyglobby@^0.2.15: version "0.2.15" resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.15.tgz#e228dd1e638cea993d2fdb4fcd2d4602a79951c2" integrity sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ== @@ -16078,6 +16212,11 @@ ts-easing@^0.2.0: resolved "https://registry.yarnpkg.com/ts-easing/-/ts-easing-0.2.0.tgz#c8a8a35025105566588d87dbda05dd7fbfa5a4ec" integrity sha512-Z86EW+fFFh/IFB1fqQ3/+7Zpf9t2ebOAxNI/V6Wo7r5gqiqtxmgTlQ1qbqQcjLKYeSHPTsEmvlJUDg/EuL0uHQ== +ts-interface-checker@^0.1.9: + version "0.1.13" + resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" + integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== + tsconfig-paths@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz#ef78e19039133446d244beac0fd6a1632e2d107c" @@ -16097,6 +16236,29 @@ tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.5.0, tslib@^2.8 resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== +tsup@^8.3.0: + version "8.5.1" + resolved "https://registry.yarnpkg.com/tsup/-/tsup-8.5.1.tgz#a9c7a875b93344bdf70600dedd78e70f88ec9a65" + integrity sha512-xtgkqwdhpKWr3tKPmCkvYmS9xnQK3m3XgxZHwSUjvfTjp7YfXe5tT3GgWi0F2N+ZSMsOeWeZFh7ZZFg5iPhing== + dependencies: + bundle-require "^5.1.0" + cac "^6.7.14" + chokidar "^4.0.3" + consola "^3.4.0" + debug "^4.4.0" + esbuild "^0.27.0" + fix-dts-default-cjs-exports "^1.0.0" + joycon "^3.1.1" + picocolors "^1.1.1" + postcss-load-config "^6.0.1" + resolve-from "^5.0.0" + rollup "^4.34.8" + source-map "^0.7.6" + sucrase "^3.35.0" + tinyexec "^0.3.2" + tinyglobby "^0.2.11" + tree-kill "^1.2.2" + tsyringe@^4.10.0: version "4.10.0" resolved "https://registry.yarnpkg.com/tsyringe/-/tsyringe-4.10.0.tgz#d0c95815d584464214060285eaaadd94aa03299c" @@ -16292,6 +16454,11 @@ typescript@^5.9.3: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== +ufo@^1.6.3: + version "1.6.3" + resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.6.3.tgz#799666e4e88c122a9659805e30b9dc071c3aed4f" + integrity sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q== + uglify-js@^3.1.4: version "3.19.3" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.19.3.tgz#82315e9bbc6f2b25888858acd1fff8441035b77f" From ccf0d8660404a4109d22bc11b7b791e499f3e1af Mon Sep 17 00:00:00 2001 From: Jean-Michel FRANCOIS Date: Wed, 11 Mar 2026 12:01:07 +0100 Subject: [PATCH 2/3] chore: drop libx --- docs/plan-tsup-migration.md | 2 +- package.json | 1 - packages/a11y/libx/Gesture/constants.js | 4 - packages/a11y/libx/Gesture/constants.js.map | 1 - packages/a11y/libx/Gesture/focus.js | 52 ----- packages/a11y/libx/Gesture/focus.js.map | 1 - packages/a11y/libx/Gesture/index.js | 16 -- packages/a11y/libx/Gesture/index.js.map | 1 - packages/a11y/libx/Gesture/preventScroll.js | 21 -- .../a11y/libx/Gesture/preventScroll.js.map | 1 - packages/a11y/libx/Gesture/propTypes.js | 1 - packages/a11y/libx/Gesture/propTypes.js.map | 1 - .../a11y/libx/Gesture/withCalendarGesture.js | 78 -------- .../libx/Gesture/withCalendarGesture.js.map | 1 - .../libx/Gesture/withDynamicListGesture.js | 86 -------- .../Gesture/withDynamicListGesture.js.map | 1 - packages/a11y/libx/Gesture/withListGesture.js | 80 -------- .../a11y/libx/Gesture/withListGesture.js.map | 1 - .../libx/Gesture/withMonthCalendarGesture.js | 65 ------ .../Gesture/withMonthCalendarGesture.js.map | 1 - packages/a11y/libx/Gesture/withTreeGesture.js | 148 -------------- .../a11y/libx/Gesture/withTreeGesture.js.map | 1 - packages/a11y/libx/index.js | 3 - packages/a11y/libx/index.js.map | 1 - packages/a11y/libx/test-setup.js | 2 - packages/a11y/libx/test-setup.js.map | 1 - packages/a11y/package.json | 1 + packages/assets-api/libx/index.d.ts | 50 ----- packages/assets-api/libx/index.js | 156 --------------- packages/assets-api/libx/index.js.map | 1 - packages/assets-api/package.json | 1 + packages/cmf-cqrs/package.json | 1 + packages/cmf-router/package.json | 1 + packages/cmf/package.json | 1 + packages/components/package.json | 1 + packages/containers/package.json | 1 + packages/dataviz/package.json | 1 + packages/design-system/package.json | 1 + packages/design-tokens/package.json | 1 + .../faceted-search-query-client/package.json | 1 + packages/faceted-search/package.json | 1 + packages/flow-designer/package.json | 1 + packages/forms/package.json | 1 + packages/http/package.json | 1 + packages/router-bridge/package.json | 1 + packages/sagas/package.json | 1 + packages/stepper/libx/Stepper.constants.js | 16 -- .../stepper/libx/Stepper.constants.js.map | 1 - .../StepFooter/StepFooter.component.js | 43 ---- .../StepFooter/StepFooter.component.js.map | 1 - .../StepperForm/StepFooter/index.js | 3 - .../StepperForm/StepFooter/index.js.map | 1 - .../StepHeader/StepHeader.component.js | 19 -- .../StepHeader/StepHeader.component.js.map | 1 - .../StepHeader/StepHeader.types.js | 1 - .../StepHeader/StepHeader.types.js.map | 1 - .../StepperForm/StepHeader/index.js | 3 - .../StepperForm/StepHeader/index.js.map | 1 - .../StepperForm/StepperForm.component.js | 51 ----- .../StepperForm/StepperForm.component.js.map | 1 - .../StepperForm/StepperForm.context.js | 29 --- .../StepperForm/StepperForm.context.js.map | 1 - .../StepperForm/StepperForm.module.css | 41 ---- .../StepperForm/StepperForm.types.js | 1 - .../StepperForm/StepperForm.types.js.map | 1 - .../StepperForm/StepperForm.utils.js | 26 --- .../StepperForm/StepperForm.utils.js.map | 1 - .../StepperFormContainer.component.js | 14 -- .../StepperFormContainer.component.js.map | 1 - .../StepperForm/StepperFormContainer/index.js | 3 - .../StepperFormContainer/index.js.map | 1 - .../libx/components/StepperForm/index.js | 10 - .../libx/components/StepperForm/index.js.map | 1 - packages/stepper/libx/components/index.js | 4 - packages/stepper/libx/components/index.js.map | 1 - packages/stepper/libx/constants/i18n.js | 6 - packages/stepper/libx/constants/i18n.js.map | 1 - .../libx/containers/Stepper.connect.js | 9 - .../libx/containers/Stepper.connect.js.map | 1 - .../useStepperForm/useStepperForm.hook.js | 105 ---------- .../useStepperForm/useStepperForm.hook.js.map | 1 - .../useStepperForm/useStepperForm.types.js | 7 - .../useStepperForm.types.js.map | 1 - packages/stepper/libx/index.js | 47 ----- packages/stepper/libx/index.js.map | 1 - .../stepper/libx/service/Stepper.actions.js | 42 ---- .../libx/service/Stepper.actions.js.map | 1 - .../stepper/libx/service/Stepper.reducer.js | 119 ----------- .../libx/service/Stepper.reducer.js.map | 1 - .../stepper/libx/service/Stepper.selectors.js | 12 -- .../libx/service/Stepper.selectors.js.map | 1 - .../stepper/libx/service/Stepper.utils.js | 3 - .../stepper/libx/service/Stepper.utils.js.map | 1 - .../libx/stories/Stepper.components.js | 186 ------------------ .../libx/stories/Stepper.components.js.map | 1 - packages/stepper/libx/translate.js | 11 -- packages/stepper/libx/translate.js.map | 1 - packages/stepper/package.json | 1 + packages/storybook-cmf/package.json | 1 + packages/storybook-docs/package.json | 1 + packages/utils/package.json | 1 + 101 files changed, 22 insertions(+), 1613 deletions(-) delete mode 100644 packages/a11y/libx/Gesture/constants.js delete mode 100644 packages/a11y/libx/Gesture/constants.js.map delete mode 100644 packages/a11y/libx/Gesture/focus.js delete mode 100644 packages/a11y/libx/Gesture/focus.js.map delete mode 100644 packages/a11y/libx/Gesture/index.js delete mode 100644 packages/a11y/libx/Gesture/index.js.map delete mode 100644 packages/a11y/libx/Gesture/preventScroll.js delete mode 100644 packages/a11y/libx/Gesture/preventScroll.js.map delete mode 100644 packages/a11y/libx/Gesture/propTypes.js delete mode 100644 packages/a11y/libx/Gesture/propTypes.js.map delete mode 100644 packages/a11y/libx/Gesture/withCalendarGesture.js delete mode 100644 packages/a11y/libx/Gesture/withCalendarGesture.js.map delete mode 100644 packages/a11y/libx/Gesture/withDynamicListGesture.js delete mode 100644 packages/a11y/libx/Gesture/withDynamicListGesture.js.map delete mode 100644 packages/a11y/libx/Gesture/withListGesture.js delete mode 100644 packages/a11y/libx/Gesture/withListGesture.js.map delete mode 100644 packages/a11y/libx/Gesture/withMonthCalendarGesture.js delete mode 100644 packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map delete mode 100644 packages/a11y/libx/Gesture/withTreeGesture.js delete mode 100644 packages/a11y/libx/Gesture/withTreeGesture.js.map delete mode 100644 packages/a11y/libx/index.js delete mode 100644 packages/a11y/libx/index.js.map delete mode 100644 packages/a11y/libx/test-setup.js delete mode 100644 packages/a11y/libx/test-setup.js.map delete mode 100644 packages/assets-api/libx/index.d.ts delete mode 100644 packages/assets-api/libx/index.js delete mode 100644 packages/assets-api/libx/index.js.map delete mode 100644 packages/stepper/libx/Stepper.constants.js delete mode 100644 packages/stepper/libx/Stepper.constants.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/index.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepFooter/index.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/index.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepHeader/index.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.component.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.component.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.context.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.context.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.module.css delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.types.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.types.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.utils.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js delete mode 100644 packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map delete mode 100644 packages/stepper/libx/components/StepperForm/index.js delete mode 100644 packages/stepper/libx/components/StepperForm/index.js.map delete mode 100644 packages/stepper/libx/components/index.js delete mode 100644 packages/stepper/libx/components/index.js.map delete mode 100644 packages/stepper/libx/constants/i18n.js delete mode 100644 packages/stepper/libx/constants/i18n.js.map delete mode 100644 packages/stepper/libx/containers/Stepper.connect.js delete mode 100644 packages/stepper/libx/containers/Stepper.connect.js.map delete mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js delete mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map delete mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js delete mode 100644 packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map delete mode 100644 packages/stepper/libx/index.js delete mode 100644 packages/stepper/libx/index.js.map delete mode 100644 packages/stepper/libx/service/Stepper.actions.js delete mode 100644 packages/stepper/libx/service/Stepper.actions.js.map delete mode 100644 packages/stepper/libx/service/Stepper.reducer.js delete mode 100644 packages/stepper/libx/service/Stepper.reducer.js.map delete mode 100644 packages/stepper/libx/service/Stepper.selectors.js delete mode 100644 packages/stepper/libx/service/Stepper.selectors.js.map delete mode 100644 packages/stepper/libx/service/Stepper.utils.js delete mode 100644 packages/stepper/libx/service/Stepper.utils.js.map delete mode 100644 packages/stepper/libx/stories/Stepper.components.js delete mode 100644 packages/stepper/libx/stories/Stepper.components.js.map delete mode 100644 packages/stepper/libx/translate.js delete mode 100644 packages/stepper/libx/translate.js.map diff --git a/docs/plan-tsup-migration.md b/docs/plan-tsup-migration.md index a9cff9d3ab5..a03f4b82a98 100644 --- a/docs/plan-tsup-migration.md +++ b/docs/plan-tsup-migration.md @@ -29,7 +29,7 @@ with the current `lib-esm/` before cutting over. ### Phase 0 — Setup ✅ DONE -- [x] Add `tsup` to root `devDependencies` +- [x] Add `tsup` as `devDependency` to each consumer package (not the root — pnpm-compatible explicit deps) - [x] Create `tools/scripts-config-tsup/` workspace package - [x] Exports `baseConfig()` helper — common tsup options - [x] Exports `copyAssets()` helper — replaces `cpx2` copy step diff --git a/package.json b/package.json index a908dd68782..ee01a897cc8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "@changesets/cli": "^2.29.8", "@talend/eslint-config": "^14.0.0", "@talend/scripts-config-babel": "^13.8.0", - "tsup": "^8.3.0", "@talend/scripts-config-prettier": "^12.5.0", "@talend/scripts-core": "^18.0.0", "@talend/scripts-yarn-workspace": "^2.3.0", diff --git a/packages/a11y/libx/Gesture/constants.js b/packages/a11y/libx/Gesture/constants.js deleted file mode 100644 index 5e03d15ab47..00000000000 --- a/packages/a11y/libx/Gesture/constants.js +++ /dev/null @@ -1,4 +0,0 @@ -const FIRST = 0; -const LAST = Number.POSITIVE_INFINITY; -export { FIRST, LAST }; -//# sourceMappingURL=constants.js.map diff --git a/packages/a11y/libx/Gesture/constants.js.map b/packages/a11y/libx/Gesture/constants.js.map deleted file mode 100644 index 02184b023bb..00000000000 --- a/packages/a11y/libx/Gesture/constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/constants.ts"],"sourcesContent":["export const FIRST = 0;\nexport const LAST = Number.POSITIVE_INFINITY;\n"],"mappings":"AAAO,MAAM,QAAQ;AACd,MAAM,OAAO,OAAO;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/focus.js b/packages/a11y/libx/Gesture/focus.js deleted file mode 100644 index 213a7eb36e3..00000000000 --- a/packages/a11y/libx/Gesture/focus.js +++ /dev/null @@ -1,52 +0,0 @@ -import { FIRST, LAST } from './constants'; -function focusOn(element) { - if (element) { - element.focus(); - } -} -function getAllItems(calendarRef) { - return calendarRef.querySelectorAll('td > button[data-value]'); -} -function getDay(calendarRef, offset) { - const allItems = getAllItems(calendarRef); - const index = offset >= 0 ? offset : allItems.length + offset; - return allItems[index]; -} -function focusWithinCurrentCalendar(calendarRef, indexToFocus = 0) { - const allItems = getAllItems(calendarRef); - if (indexToFocus === FIRST || indexToFocus < 0) { - focusOn(allItems[0]); - } else if (indexToFocus === LAST || indexToFocus > allItems.length - 1) { - focusOn(allItems[allItems.length - 1]); - } else { - focusOn(allItems[indexToFocus]); - } -} -function focusOnDay(calendarRef, indexToFocus, props) { - const allItems = getAllItems(calendarRef); - if (indexToFocus < 0) { - props.goToPreviousMonth(() => { - focusOn(getDay(calendarRef, indexToFocus)); - }); - } else if (indexToFocus > allItems.length - 1) { - props.goToNextMonth(() => { - focusOn(getDay(calendarRef, indexToFocus - allItems.length)); - }); - } else { - focusOn(allItems[indexToFocus]); - } -} -function focusOnCalendar(containerRef) { - let target = containerRef.querySelector('td[aria-current="date"] > button'); - if (!target) { - target = containerRef.querySelector('td > button[disabled=false]'); - } - if (!target) { - target = containerRef.querySelector('td > button[data-value]'); - } - if (target) { - target.focus(); - } -} -export { focusOn, focusOnCalendar, focusOnDay, focusWithinCurrentCalendar }; -//# sourceMappingURL=focus.js.map diff --git a/packages/a11y/libx/Gesture/focus.js.map b/packages/a11y/libx/Gesture/focus.js.map deleted file mode 100644 index 86d9838e830..00000000000 --- a/packages/a11y/libx/Gesture/focus.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/focus.ts"],"sourcesContent":["import { FIRST, LAST } from './constants';\nimport { CalendarGestureProps } from './propTypes';\n\nexport interface WithFocus {\n\tfocus: HTMLElement['focus'];\n}\n\nexport function focusOn(element?: WithFocus | null) {\n\tif (element) {\n\t\telement.focus();\n\t}\n}\n\n/**\n * Select all items in current calendar\n */\nfunction getAllItems(calendarRef: HTMLElement) {\n\treturn calendarRef.querySelectorAll('td > button[data-value]');\n}\n\n/**\n * Get the day corresponding to the offset.\n * - positive offset : we count from the beginning of the month. Ex : days 1-31 + offset 5 = day 5\n * - negative offset < 0 : we count from the end of the month. \t Ex : days 1-31 + offset -2 = day 29\n */\nfunction getDay(calendarRef: HTMLElement, offset: number): HTMLElement {\n\tconst allItems = getAllItems(calendarRef);\n\tconst index = offset >= 0 ? offset : allItems.length + offset;\n\treturn allItems[index];\n}\n\n/**\n * Focus on the item within the current calendar.\n * If the day index is out of the calendar's limits, it focuses on the limits.\n */\nexport function focusWithinCurrentCalendar(calendarRef: HTMLElement, indexToFocus = 0) {\n\tconst allItems = getAllItems(calendarRef);\n\tif (indexToFocus === FIRST || indexToFocus < 0) {\n\t\tfocusOn(allItems[0]);\n\t} else if (indexToFocus === LAST || indexToFocus > allItems.length - 1) {\n\t\tfocusOn(allItems[allItems.length - 1]);\n\t} else {\n\t\tfocusOn(allItems[indexToFocus]);\n\t}\n}\n\n/**\n * Focus on the day, managing the switch to previous/next month\n */\nexport function focusOnDay(\n\tcalendarRef: HTMLElement,\n\tindexToFocus: number,\n\tprops: CalendarGestureProps,\n) {\n\tconst allItems = getAllItems(calendarRef);\n\n\tif (indexToFocus < 0) {\n\t\tprops.goToPreviousMonth(() => {\n\t\t\tfocusOn(getDay(calendarRef, indexToFocus));\n\t\t});\n\t} else if (indexToFocus > allItems.length - 1) {\n\t\tprops.goToNextMonth(() => {\n\t\t\tfocusOn(getDay(calendarRef, indexToFocus - allItems.length));\n\t\t});\n\t} else {\n\t\tfocusOn(allItems[indexToFocus] as HTMLElement);\n\t}\n}\n\n/**\n * Focus management on calendar.\n * - try to focus on the selected item\n * - try to focus on the 1st not disabled item\n * - try to focus on the 1st item\n */\nexport function focusOnCalendar(containerRef: HTMLElement) {\n\tlet target = containerRef.querySelector('td[aria-current=\"date\"] > button');\n\tif (!target) {\n\t\ttarget = containerRef.querySelector('td > button[disabled=false]');\n\t}\n\tif (!target) {\n\t\ttarget = containerRef.querySelector('td > button[data-value]');\n\t}\n\tif (target) {\n\t\ttarget.focus();\n\t}\n}\n"],"mappings":"AAAA,SAAS,OAAO,YAAY;AAOrB,SAAS,QAAQ,SAA4B;AACnD,MAAI,SAAS;AACZ,YAAQ,MAAM;AAAA,EACf;AACD;AAKA,SAAS,YAAY,aAA0B;AAC9C,SAAO,YAAY,iBAAoC,yBAAyB;AACjF;AAOA,SAAS,OAAO,aAA0B,QAA6B;AACtE,QAAM,WAAW,YAAY,WAAW;AACxC,QAAM,QAAQ,UAAU,IAAI,SAAS,SAAS,SAAS;AACvD,SAAO,SAAS,KAAK;AACtB;AAMO,SAAS,2BAA2B,aAA0B,eAAe,GAAG;AACtF,QAAM,WAAW,YAAY,WAAW;AACxC,MAAI,iBAAiB,SAAS,eAAe,GAAG;AAC/C,YAAQ,SAAS,CAAC,CAAC;AAAA,EACpB,WAAW,iBAAiB,QAAQ,eAAe,SAAS,SAAS,GAAG;AACvE,YAAQ,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,EACtC,OAAO;AACN,YAAQ,SAAS,YAAY,CAAC;AAAA,EAC/B;AACD;AAKO,SAAS,WACf,aACA,cACA,OACC;AACD,QAAM,WAAW,YAAY,WAAW;AAExC,MAAI,eAAe,GAAG;AACrB,UAAM,kBAAkB,MAAM;AAC7B,cAAQ,OAAO,aAAa,YAAY,CAAC;AAAA,IAC1C,CAAC;AAAA,EACF,WAAW,eAAe,SAAS,SAAS,GAAG;AAC9C,UAAM,cAAc,MAAM;AACzB,cAAQ,OAAO,aAAa,eAAe,SAAS,MAAM,CAAC;AAAA,IAC5D,CAAC;AAAA,EACF,OAAO;AACN,YAAQ,SAAS,YAAY,CAAgB;AAAA,EAC9C;AACD;AAQO,SAAS,gBAAgB,cAA2B;AAC1D,MAAI,SAAS,aAAa,cAA2B,kCAAkC;AACvF,MAAI,CAAC,QAAQ;AACZ,aAAS,aAAa,cAA2B,6BAA6B;AAAA,EAC/E;AACA,MAAI,CAAC,QAAQ;AACZ,aAAS,aAAa,cAA2B,yBAAyB;AAAA,EAC3E;AACA,MAAI,QAAQ;AACX,WAAO,MAAM;AAAA,EACd;AACD;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/index.js b/packages/a11y/libx/Gesture/index.js deleted file mode 100644 index b749e53e12b..00000000000 --- a/packages/a11y/libx/Gesture/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import { withListGesture } from './withListGesture'; -import { withTreeGesture } from './withTreeGesture'; -import { WithDynamicListGesture } from './withDynamicListGesture'; -import { withCalendarGesture } from './withCalendarGesture'; -import { withMonthCalendarGesture } from './withMonthCalendarGesture'; -import * as focus from './focus'; -const Gesture = { - withMonthCalendarGesture, - withListGesture, - withTreeGesture, - WithDynamicListGesture, - withCalendarGesture, -}; -var Gesture_default = Gesture; -export { Gesture_default as default, focus }; -//# sourceMappingURL=index.js.map diff --git a/packages/a11y/libx/Gesture/index.js.map b/packages/a11y/libx/Gesture/index.js.map deleted file mode 100644 index 351e2331e89..00000000000 --- a/packages/a11y/libx/Gesture/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/index.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport { withListGesture } from './withListGesture';\nimport { withTreeGesture } from './withTreeGesture';\nimport { WithDynamicListGesture } from './withDynamicListGesture';\nimport { withCalendarGesture } from './withCalendarGesture';\nimport { withMonthCalendarGesture } from './withMonthCalendarGesture';\nimport * as focus from './focus';\n\nconst Gesture = {\n\twithMonthCalendarGesture,\n\twithListGesture,\n\twithTreeGesture,\n\tWithDynamicListGesture,\n\twithCalendarGesture,\n};\n\nexport { focus };\nexport default Gesture;\n"],"mappings":"AACA,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,gCAAgC;AACzC,YAAY,WAAW;AAEvB,MAAM,UAAU;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAGA,IAAO,kBAAQ;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/preventScroll.js b/packages/a11y/libx/Gesture/preventScroll.js deleted file mode 100644 index 2823e19836f..00000000000 --- a/packages/a11y/libx/Gesture/preventScroll.js +++ /dev/null @@ -1,21 +0,0 @@ -function preventScroll(evt) { - const arrows = [ - 'ArrowLeft', - 'ArrowRight', - 'ArrowUp', - 'ArrowDown', - 'Home', - 'PageUp', - 'PageDown', - // Arrow key management for old browsers - 'Left', - 'Right', - 'Up', - 'Down', - ]; - if (arrows.includes(evt.key)) { - evt.preventDefault(); - } -} -export { preventScroll }; -//# sourceMappingURL=preventScroll.js.map diff --git a/packages/a11y/libx/Gesture/preventScroll.js.map b/packages/a11y/libx/Gesture/preventScroll.js.map deleted file mode 100644 index 6e80f7afc04..00000000000 --- a/packages/a11y/libx/Gesture/preventScroll.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/preventScroll.ts"],"sourcesContent":["import { KeyboardEvent } from 'react';\n\nexport function preventScroll(evt: KeyboardEvent) {\n\tconst arrows = [\n\t\t'ArrowLeft',\n\t\t'ArrowRight',\n\t\t'ArrowUp',\n\t\t'ArrowDown',\n\t\t'Home',\n\t\t'PageUp',\n\t\t'PageDown',\n\t\t// Arrow key management for old browsers\n\t\t'Left',\n\t\t'Right',\n\t\t'Up',\n\t\t'Down',\n\t];\n\tif (arrows.includes(evt.key)) {\n\t\tevt.preventDefault();\n\t}\n}\n"],"mappings":"AAEO,SAAS,cAAc,KAAiC;AAC9D,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,MAAI,OAAO,SAAS,IAAI,GAAG,GAAG;AAC7B,QAAI,eAAe;AAAA,EACpB;AACD;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/propTypes.js b/packages/a11y/libx/Gesture/propTypes.js deleted file mode 100644 index edcb19df5b4..00000000000 --- a/packages/a11y/libx/Gesture/propTypes.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=propTypes.js.map diff --git a/packages/a11y/libx/Gesture/propTypes.js.map b/packages/a11y/libx/Gesture/propTypes.js.map deleted file mode 100644 index 84c51b288c4..00000000000 --- a/packages/a11y/libx/Gesture/propTypes.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withCalendarGesture.js b/packages/a11y/libx/Gesture/withCalendarGesture.js deleted file mode 100644 index 0c8ff8148a1..00000000000 --- a/packages/a11y/libx/Gesture/withCalendarGesture.js +++ /dev/null @@ -1,78 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import { Component, createRef } from 'react'; -import { FIRST, LAST } from './constants'; -import { focusOnDay, focusWithinCurrentCalendar } from './focus'; -import { preventScroll } from './preventScroll'; -function switchMonth(calendarRef, indexToFocus, monthSwitcher) { - monthSwitcher(() => { - focusWithinCurrentCalendar(calendarRef, indexToFocus); - }); -} -function withCalendarGesture(WrappedComponent) { - var _a; - return ( - (_a = class extends Component { - constructor(props) { - super(props); - this.ref = createRef(); - this.onKeyDown = this.onKeyDown.bind(this); - } - onKeyDown(event, calendarRef, dayIndex) { - switch (event.key) { - case 'Left': - case 'ArrowLeft': - event.stopPropagation(); - focusOnDay(calendarRef, dayIndex - 1, this.props); - break; - case 'Right': - case 'ArrowRight': - event.stopPropagation(); - focusOnDay(calendarRef, dayIndex + 1, this.props); - break; - case 'Up': - case 'ArrowUp': - event.stopPropagation(); - focusOnDay(calendarRef, dayIndex - 7, this.props); - break; - case 'Down': - case 'ArrowDown': - event.stopPropagation(); - focusOnDay(calendarRef, dayIndex + 7, this.props); - break; - case 'Home': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, FIRST); - break; - case 'End': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, LAST); - break; - case 'PageUp': - event.stopPropagation(); - switchMonth(calendarRef, dayIndex, this.props.goToPreviousMonth); - break; - case 'PageDown': - event.stopPropagation(); - switchMonth(calendarRef, dayIndex, this.props.goToNextMonth); - break; - default: - break; - } - } - render() { - return /* @__PURE__ */ jsx('div', { - ref: this.ref, - onKeyDown: preventScroll, - children: /* @__PURE__ */ jsx(WrappedComponent, { - ...this.props, - onKeyDown: this.onKeyDown, - }), - }); - } - }), - (_a.displayName = `CalendarGesture(${WrappedComponent.displayName})`), - _a - ); -} -export { withCalendarGesture }; -//# sourceMappingURL=withCalendarGesture.js.map diff --git a/packages/a11y/libx/Gesture/withCalendarGesture.js.map b/packages/a11y/libx/Gesture/withCalendarGesture.js.map deleted file mode 100644 index 21af31d6be2..00000000000 --- a/packages/a11y/libx/Gesture/withCalendarGesture.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/withCalendarGesture.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n\n/* eslint-disable react/no-multi-comp,class-methods-use-this */\nimport { Component, ComponentType, createRef, KeyboardEvent } from 'react';\n\nimport { FIRST, LAST } from './constants';\nimport { focusOnDay, focusWithinCurrentCalendar } from './focus';\nimport { preventScroll } from './preventScroll';\nimport { WithCalendarGestureInjectedProps } from './propTypes';\n\n/**\n * Switch month and focus on the same focused day or the month's limits if it's out of the limits\n */\nfunction switchMonth(\n\tcalendarRef: HTMLElement,\n\tindexToFocus: number,\n\tmonthSwitcher: (cb?: () => void) => void,\n) {\n\tmonthSwitcher(() => {\n\t\tfocusWithinCurrentCalendar(calendarRef, indexToFocus);\n\t});\n}\n\n// T is the type of data\n// P is the props of the wrapped component that is inferred\n// C is the actual interface of the wrapped component (used to grab defaultProps from it)\n\nexport function withCalendarGesture

(\n\tWrappedComponent: ComponentType

,\n) {\n\t// the magic is here: JSX.LibraryManagedAttributes will take the type of WrapedComponent and resolve its default props\n\t// against the props of WithData, which is just the original P type with 'data' removed from its requirements\n\ttype Props = Omit;\n\n\treturn class CalendarGesture extends Component {\n\t\tstatic displayName = `CalendarGesture(${WrappedComponent.displayName})`;\n\n\t\tref = createRef();\n\n\t\tconstructor(props: Props) {\n\t\t\tsuper(props);\n\t\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t\t}\n\n\t\tonKeyDown(event: KeyboardEvent, calendarRef: HTMLElement, dayIndex: number) {\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'Left':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex - 1, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Right':\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex + 1, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Up':\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex - 7, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Down':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOnDay(calendarRef, dayIndex + 7, this.props);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, FIRST);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, LAST);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'PageUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tswitchMonth(calendarRef, dayIndex, this.props.goToPreviousMonth);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'PageDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tswitchMonth(calendarRef, dayIndex, this.props.goToNextMonth);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\treturn (\n\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t);\n\t\t}\n\t};\n}\n"],"mappings":"AA4FK;AAvFL,SAAS,WAA0B,iBAAgC;AAEnE,SAAS,OAAO,YAAY;AAC5B,SAAS,YAAY,kCAAkC;AACvD,SAAS,qBAAqB;AAM9B,SAAS,YACR,aACA,cACA,eACC;AACD,gBAAc,MAAM;AACnB,+BAA2B,aAAa,YAAY;AAAA,EACrD,CAAC;AACF;AAMO,SAAS,oBACf,kBACC;AA/BF;AAoCC,SAAO,mBAA8B,UAAiB;AAAA,IAKrD,YAAY,OAAc;AACzB,YAAM,KAAK;AAHZ,iBAAM,UAA0B;AAI/B,WAAK,YAAY,KAAK,UAAU,KAAK,IAAI;AAAA,IAC1C;AAAA,IAEA,UAAU,OAAwC,aAA0B,UAAkB;AAC7F,cAAQ,MAAM,KAAK;AAAA,QAClB,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qBAAW,aAAa,WAAW,GAAG,KAAK,KAAK;AAChD;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,KAAK;AAC7C;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,IAAI;AAC5C;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,sBAAY,aAAa,UAAU,KAAK,MAAM,iBAAiB;AAC/D;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,sBAAY,aAAa,UAAU,KAAK,MAAM,aAAa;AAC3D;AAAA,QACD;AACC;AAAA,MACF;AAAA,IACD;AAAA,IAEA,SAAS;AACR,aACC,oBAAC,SAAI,KAAK,KAAK,KAAK,WAAW,eAC9B,8BAAC,oBAAkB,GAAI,KAAK,OAAe,WAAW,KAAK,WAAW,GACvE;AAAA,IAEF;AAAA,EACD,GA5DO,GACC,cAAc,mBAAmB,iBAAiB,WAAW,KAD9D;AA6DR;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withDynamicListGesture.js b/packages/a11y/libx/Gesture/withDynamicListGesture.js deleted file mode 100644 index b0ade17018f..00000000000 --- a/packages/a11y/libx/Gesture/withDynamicListGesture.js +++ /dev/null @@ -1,86 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import { Component, createRef } from 'react'; -import { focusOn } from './focus'; -function getAllItems(ref) { - return ref.querySelectorAll('li > button'); -} -function focusOnListItem(ref, index) { - const listItem = getAllItems(ref)[index]; - focusOn(listItem); -} -function focusOnPreviousItem(ref, { index, size }, goToPreviousPage) { - const nextIndex = index - 1; - if (nextIndex < 0 && size) { - goToPreviousPage(() => { - focusOnListItem(ref, size - 1); - }); - } - focusOnListItem(ref, nextIndex); -} -function focusOnNextItem(ref, { index, size }, goToNextPage) { - const nextIndex = index + 1; - if (size && nextIndex >= size) { - goToNextPage(() => { - focusOnListItem(ref, 0); - }); - } - focusOnListItem(ref, nextIndex); -} -function focusOnNextPage(ref, { index }, goToNextPage) { - goToNextPage(() => focusOnListItem(ref, index)); -} -function focusOnPreviousPage(ref, { index }, goToPreviousPage) { - goToPreviousPage(() => focusOnListItem(ref, index)); -} -class WithDynamicListGesture extends Component { - constructor(props) { - super(props); - this.myRef = createRef(); - this.onKeyDown = this.onKeyDown.bind(this); - } - onKeyDown(event, options) { - switch (event.key) { - case 'Up': - case 'ArrowUp': - event.preventDefault(); - event.stopPropagation(); - if (this.myRef?.current) { - focusOnPreviousItem(this.myRef.current, options, this.props.goToPreviousPage); - } - break; - case 'Down': - case 'ArrowDown': - event.preventDefault(); - event.stopPropagation(); - if (this.myRef?.current) { - focusOnNextItem(this.myRef.current, options, this.props.goToNextPage); - } - break; - case 'PageUp': - event.preventDefault(); - event.stopPropagation(); - if (this.myRef?.current) { - focusOnNextPage(this.myRef.current, options, this.props.goToPreviousPage); - } - break; - case 'PageDown': - event.preventDefault(); - event.stopPropagation(); - if (this.myRef?.current) { - focusOnPreviousPage(this.myRef.current, options, this.props.goToNextPage); - } - break; - default: - break; - } - } - render() { - return /* @__PURE__ */ jsx('div', { - ref: this.myRef, - className: this.props.className, - children: this.props.children(this.onKeyDown), - }); - } -} -export { WithDynamicListGesture }; -//# sourceMappingURL=withDynamicListGesture.js.map diff --git a/packages/a11y/libx/Gesture/withDynamicListGesture.js.map b/packages/a11y/libx/Gesture/withDynamicListGesture.js.map deleted file mode 100644 index 6b722c28ba6..00000000000 --- a/packages/a11y/libx/Gesture/withDynamicListGesture.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/withDynamicListGesture.tsx"],"sourcesContent":["import { Component, createRef } from 'react';\n\nimport { focusOn, WithFocus } from './focus';\n\nfunction getAllItems(ref: HTMLElement): NodeListOf {\n\treturn ref.querySelectorAll('li > button');\n}\n\nfunction focusOnListItem(ref: HTMLElement, index: number) {\n\tconst listItem = getAllItems(ref)[index] as WithFocus;\n\tfocusOn(listItem);\n}\n\nexport type FocusOnOption = {\n\tindex: number;\n\tsize?: number;\n};\n\nfunction focusOnPreviousItem(\n\tref: HTMLElement,\n\t{ index, size }: FocusOnOption,\n\tgoToPreviousPage: (fn?: () => void) => void,\n) {\n\tconst nextIndex = index - 1;\n\tif (nextIndex < 0 && size) {\n\t\tgoToPreviousPage(() => {\n\t\t\tfocusOnListItem(ref, size - 1);\n\t\t});\n\t}\n\tfocusOnListItem(ref, nextIndex);\n}\n\nfunction focusOnNextItem(\n\tref: HTMLElement,\n\t{ index, size }: FocusOnOption,\n\tgoToNextPage: (fn?: () => void) => void,\n) {\n\tconst nextIndex = index + 1;\n\tif (size && nextIndex >= size) {\n\t\tgoToNextPage(() => {\n\t\t\tfocusOnListItem(ref, 0);\n\t\t});\n\t}\n\tfocusOnListItem(ref, nextIndex);\n}\n\nfunction focusOnNextPage(\n\tref: HTMLElement,\n\t{ index }: FocusOnOption,\n\tgoToNextPage: (fn?: () => void) => void,\n) {\n\tgoToNextPage(() => focusOnListItem(ref, index));\n}\n\nfunction focusOnPreviousPage(\n\tref: HTMLElement,\n\t{ index }: FocusOnOption,\n\tgoToPreviousPage: (fn?: () => void) => void,\n) {\n\tgoToPreviousPage(() => focusOnListItem(ref, index));\n}\n\nexport interface WithDynamicListGestureProps {\n\tclassName: string;\n\tgoToPreviousPage: () => void;\n\tgoToNextPage: () => void;\n\tchildren: (fn: (event: KeyboardEvent, options: FocusOnOption) => void) => JSX.Element;\n}\n\nexport class WithDynamicListGesture extends Component {\n\tmyRef = createRef();\n\n\tconstructor(props: WithDynamicListGestureProps) {\n\t\tsuper(props);\n\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t}\n\n\tonKeyDown(event: KeyboardEvent, options: FocusOnOption) {\n\t\tswitch (event.key) {\n\t\t\tcase 'Up':\n\t\t\tcase 'ArrowUp':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnPreviousItem(this.myRef.current, options, this.props.goToPreviousPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'Down':\n\t\t\tcase 'ArrowDown':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnNextItem(this.myRef.current, options, this.props.goToNextPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'PageUp':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnNextPage(this.myRef.current, options, this.props.goToPreviousPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'PageDown':\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (this.myRef?.current) {\n\t\t\t\t\tfocusOnPreviousPage(this.myRef.current, options, this.props.goToNextPage);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t
\n\t\t\t\t{this.props.children(this.onKeyDown)}\n\t\t\t
\n\t\t);\n\t}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gBAAgB;AAAA,QAC7E;AACA;AAAA,MACD,KAAK;AAAA,MACL,KAAK;AACJ,cAAM,eAAe;AACrB,cAAM,gBAAgB;AACtB,YAAI,KAAK,OAAO,SAAS;AACxB,0BAAgB,KAAK,MAAM,SAAS,SAAS,KAAK,MAAM,YAAY;AAAA,QACrE;AACA;AAAA,MACD,KAAK;AACJ,cAAM,eAAe;AACrB,cAAM,gBAAgB;AACtB,YAAI,KAAK,OAAO,SAAS;AACxB,0BAAgB,KAAK,MAAM,SAAS,SAAS,KAAK,MAAM,gBAAgB;AAAA,QACzE;AACA;AAAA,MACD,KAAK;AACJ,cAAM,eAAe;AACrB,cAAM,gBAAgB;AACtB,YAAI,KAAK,OAAO,SAAS;AACxB,8BAAoB,KAAK,MAAM,SAAS,SAAS,KAAK,MAAM,YAAY;AAAA,QACzE;AACA;AAAA,MAED;AACC;AAAA,IACF;AAAA,EACD;AAAA,EAEA,SAAS;AACR,WACC,oBAAC,SAAI,KAAK,KAAK,OAAO,WAAW,KAAK,MAAM,WAC1C,eAAK,MAAM,SAAS,KAAK,SAAS,GACpC;AAAA,EAEF;AACD;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withListGesture.js b/packages/a11y/libx/Gesture/withListGesture.js deleted file mode 100644 index a5fcf8e2039..00000000000 --- a/packages/a11y/libx/Gesture/withListGesture.js +++ /dev/null @@ -1,80 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import { focusOn } from './focus'; -function getAllItems(ref) { - const closest = ref.closest('[role="list"]'); - if (!closest) { - return new NodeList(); - } - return closest.querySelectorAll('[role="listitem"]'); -} -function getNextItem(ref, loop) { - let nextElement; - let currentFound; - let hasNext; - const nodes = getAllItems(ref); - const iterator = nodes.values(); - if (loop && ref === nodes.item(nodes.length - 1)) { - return nodes.item(0); - } - do { - const { value, done } = iterator.next(); - if (currentFound) { - nextElement = value; - hasNext = false; - } else { - currentFound = value === ref; - hasNext = !done; - } - } while (hasNext); - return nextElement; -} -function getPreviousItem(ref, loop) { - let previousElement; - let hasNext; - const nodes = getAllItems(ref); - const iterator = nodes.values(); - if (loop && ref === nodes.item(0)) { - return nodes.item(nodes.length - 1); - } - do { - const { value, done } = iterator.next(); - const currentFound = value === ref; - if (currentFound) { - hasNext = false; - } else { - previousElement = value; - hasNext = !done; - } - } while (hasNext); - return previousElement; -} -function onKeyDown(event, ref, loop) { - switch (event.key) { - case 'Down': - case 'ArrowDown': - event.stopPropagation(); - event.preventDefault(); - focusOn(getNextItem(ref, loop)); - break; - case 'Up': - case 'ArrowUp': - event.stopPropagation(); - event.preventDefault(); - focusOn(getPreviousItem(ref, loop)); - break; - default: - break; - } -} -function withListGesture(WrappedComponent, loop = false) { - function ListGesture(props) { - return /* @__PURE__ */ jsx(WrappedComponent, { - ...props, - onKeyDown: (event, ref) => onKeyDown(event, ref, loop), - }); - } - ListGesture.displayName = `ListGesture(${WrappedComponent.displayName})`; - return ListGesture; -} -export { withListGesture }; -//# sourceMappingURL=withListGesture.js.map diff --git a/packages/a11y/libx/Gesture/withListGesture.js.map b/packages/a11y/libx/Gesture/withListGesture.js.map deleted file mode 100644 index a9aa1b72de7..00000000000 --- a/packages/a11y/libx/Gesture/withListGesture.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/withListGesture.tsx"],"sourcesContent":["import { focusOn } from './focus';\n\nfunction getAllItems(ref: HTMLElement): NodeList {\n\tconst closest = ref.closest('[role=\"list\"]');\n\tif (!closest) {\n\t\treturn new NodeList();\n\t}\n\treturn closest.querySelectorAll('[role=\"listitem\"]');\n}\n\nfunction getNextItem(ref: HTMLElement, loop: boolean) {\n\tlet nextElement;\n\tlet currentFound;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref);\n\tconst iterator = nodes.values();\n\n\tif (loop && ref === nodes.item(nodes.length - 1)) {\n\t\treturn nodes.item(0);\n\t}\n\n\tdo {\n\t\tconst { value, done } = iterator.next();\n\n\t\tif (currentFound) {\n\t\t\tnextElement = value;\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tcurrentFound = value === ref;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn nextElement;\n}\n\nfunction getPreviousItem(ref: HTMLElement, loop: boolean) {\n\tlet previousElement;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref);\n\tconst iterator = nodes.values();\n\n\tif (loop && ref === nodes.item(0)) {\n\t\treturn nodes.item(nodes.length - 1);\n\t}\n\n\tdo {\n\t\tconst { value, done } = iterator.next();\n\t\tconst currentFound = value === ref;\n\n\t\tif (currentFound) {\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tpreviousElement = value;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn previousElement;\n}\n\nfunction onKeyDown(event: KeyboardEvent, ref: HTMLElement, loop: boolean) {\n\tswitch (event.key) {\n\t\tcase 'Down':\n\t\tcase 'ArrowDown':\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tfocusOn(getNextItem(ref, loop));\n\t\t\tbreak;\n\t\tcase 'Up':\n\t\tcase 'ArrowUp':\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\t\t\tfocusOn(getPreviousItem(ref, loop));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\nexport function withListGesture(WrappedComponent: React.ComponentType, loop = false) {\n\tfunction ListGesture(props: T) {\n\t\treturn (\n\t\t\t onKeyDown(event, ref, loop)}\n\t\t\t/>\n\t\t);\n\t}\n\n\tListGesture.displayName = `ListGesture(${WrappedComponent.displayName})`;\n\n\treturn ListGesture;\n}\n"],"mappings":"AAqFG;AArFH,SAAS,eAAe;AAExB,SAAS,YAAY,KAA4B;AAChD,QAAM,UAAU,IAAI,QAAQ,eAAe;AAC3C,MAAI,CAAC,SAAS;AACb,WAAO,IAAI,SAAS;AAAA,EACrB;AACA,SAAO,QAAQ,iBAAiB,mBAAmB;AACpD;AAEA,S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O,OAAO;AAC1F,WAAS,YAAY,OAAU;AAC9B,WACC;AAAA,MAAC;AAAA;AAAA,QACC,GAAG;AAAA,QACJ,WAAW,CAAC,OAAsB,QAAqB,UAAU,OAAO,KAAK,IAAI;AAAA;AAAA,IAClF;AAAA,EAEF;AAEA,cAAY,cAAc,eAAe,iBAAiB,WAAW;AAErE,SAAO;AACR;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withMonthCalendarGesture.js b/packages/a11y/libx/Gesture/withMonthCalendarGesture.js deleted file mode 100644 index 8dad8ec68d9..00000000000 --- a/packages/a11y/libx/Gesture/withMonthCalendarGesture.js +++ /dev/null @@ -1,65 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import { Component, createRef } from 'react'; -import { FIRST, LAST } from './constants'; -import { focusWithinCurrentCalendar } from './focus'; -import { preventScroll } from './preventScroll'; -function withMonthCalendarGesture(WrappedComponent, rowSize) { - var _a; - return ( - (_a = class extends Component { - constructor(props) { - super(props); - this.ref = createRef(); - this.onKeyDown = this.onKeyDown.bind(this); - } - onKeyDown(event, calendarRef, monthIndex) { - switch (event.key) { - case 'Left': - case 'ArrowLeft': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, monthIndex - 1); - break; - case 'Right': - case 'ArrowRight': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, monthIndex + 1); - break; - case 'Up': - case 'ArrowUp': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, monthIndex - rowSize); - break; - case 'Down': - case 'ArrowDown': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, monthIndex + rowSize); - break; - case 'Home': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, FIRST); - break; - case 'End': - event.stopPropagation(); - focusWithinCurrentCalendar(calendarRef, LAST); - break; - default: - break; - } - } - render() { - return /* @__PURE__ */ jsx('div', { - ref: this.ref, - onKeyDown: preventScroll, - children: /* @__PURE__ */ jsx(WrappedComponent, { - ...this.props, - onKeyDown: this.onKeyDown, - }), - }); - } - }), - (_a.displayName = `MonthCalendarGesture(${WrappedComponent.displayName})`), - _a - ); -} -export { withMonthCalendarGesture }; -//# sourceMappingURL=withMonthCalendarGesture.js.map diff --git a/packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map b/packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map deleted file mode 100644 index dfc55c5c894..00000000000 --- a/packages/a11y/libx/Gesture/withMonthCalendarGesture.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/withMonthCalendarGesture.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable jsx-a11y/no-static-element-interactions */\n\n/* eslint-disable react/no-multi-comp,class-methods-use-this */\nimport { Component, ComponentType, createRef, KeyboardEvent as ReactKeyboardEvent } from 'react';\n\nimport { FIRST, LAST } from './constants';\nimport { focusWithinCurrentCalendar } from './focus';\nimport { preventScroll } from './preventScroll';\nimport { WithCalendarGestureInjectedProps } from './propTypes';\n\nexport function withMonthCalendarGesture

(\n\tWrappedComponent: ComponentType

,\n\trowSize: number,\n) {\n\ttype Props = Omit;\n\n\treturn class MonthCalendarGesture extends Component {\n\t\tstatic displayName = `MonthCalendarGesture(${WrappedComponent.displayName})`;\n\n\t\tref = createRef();\n\n\t\tconstructor(props: Props) {\n\t\t\tsuper(props);\n\t\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t\t}\n\n\t\tonKeyDown(\n\t\t\tevent: ReactKeyboardEvent,\n\t\t\tcalendarRef: HTMLElement,\n\t\t\tmonthIndex: number,\n\t\t) {\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'Left':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex - 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Right':\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex + 1);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Up':\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex - rowSize);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Down':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, monthIndex + rowSize);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, FIRST);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusWithinCurrentCalendar(calendarRef, LAST);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\treturn (\n\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t);\n\t\t}\n\t};\n}\n"],"mappings":"AAsEK;AAjEL,SAAS,WAA0B,iBAAsD;AAEzF,SAAS,OAAO,YAAY;AAC5B,SAAS,kCAAkC;AAC3C,SAAS,qBAAqB;AAGvB,SAAS,yBACf,kBACA,SACC;AAfF;AAkBC,SAAO,mBAAmC,UAAiB;AAAA,IAK1D,YAAY,OAAc;AACzB,YAAM,KAAK;AAHZ,iBAAM,UAA0B;AAI/B,WAAK,YAAY,KAAK,UAAU,KAAK,IAAI;AAAA,IAC1C;AAAA,IAEA,UACC,OACA,aACA,YACC;AACD,cAAQ,MAAM,KAAK;AAAA,QAClB,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,aAAa,CAAC;AACtD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,aAAa,CAAC;AACtD;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,aAAa,OAAO;AAC5D;AAAA,QACD,KAAK;AAAA,QACL,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,aAAa,OAAO;AAC5D;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,KAAK;AAC7C;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,qCAA2B,aAAa,IAAI;AAC5C;AAAA,QACD;AACC;AAAA,MACF;AAAA,IACD;AAAA,IAEA,SAAS;AACR,aACC,oBAAC,SAAI,KAAK,KAAK,KAAK,WAAW,eAC9B,8BAAC,oBAAkB,GAAI,KAAK,OAAe,WAAW,KAAK,WAAW,GACvE;AAAA,IAEF;AAAA,EACD,GAxDO,GACC,cAAc,wBAAwB,iBAAiB,WAAW,KADnE;AAyDR;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/Gesture/withTreeGesture.js b/packages/a11y/libx/Gesture/withTreeGesture.js deleted file mode 100644 index 08220efae8e..00000000000 --- a/packages/a11y/libx/Gesture/withTreeGesture.js +++ /dev/null @@ -1,148 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import { Component } from 'react'; -import { focusOn } from './focus'; -function getAllItems(ref) { - const nodes = ref.closest('ul[role="tree"]'); - if (nodes) { - return nodes.querySelectorAll('li[role="treeitem"]'); - } - return null; -} -function getFirstItem(ref) { - const nodes = ref.closest('ul[role="tree"]'); - if (nodes) { - return nodes.querySelector('li[role="treeitem"]'); - } - return null; -} -function getLastItem(ref) { - const nodes = getAllItems(ref); - if (nodes && nodes.length > 0) { - return nodes.item(nodes.length - 1); - } - return null; -} -function getParentItem(ref) { - const parentElement = ref.parentElement; - if (parentElement) { - return parentElement.closest('li[role="treeitem"]'); - } - return null; -} -function getFirstChildItem(ref) { - return ref.querySelector('li[role="treeitem"]'); -} -function getNextItem(ref) { - let nextElement = null; - let currentFound; - let hasNext; - const nodes = getAllItems(ref)?.values(); - if (!nodes) { - return nextElement; - } - do { - const { value, done } = nodes.next(); - if (currentFound) { - nextElement = value; - hasNext = false; - } else { - currentFound = value === ref; - hasNext = !done; - } - } while (hasNext); - return nextElement; -} -function getPreviousItem(ref) { - let previousElement = null; - let hasNext; - const nodes = getAllItems(ref)?.values(); - if (!nodes) { - return previousElement; - } - do { - const { value, done } = nodes.next(); - const currentFound = value === ref; - if (currentFound) { - hasNext = false; - } else { - previousElement = value; - hasNext = !done; - } - } while (hasNext); - return previousElement; -} -function withTreeGesture(WrappedComponent) { - var _a; - return ( - (_a = class extends Component { - constructor(props) { - super(props); - this.onKeyDown = this.onKeyDown.bind(this); - } - onKeyDown(event, ref, item) { - const { hasChildren, isOpened, siblings } = item; - switch (event.key) { - case 'Enter': - case ' ': - case 'Spacebar': - event.stopPropagation(); - this.props.onSelect(event, item); - break; - case 'Left': - case 'ArrowLeft': - if (hasChildren && isOpened) { - event.stopPropagation(); - this.props.onToggle(event, item); - } else if (!hasChildren || !isOpened) { - event.stopPropagation(); - focusOn(getParentItem(ref)); - } - break; - case 'Right': - case 'ArrowRight': - if (hasChildren && !isOpened) { - event.stopPropagation(); - this.props.onToggle(event, item); - } else if (hasChildren && isOpened) { - event.stopPropagation(); - focusOn(getFirstChildItem(ref)); - } - break; - case 'Down': - case 'ArrowDown': - event.stopPropagation(); - focusOn(getNextItem(ref)); - break; - case 'Up': - case 'ArrowUp': - event.stopPropagation(); - focusOn(getPreviousItem(ref)); - break; - case 'Home': - event.stopPropagation(); - focusOn(getFirstItem(ref)); - break; - case 'End': - event.stopPropagation(); - focusOn(getLastItem(ref)); - break; - default: - break; - } - if (event.nativeEvent.key === '*' || event.nativeEvent.key === 'Multiply') { - event.stopPropagation(); - this.props.onToggleAllSiblings(event, siblings); - } - } - render() { - const props = { ...this.props }; - props.onKeyDown = this.onKeyDown; - return /* @__PURE__ */ jsx(WrappedComponent, { ...props }); - } - }), - (_a.displayName = `TreeGesture(${WrappedComponent.displayName})`), - _a - ); -} -export { withTreeGesture }; -//# sourceMappingURL=withTreeGesture.js.map diff --git a/packages/a11y/libx/Gesture/withTreeGesture.js.map b/packages/a11y/libx/Gesture/withTreeGesture.js.map deleted file mode 100644 index 6b906236281..00000000000 --- a/packages/a11y/libx/Gesture/withTreeGesture.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/Gesture/withTreeGesture.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Component, ComponentType, KeyboardEvent } from 'react';\n\nimport { focusOn } from './focus';\n\nfunction getAllItems(ref: HTMLElement) {\n\tconst nodes = ref.closest('ul[role=\"tree\"]');\n\tif (nodes) {\n\t\treturn nodes.querySelectorAll('li[role=\"treeitem\"]');\n\t}\n\treturn null;\n}\n\nfunction getFirstItem(ref: HTMLElement): HTMLElement | null {\n\tconst nodes = ref.closest('ul[role=\"tree\"]');\n\tif (nodes) {\n\t\treturn nodes.querySelector('li[role=\"treeitem\"]');\n\t}\n\treturn null;\n}\n\nfunction getLastItem(ref: HTMLElement): HTMLElement | null {\n\tconst nodes = getAllItems(ref);\n\tif (nodes && nodes.length > 0) {\n\t\treturn nodes.item(nodes.length - 1) as HTMLElement;\n\t}\n\treturn null;\n}\n\nfunction getParentItem(ref: HTMLElement): HTMLElement | null {\n\tconst parentElement = ref.parentElement;\n\tif (parentElement) {\n\t\treturn parentElement.closest('li[role=\"treeitem\"]');\n\t}\n\treturn null;\n}\n\nfunction getFirstChildItem(ref: HTMLElement): HTMLElement | null {\n\treturn ref.querySelector('li[role=\"treeitem\"]');\n}\n\nfunction getNextItem(ref: HTMLElement): HTMLElement | null {\n\tlet nextElement = null;\n\tlet currentFound;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref)?.values();\n\tif (!nodes) {\n\t\treturn nextElement;\n\t}\n\n\tdo {\n\t\tconst { value, done } = nodes.next();\n\n\t\tif (currentFound) {\n\t\t\tnextElement = value;\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tcurrentFound = value === ref;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn nextElement;\n}\n\nfunction getPreviousItem(ref: HTMLElement) {\n\tlet previousElement = null;\n\tlet hasNext;\n\n\tconst nodes = getAllItems(ref)?.values();\n\tif (!nodes) {\n\t\treturn previousElement;\n\t}\n\n\tdo {\n\t\tconst { value, done } = nodes.next();\n\t\tconst currentFound = value === ref;\n\n\t\tif (currentFound) {\n\t\t\thasNext = false;\n\t\t} else {\n\t\t\tpreviousElement = value;\n\t\t\thasNext = !done;\n\t\t}\n\t} while (hasNext);\n\n\treturn previousElement;\n}\n\nexport type TreeGestureProps = {\n\tonSelect: (e: KeyboardEvent, item: any) => void;\n\tonToggle: (e: KeyboardEvent, item: any) => void;\n\tonToggleAllSiblings: (e: KeyboardEvent, siblings: any) => void;\n};\n\nexport type WithTreeInjectedProps = TreeGestureProps & {\n\tonKeyDown: (e: KeyboardEvent, ref: any, item: any) => void;\n};\n\nexport function withTreeGesture(\n\tWrappedComponent: ComponentType,\n) {\n\ttype Props = Omit;\n\n\treturn class TreeGesture extends Component {\n\t\tstatic displayName = `TreeGesture(${WrappedComponent.displayName})`;\n\n\t\tconstructor(props: Props) {\n\t\t\tsuper(props);\n\t\t\tthis.onKeyDown = this.onKeyDown.bind(this);\n\t\t}\n\n\t\tonKeyDown(event: KeyboardEvent, ref: any, item: any) {\n\t\t\tconst { hasChildren, isOpened, siblings } = item;\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'Enter':\n\t\t\t\tcase ' ':\n\t\t\t\tcase 'Spacebar':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tthis.props.onSelect(event, item);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Left':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tif (hasChildren && isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tthis.props.onToggle(event, item);\n\t\t\t\t\t} else if (!hasChildren || !isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tfocusOn(getParentItem(ref));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Right':\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tif (hasChildren && !isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tthis.props.onToggle(event, item);\n\t\t\t\t\t} else if (hasChildren && isOpened) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tfocusOn(getFirstChildItem(ref));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Down':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getNextItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Up':\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getPreviousItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getFirstItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tfocusOn(getLastItem(ref));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (event.nativeEvent.key === '*' || event.nativeEvent.key === 'Multiply') {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tthis.props.onToggleAllSiblings(event, siblings);\n\t\t\t}\n\t\t}\n\n\t\trender() {\n\t\t\tconst props = { ...(this.props as any) };\n\t\t\tprops.onKeyDown = this.onKeyDown;\n\t\t\treturn ;\n\t\t}\n\t};\n}\n"],"mappings":"AA4KU;AA3KV,SAAS,iBAA+C;AA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gB;AACtB,kBAAQ,aAAa,GAAG,CAAC;AACzB;AAAA,QACD,KAAK;AACJ,gBAAM,gBAAgB;AACtB,kBAAQ,YAAY,GAAG,CAAC;AACxB;AAAA,QACD;AACC;AAAA,MACF;AACA,UAAI,MAAM,YAAY,QAAQ,OAAO,MAAM,YAAY,QAAQ,YAAY;AAC1E,cAAM,gBAAgB;AACtB,aAAK,MAAM,oBAAoB,OAAO,QAAQ;AAAA,MAC/C;AAAA,IACD;AAAA,IAEA,SAAS;AACR,YAAM,QAAQ,EAAE,GAAI,KAAK,MAAc;AACvC,YAAM,YAAY,KAAK;AACvB,aAAO,oBAAC,oBAAkB,GAAG,OAAO;AAAA,IACrC;AAAA,EACD,GArEO,GACC,cAAc,eAAe,iBAAiB,WAAW,KAD1D;AAsER;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/index.js b/packages/a11y/libx/index.js deleted file mode 100644 index b625cf50ef5..00000000000 --- a/packages/a11y/libx/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Gesture, { focus } from './Gesture'; -export { Gesture, focus }; -//# sourceMappingURL=index.js.map diff --git a/packages/a11y/libx/index.js.map b/packages/a11y/libx/index.js.map deleted file mode 100644 index 803684f71ec..00000000000 --- a/packages/a11y/libx/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import Gesture, { focus } from './Gesture';\n\nexport { Gesture, focus };\n"],"mappings":"AAAA,OAAO,WAAW,aAAa;","names":[]} \ No newline at end of file diff --git a/packages/a11y/libx/test-setup.js b/packages/a11y/libx/test-setup.js deleted file mode 100644 index e178fbc0b35..00000000000 --- a/packages/a11y/libx/test-setup.js +++ /dev/null @@ -1,2 +0,0 @@ -import '@testing-library/jest-dom/vitest'; -//# sourceMappingURL=test-setup.js.map diff --git a/packages/a11y/libx/test-setup.js.map b/packages/a11y/libx/test-setup.js.map deleted file mode 100644 index 1f6c75df7d0..00000000000 --- a/packages/a11y/libx/test-setup.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/test-setup.ts"],"sourcesContent":["import '@testing-library/jest-dom/vitest';\n"],"mappings":"AAAA,OAAO;","names":[]} \ No newline at end of file diff --git a/packages/a11y/package.json b/packages/a11y/package.json index 18e3d205762..94650352265 100644 --- a/packages/a11y/package.json +++ b/packages/a11y/package.json @@ -39,6 +39,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/assets-api/libx/index.d.ts b/packages/assets-api/libx/index.d.ts deleted file mode 100644 index 6057b38d4f8..00000000000 --- a/packages/assets-api/libx/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -declare global { - interface Window { - Talend: any; - } -} -interface Asset { - name: string; - version: string; - path: string; -} -interface Script { - src: string; - integrity?: string; - onload?: () => void; - onerror?: (e: Error) => void; -} -interface StyleAsset { - href: string; - integrity: string; -} -interface TypedResponse extends Response { - /** - * this will override `json` method from `Body` that is extended by `Response` - * interface Body { - * json(): Promise; - * } - */ - json

(): Promise

; -} -declare function getURL(path: string, name?: string, version?: string): any; -declare function addScript({ src, integrity, ...attr }: Script): void; -declare function toDefaultModule(value: any): any; -declare function getUMD( - name: string, - version?: string, - varName?: string, - path?: string, -): Promise; -declare function getJSON(path: string, name?: string, version?: string): Promise; -declare function addStyle({ href, integrity, ...attr }: StyleAsset): void; -declare const _default: { - getURL: typeof getURL; - getUMD: typeof getUMD; - getJSON: typeof getJSON; - addScript: typeof addScript; - addStyle: typeof addStyle; - toDefaultModule: typeof toDefaultModule; -}; - -export { type Asset, type Script, type StyleAsset, type TypedResponse, _default as default }; diff --git a/packages/assets-api/libx/index.js b/packages/assets-api/libx/index.js deleted file mode 100644 index 83fdd8fcd92..00000000000 --- a/packages/assets-api/libx/index.js +++ /dev/null @@ -1,156 +0,0 @@ -function getPackageVersion(name, version) { - if (name) { - const sessionVersion = sessionStorage.getItem(name); - if (sessionVersion) { - return sessionVersion; - } - const metas = document.querySelectorAll(`meta[name="${name}"]`); - if (metas.length > 1) { - console.warn(`Package ${name} is installed multiple times`); - } - if (metas.length > 0) { - return metas[0].getAttribute('content') || version; - } - } - return version; -} -function getURL(path, name, version) { - const overriddenVersion = getPackageVersion(name, version); - if (!overriddenVersion) { - throw new Error(`Version not found for ${name}`); - } - return window.Talend.getCDNUrl({ name, version: overriddenVersion, path }); -} -const TIMEOUT = 1e4; -function addScript({ src, integrity, ...attr }) { - const found = !!document.querySelector(`script[src="${src}"]`); - if (found) { - return; - } - const script = document.createElement('script'); - script.setAttribute('src', src); - script.setAttribute('type', 'text/javascript'); - script.setAttribute('crossorigin', 'anonymous'); - if (integrity) { - script.setAttribute('integrity', integrity); - } - script.async = false; - Object.assign(script, attr); - document.body.appendChild(script); -} -function toDefaultModule(value) { - return Object.create(null, { - default: { - value, - enumerable: true, - }, - __esModule: { - value: true, - }, - [Symbol.toStringTag]: { - value: 'Module', - }, - }); -} -function getUMD(name, version, varName, path) { - const cache = { resolved: false }; - function loaded() { - if (!varName) { - return false; - } - return !!window[varName]; - } - if (loaded() && varName) { - return Promise.resolve(window[varName]); - } - const src = getURL(path || '/undefined', name, version); - console.log('getUMD', src, varName); - return new Promise((resolve, reject) => { - function onload() { - if (!varName) { - cache.resolved = true; - resolve(void 0); - } else { - console.log(`${varName} onload ok`); - } - } - function onerror(e) { - console.error(e); - reject(e); - } - addScript({ src, onload, onerror }); - if (varName) { - const intervalId = setInterval(() => { - if (loaded()) { - cache.resolved = true; - clearInterval(intervalId); - resolve(window[varName]); - } - }, 200); - setTimeout(() => { - if (!cache.resolved) { - clearInterval(intervalId); - reject(new Error(`UMD from ${src}, ${varName} not found in ${TIMEOUT}`)); - } - }, TIMEOUT); - } - }); -} -async function getJSON(path, name, version) { - const url = getURL(path, name, version); - const response = await fetch(url); - if (response.ok) { - return response.json(); - } - console.error(`Response not ok: ${response.status} ${response.statusText} from ${url}`); - return void 0; -} -function addStyle({ href, integrity, ...attr }) { - const found = !!document.querySelector(`link[href="${href}"]`); - if (found) { - return; - } - const style = document.createElement('link'); - style.setAttribute('rel', 'stylesheet'); - style.setAttribute('media', 'print'); - style.setAttribute('onload', 'this.media="all"'); - if (integrity) { - style.setAttribute('integrity', integrity); - style.setAttribute('crossorigin', 'anonymous'); - } - style.setAttribute('href', href); - Object.assign(style, attr); - const title = document.getElementsByTagName('TITLE')[0]; - document.head.insertBefore(style, title); -} -if (!window.Talend) { - window.Talend = {}; -} -if (!window.Talend.getCDNUrl) { - window.Talend.getCDNUrl = info => { - const CDN_URL = window.Talend.CDN_URL; - if (CDN_URL) { - if (CDN_URL.startsWith('/')) { - const baseTag = document.querySelector('base'); - if (baseTag) { - const root = baseTag.getAttribute('href') || ''; - if (root !== '/') { - return `${root}${CDN_URL}/${info.name}/${info.version}${info.path}`; - } - } - } - return `${CDN_URL}/${info.name}/${info.version}${info.path}`; - } - return `https://statics.cloud.talend.com/${info.name}/${info.version}${info.path}`; - }; -} -var index_default = { - getURL, - getUMD, - getJSON, - addScript, - addStyle, - toDefaultModule, -}; -export { index_default as default }; -//# sourceMappingURL=index.js.map diff --git a/packages/assets-api/libx/index.js.map b/packages/assets-api/libx/index.js.map deleted file mode 100644 index e4e90ea596d..00000000000 --- a/packages/assets-api/libx/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable no-console */\ndeclare global {\n\tinterface Window {\n\t\tTalend: any;\n\t}\n}\n\nexport interface Asset {\n\tname: string;\n\tversion: string;\n\tpath: string;\n}\nexport interface Script {\n\tsrc: string;\n\tintegrity?: string;\n\tonload?: () => void;\n\tonerror?: (e: Error) => void;\n}\nexport interface StyleAsset {\n\thref: string;\n\tintegrity: string;\n}\n\nexport interface TypedResponse extends Response {\n\t/**\n\t * this will override `json` method from `Body` that is extended by `Response`\n\t * interface Body {\n\t * json(): Promise;\n\t * }\n\t */\n\tjson

(): Promise

;\n}\n\n/**\n *\n * Most of the parameters are optional but in fact they are not optional.\n * They are optional for dev experience because injected by a babel plugin\n */\n\nfunction getPackageVersion(name?: string, version?: string): string | undefined {\n\tif (name) {\n\t\tconst sessionVersion = sessionStorage.getItem(name);\n\t\tif (sessionVersion) {\n\t\t\treturn sessionVersion;\n\t\t}\n\n\t\tconst metas = document.querySelectorAll(`meta[name=\"${name}\"]`);\n\t\tif (metas.length > 1) {\n\t\t\tconsole.warn(`Package ${name} is installed multiple times`);\n\t\t}\n\t\tif (metas.length > 0) {\n\t\t\treturn metas[0].getAttribute('content') || version;\n\t\t}\n\t}\n\treturn version;\n}\n\nfunction getURL(path: string, name?: string, version?: string) {\n\tconst overriddenVersion = getPackageVersion(name, version);\n\tif (!overriddenVersion) {\n\t\tthrow new Error(`Version not found for ${name}`);\n\t}\n\treturn window.Talend.getCDNUrl({ name, version: overriddenVersion, path });\n}\n\nconst TIMEOUT = 10000;\n\nfunction addScript({ src, integrity, ...attr }: Script) {\n\tconst found = !!document.querySelector(`script[src=\"${src}\"]`);\n\tif (found) {\n\t\treturn;\n\t}\n\tconst script = document.createElement('script');\n\tscript.setAttribute('src', src);\n\tscript.setAttribute('type', 'text/javascript');\n\tscript.setAttribute('crossorigin', 'anonymous');\n\tif (integrity) {\n\t\tscript.setAttribute('integrity', integrity);\n\t}\n\tscript.async = false;\n\tObject.assign(script, attr);\n\tdocument.body.appendChild(script);\n}\n\nfunction toDefaultModule(value: any) {\n\treturn Object.create(null, {\n\t\tdefault: {\n\t\t\tvalue,\n\t\t\tenumerable: true,\n\t\t},\n\t\t__esModule: {\n\t\t\tvalue: true,\n\t\t},\n\t\t[Symbol.toStringTag]: {\n\t\t\tvalue: 'Module',\n\t\t},\n\t});\n}\n\nfunction getUMD(name: string, version?: string, varName?: string, path?: string) {\n\tconst cache = { resolved: false };\n\tfunction loaded() {\n\t\tif (!varName) {\n\t\t\treturn false;\n\t\t}\n\t\treturn !!(window as any)[varName];\n\t}\n\tif (loaded() && varName) {\n\t\treturn Promise.resolve((window as any)[varName]);\n\t}\n\tconst src = getURL(path || '/undefined', name, version);\n\tconsole.log('getUMD', src, varName);\n\n\treturn new Promise((resolve, reject) => {\n\t\tfunction onload() {\n\t\t\tif (!varName) {\n\t\t\t\tcache.resolved = true;\n\t\t\t\tresolve(undefined);\n\t\t\t} else {\n\t\t\t\tconsole.log(`${varName} onload ok`);\n\t\t\t}\n\t\t}\n\t\tfunction onerror(e: Error) {\n\t\t\tconsole.error(e);\n\t\t\treject(e);\n\t\t}\n\t\taddScript({ src, onload, onerror });\n\t\tif (varName) {\n\t\t\tconst intervalId = setInterval(() => {\n\t\t\t\tif (loaded()) {\n\t\t\t\t\tcache.resolved = true;\n\t\t\t\t\tclearInterval(intervalId);\n\t\t\t\t\tresolve((window as any)[varName]);\n\t\t\t\t}\n\t\t\t}, 200);\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (!cache.resolved) {\n\t\t\t\t\tclearInterval(intervalId);\n\t\t\t\t\treject(new Error(`UMD from ${src}, ${varName} not found in ${TIMEOUT}`));\n\t\t\t\t}\n\t\t\t}, TIMEOUT);\n\t\t}\n\t});\n}\n\nasync function getJSON(path: string, name?: string, version?: string) {\n\tconst url = getURL(path, name, version);\n\tconst response: TypedResponse = await fetch(url);\n\tif (response.ok) {\n\t\treturn response.json();\n\t}\n\tconsole.error(`Response not ok: ${response.status} ${response.statusText} from ${url}`);\n\n\treturn undefined;\n}\n\nfunction addStyle({ href, integrity, ...attr }: StyleAsset) {\n\tconst found = !!document.querySelector(`link[href=\"${href}\"]`);\n\tif (found) {\n\t\treturn;\n\t}\n\tconst style = document.createElement('link');\n\tstyle.setAttribute('rel', 'stylesheet');\n\tstyle.setAttribute('media', 'print');\n\tstyle.setAttribute('onload', 'this.media=\"all\"');\n\tif (integrity) {\n\t\tstyle.setAttribute('integrity', integrity);\n\t\tstyle.setAttribute('crossorigin', 'anonymous');\n\t}\n\tstyle.setAttribute('href', href);\n\tObject.assign(style, attr);\n\tconst title = document.getElementsByTagName('TITLE')[0];\n\tdocument.head.insertBefore(style, title);\n}\n\nif (!window.Talend) {\n\twindow.Talend = {};\n}\nif (!window.Talend.getCDNUrl) {\n\twindow.Talend.getCDNUrl = (info: Asset) => {\n\t\tconst CDN_URL = window.Talend.CDN_URL;\n\t\tif (CDN_URL) {\n\t\t\tif (CDN_URL.startsWith('/')) {\n\t\t\t\tconst baseTag = document.querySelector('base');\n\t\t\t\tif (baseTag) {\n\t\t\t\t\tconst root = baseTag.getAttribute('href') || '';\n\t\t\t\t\tif (root !== '/') {\n\t\t\t\t\t\treturn `${root}${CDN_URL}/${info.name}/${info.version}${info.path}`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn `${CDN_URL}/${info.name}/${info.version}${info.path}`;\n\t\t}\n\t\treturn `https://statics.cloud.talend.com/${info.name}/${info.version}${info.path}`;\n\t};\n}\n\nexport default {\n\tgetURL,\n\tgetUMD,\n\tgetJSON,\n\taddScript,\n\taddStyle,\n\ttoDefaultModule,\n};\n"],"mappings":"AAuCA,SAAS,kBAAkB,MAAe,SAAsC;AAC/E,MAAI,MAAM;AACT,UAAM,iBAAiB,eAAe,QAAQ,IAAI;AAClD,QAAI,gBAAgB;AACnB,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,SAAS,iBAAiB,cAAc,IAAI,IAAI;AAC9D,QAAI,MAAM,SAAS,GAAG;AACrB,cAAQ,KAAK,WAAW,IAAI,8BAA8B;AAAA,IAC3D;AACA,QAAI,MAAM,SAAS,GAAG;AACrB,aAAO,MAAM,CAAC,EAAE,aAAa,SAAS,KAAK;AAAA,IAC5C;AAAA,EACD;AACA,SAAO;AACR;AAEA,SAAS,OAAO,MAAc,MAAe,SAAkB;AAC9D,QAAM,oBAAoB,kBAAkB,MAAM,OAAO;AACzD,MAAI,CAAC,mBAAmB;AACvB,UAAM,IAAI,MAAM,yBAAyB,IAAI,EAAE;AAAA,EA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e,WAAW;AAAA,EAC9C;AACA,QAAM,aAAa,QAAQ,IAAI;AAC/B,SAAO,OAAO,OAAO,IAAI;AACzB,QAAM,QAAQ,SAAS,qBAAqB,OAAO,EAAE,CAAC;AACtD,WAAS,KAAK,aAAa,OAAO,KAAK;AACxC;AAEA,IAAI,CAAC,OAAO,QAAQ;AACnB,SAAO,SAAS,CAAC;AAClB;AACA,IAAI,CAAC,OAAO,OAAO,WAAW;AAC7B,SAAO,OAAO,YAAY,CAAC,SAAgB;AAC1C,UAAM,UAAU,OAAO,OAAO;AAC9B,QAAI,SAAS;AACZ,UAAI,QAAQ,WAAW,GAAG,GAAG;AAC5B,cAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAI,SAAS;AACZ,gBAAM,OAAO,QAAQ,aAAa,MAAM,KAAK;AAC7C,cAAI,SAAS,KAAK;AACjB,mBAAO,GAAG,IAAI,GAAG,OAAO,IAAI,KAAK,IAAI,IAAI,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,UAClE;AAAA,QACD;AAAA,MACD;AACA,aAAO,GAAG,OAAO,IAAI,KAAK,IAAI,IAAI,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,IAC3D;AACA,WAAO,oCAAoC,KAAK,IAAI,IAAI,KAAK,OAAO,GAAG,KAAK,IAAI;AAAA,EACjF;AACD;AAEA,IAAO,gBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;","names":[]} \ No newline at end of file diff --git a/packages/assets-api/package.json b/packages/assets-api/package.json index 7de84259b5e..0f35b1b3887 100644 --- a/packages/assets-api/package.json +++ b/packages/assets-api/package.json @@ -37,6 +37,7 @@ "dependencies": {}, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@talend/babel-plugin-import-from-index": "^1.13.1", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/cmf-cqrs/package.json b/packages/cmf-cqrs/package.json index 4fb050a0919..4b06a4b7d25 100644 --- a/packages/cmf-cqrs/package.json +++ b/packages/cmf-cqrs/package.json @@ -49,6 +49,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitest/coverage-v8": "^4.0.18", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/cmf-router/package.json b/packages/cmf-router/package.json index 033e5ab6570..b095df2c858 100644 --- a/packages/cmf-router/package.json +++ b/packages/cmf-router/package.json @@ -45,6 +45,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitest/coverage-v8": "^4.0.18", "@redux-saga/testing-utils": "^1.2.1", "@talend/eslint-config": "^14.1.2", diff --git a/packages/cmf/package.json b/packages/cmf/package.json index dc545abdd04..558e4e208ff 100644 --- a/packages/cmf/package.json +++ b/packages/cmf/package.json @@ -63,6 +63,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@redux-saga/testing-utils": "^1.2.1", diff --git a/packages/components/package.json b/packages/components/package.json index dfd190a39bd..663f956fc04 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -82,6 +82,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/addon-links": "^10.2.1", "@storybook/react": "^10.2.1", diff --git a/packages/containers/package.json b/packages/containers/package.json index b790516f12a..b2553bb5380 100644 --- a/packages/containers/package.json +++ b/packages/containers/package.json @@ -62,6 +62,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/icons": "^8.0.0", diff --git a/packages/dataviz/package.json b/packages/dataviz/package.json index a037fd2ced8..4caeafd374f 100644 --- a/packages/dataviz/package.json +++ b/packages/dataviz/package.json @@ -55,6 +55,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/react": "^10.2.1", "@storybook/react-vite": "^10.2.1", diff --git a/packages/design-system/package.json b/packages/design-system/package.json index 2df1f4c4c5d..3b518d3aed7 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -59,6 +59,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/addon-links": "^10.2.1", "@storybook/react": "^10.2.1", diff --git a/packages/design-tokens/package.json b/packages/design-tokens/package.json index d9054231caf..c2196c5c435 100644 --- a/packages/design-tokens/package.json +++ b/packages/design-tokens/package.json @@ -54,6 +54,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "sass": "^1.97.3", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/faceted-search-query-client/package.json b/packages/faceted-search-query-client/package.json index 3c1a999fa38..87c73491349 100644 --- a/packages/faceted-search-query-client/package.json +++ b/packages/faceted-search-query-client/package.json @@ -48,6 +48,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/react-faceted-search": "22.1.1", diff --git a/packages/faceted-search/package.json b/packages/faceted-search/package.json index ea1da270e04..d035764ca7b 100644 --- a/packages/faceted-search/package.json +++ b/packages/faceted-search/package.json @@ -55,6 +55,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@storybook/react": "^10.2.1", diff --git a/packages/flow-designer/package.json b/packages/flow-designer/package.json index 78d73065883..d740e8853fc 100644 --- a/packages/flow-designer/package.json +++ b/packages/flow-designer/package.json @@ -32,6 +32,7 @@ "license": "Apache-2.0", "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/babel-plugin-import-from-index": "^1.13.1", diff --git a/packages/forms/package.json b/packages/forms/package.json index 41648bb0e2c..9e048354eaf 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -68,6 +68,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.0", "@vitest/coverage-v8": "^4.0.18", "@talend/locales-tui-forms": "^15.2.0", diff --git a/packages/http/package.json b/packages/http/package.json index 1e7a0a1edcd..63bb35c112f 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -39,6 +39,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitest/coverage-v8": "^4.0.18", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", diff --git a/packages/router-bridge/package.json b/packages/router-bridge/package.json index 48cac636775..736780d1982 100644 --- a/packages/router-bridge/package.json +++ b/packages/router-bridge/package.json @@ -32,6 +32,7 @@ "homepage": "https://github.com/ui/tree/master/packages/router-bridge#readme", "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/sagas/package.json b/packages/sagas/package.json index 02923794e48..c6af8615f25 100644 --- a/packages/sagas/package.json +++ b/packages/sagas/package.json @@ -52,6 +52,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", diff --git a/packages/stepper/libx/Stepper.constants.js b/packages/stepper/libx/Stepper.constants.js deleted file mode 100644 index 75d028e07b0..00000000000 --- a/packages/stepper/libx/Stepper.constants.js +++ /dev/null @@ -1,16 +0,0 @@ -import Stepper from '@talend/react-components/lib/Stepper'; -const initialState = {}; -const STATE_KEY = 'stepper'; -const LOADING_STEPS_REMOVE = 'LOADING_STEPS_REMOVE'; -const LOADING_STEPS_INIT = 'LOADING_STEPS_INIT'; -const LOADING_STEPS_PROCEED_EVENT = 'LOADING_STEPS_PROCEED_EVENT'; -const LOADING_STEP_STATUSES = Stepper.LOADING_STEP_STATUSES; -export { - LOADING_STEPS_INIT, - LOADING_STEPS_PROCEED_EVENT, - LOADING_STEPS_REMOVE, - LOADING_STEP_STATUSES, - STATE_KEY, - initialState, -}; -//# sourceMappingURL=Stepper.constants.js.map diff --git a/packages/stepper/libx/Stepper.constants.js.map b/packages/stepper/libx/Stepper.constants.js.map deleted file mode 100644 index 99b11011f90..00000000000 --- a/packages/stepper/libx/Stepper.constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/Stepper.constants.js"],"sourcesContent":["import Stepper from '@talend/react-components/lib/Stepper';\n\nexport const initialState = {};\nexport const STATE_KEY = 'stepper';\nexport const LOADING_STEPS_REMOVE = 'LOADING_STEPS_REMOVE';\nexport const LOADING_STEPS_INIT = 'LOADING_STEPS_INIT';\nexport const LOADING_STEPS_PROCEED_EVENT = 'LOADING_STEPS_PROCEED_EVENT';\n\nexport const LOADING_STEP_STATUSES = Stepper.LOADING_STEP_STATUSES;\n"],"mappings":"AAAA,OAAO,aAAa;AAEb,MAAM,eAAe,CAAC;AACtB,MAAM,YAAY;AAClB,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAM,8BAA8B;AAEpC,MAAM,wBAAwB,QAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js b/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js deleted file mode 100644 index 5687595ba86..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js +++ /dev/null @@ -1,43 +0,0 @@ -import { jsx, jsxs } from 'react/jsx-runtime'; -import { useContext } from 'react'; -import { useTranslation } from 'react-i18next'; -import { ButtonPrimary, ButtonSecondary, Divider, StackHorizontal } from '@talend/design-system'; -import I18N from '../../../constants/i18n'; -import { StepperFormContext } from '../StepperForm.context'; -import style from '../StepperForm.module.css'; -const StepFooter = ({ children, dataFeature, isLoading, onCancel, onPrevious, onNext }) => { - const { t } = useTranslation(I18N.STEPPER_NAMESPACE); - const { currentStep, steps } = useContext(StepperFormContext); - const currentStepNavigation = steps[currentStep].navigation; - return /* @__PURE__ */ jsx('div', { - className: style['stepper-form__footer'], - children: /* @__PURE__ */ jsxs(StackHorizontal, { - gap: 'M', - align: 'center', - children: [ - /* @__PURE__ */ jsx(ButtonSecondary, { - onClick: onCancel, - 'data-feature': dataFeature?.cancel, - children: t('CANCEL', 'Cancel'), - }), - /* @__PURE__ */ jsx(Divider, { orientation: 'vertical' }), - onPrevious && - /* @__PURE__ */ jsx(ButtonSecondary, { - onClick: onPrevious, - 'data-feature': dataFeature?.previous, - children: t('PREVIOUS', 'Previous'), - }), - children, - onNext && - /* @__PURE__ */ jsx(ButtonPrimary, { - onClick: onNext, - 'data-feature': dataFeature?.next, - disabled: isLoading, - children: currentStepNavigation?.next ? t('NEXT', 'Next') : t('VALIDATE', 'Validate'), - }), - ], - }), - }); -}; -export { StepFooter }; -//# sourceMappingURL=StepFooter.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map b/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map deleted file mode 100644 index ff02e79f656..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepFooter/StepFooter.component.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../../src/components/StepperForm/StepFooter/StepFooter.component.tsx"],"sourcesContent":["import { ReactNode, useContext } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { ButtonPrimary, ButtonSecondary, Divider, StackHorizontal } from '@talend/design-system';\n\nimport I18N from '../../../constants/i18n';\nimport { StepperFormContext } from '../StepperForm.context';\n\nimport style from '../StepperForm.module.css';\n\ninterface StepFooterProps {\n\tchildren?: ReactNode;\n\tdataFeature?: {\n\t\tcancel?: string;\n\t\tnext?: string;\n\t\tprevious?: string;\n\t\tsubmit?: string;\n\t};\n\tisLoading?: boolean;\n\tonCancel(): void;\n\tonNext?(): void;\n\tonPrevious?(): void;\n}\n\nexport const StepFooter = ({\n\tchildren,\n\tdataFeature,\n\tisLoading,\n\tonCancel,\n\tonPrevious,\n\tonNext,\n}: StepFooterProps) => {\n\tconst { t } = useTranslation(I18N.STEPPER_NAMESPACE);\n\tconst { currentStep, steps } = useContext(StepperFormContext);\n\n\tconst currentStepNavigation = steps[currentStep].navigation;\n\n\treturn (\n\t\t

\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t{t('CANCEL', 'Cancel')}\n\t\t\t\t\n\n\t\t\t\t\n\n\t\t\t\t{onPrevious && (\n\t\t\t\t\t\n\t\t\t\t\t\t{t('PREVIOUS', 'Previous')}\n\t\t\t\t\t\n\t\t\t\t)}\n\n\t\t\t\t{children}\n\n\t\t\t\t{onNext && (\n\t\t\t\t\t\n\t\t\t\t\t\t{currentStepNavigation?.next ? t('NEXT', 'Next') : t('VALIDATE', 'Validate')}\n\t\t\t\t\t\n\t\t\t\t)}\n\t\t\t\n\t\t
\n\t);\n};\n"],"mappings":"AAuCG,SACC,KADD;AAvCH,SAAoB,kBAAkB;AACtC,SAAS,sBAAsB;AAE/B,SAAS,eAAe,iBAAiB,SAAS,uBAAuB;AAEzE,OAAO,UAAU;AACjB,SAAS,0BAA0B;AAEnC,OAAO,WAAW;AAgBX,MAAM,aAAa,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAuB;AACtB,QAAM,EAAE,EAAE,IAAI,eAAe,KAAK,iBAAiB;AACnD,QAAM,EAAE,aAAa,MAAM,IAAI,WAAW,kBAAkB;AAE5D,QAAM,wBAAwB,MAAM,WAAW,EAAE;AAEjD,SACC,oBAAC,SAAI,WAAW,MAAM,sBAAsB,GAC3C,+BAAC,mBAAgB,KAAI,KAAI,OAAM,UAC9B;AAAA,wBAAC,mBAAgB,SAAS,UAAU,gBAAc,aAAa,QAC7D,YAAE,UAAU,QAAQ,GACtB;AAAA,IAEA,oBAAC,WAAQ,aAAY,YAAW;AAAA,IAE/B,cACA,oBAAC,mBAAgB,SAAS,YAAY,gBAAc,aAAa,UAC/D,YAAE,YAAY,UAAU,GAC1B;AAAA,IAGA;AAAA,IAEA,UACA,oBAAC,iBAAc,SAAS,QAAQ,gBAAc,aAAa,MAAM,UAAU,WACzE,iCAAuB,OAAO,EAAE,QAAQ,MAAM,IAAI,EAAE,YAAY,UAAU,GAC5E;AAAA,KAEF,GACD;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/index.js b/packages/stepper/libx/components/StepperForm/StepFooter/index.js deleted file mode 100644 index 8dd69385f75..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepFooter/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { StepFooter } from './StepFooter.component'; -export { StepFooter }; -//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepFooter/index.js.map b/packages/stepper/libx/components/StepperForm/StepFooter/index.js.map deleted file mode 100644 index f1eb48bed7a..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepFooter/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../../src/components/StepperForm/StepFooter/index.ts"],"sourcesContent":["export { StepFooter } from './StepFooter.component';\n"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js deleted file mode 100644 index c3f70f7a405..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js +++ /dev/null @@ -1,19 +0,0 @@ -import { Fragment, jsx, jsxs } from 'react/jsx-runtime'; -import style from '../StepperForm.module.css'; -const StepHeader = ({ title, subtitle }) => { - return /* @__PURE__ */ jsxs(Fragment, { - children: [ - /* @__PURE__ */ jsx('h2', { - className: style['stepper-form__header__title'], - children: title, - }), - subtitle && - /* @__PURE__ */ jsx('span', { - className: style['stepper-form__header__subtitle'], - children: subtitle, - }), - ], - }); -}; -export { StepHeader }; -//# sourceMappingURL=StepHeader.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map deleted file mode 100644 index e2e183c6e51..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.component.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../../src/components/StepperForm/StepHeader/StepHeader.component.tsx"],"sourcesContent":["import { StepHeaderProps } from './StepHeader.types';\n\nimport style from '../StepperForm.module.css';\n\nexport const StepHeader = ({ title, subtitle }: StepHeaderProps) => {\n\treturn (\n\t\t<>\n\t\t\t

{title}

\n\t\t\t{subtitle && {subtitle}}\n\t\t\n\t);\n};\n"],"mappings":"AAME,mBACC,KADD;AAJF,OAAO,WAAW;AAEX,MAAM,aAAa,CAAC,EAAE,OAAO,SAAS,MAAuB;AACnE,SACC,iCACC;AAAA,wBAAC,QAAG,WAAW,MAAM,6BAA6B,GAAI,iBAAM;AAAA,IAC3D,YAAY,oBAAC,UAAK,WAAW,MAAM,gCAAgC,GAAI,oBAAS;AAAA,KAClF;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js deleted file mode 100644 index 61f2add7d5e..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=StepHeader.types.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map b/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map deleted file mode 100644 index 84c51b288c4..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepHeader/StepHeader.types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/index.js b/packages/stepper/libx/components/StepperForm/StepHeader/index.js deleted file mode 100644 index f97f33f0dc1..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepHeader/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { StepHeader } from './StepHeader.component'; -export { StepHeader }; -//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepHeader/index.js.map b/packages/stepper/libx/components/StepperForm/StepHeader/index.js.map deleted file mode 100644 index d6332baeea9..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepHeader/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../../src/components/StepperForm/StepHeader/index.ts"],"sourcesContent":["export { StepHeader } from './StepHeader.component';\n"],"mappings":"AAAA,SAAS,kBAAkB;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.component.js b/packages/stepper/libx/components/StepperForm/StepperForm.component.js deleted file mode 100644 index 8de08e6f620..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.component.js +++ /dev/null @@ -1,51 +0,0 @@ -import { jsx, jsxs } from 'react/jsx-runtime'; -import { useContext } from 'react'; -import { Stepper as StepperDS } from '@talend/design-system'; -import { StepHeader } from './StepHeader'; -import { StepperFormContext } from './StepperForm.context'; -import { getStepComponent } from './StepperForm.utils'; -import style from './StepperForm.module.css'; -const StepperForm = ({ isLoading }) => { - const { steps, currentStep } = useContext(StepperFormContext); - const currentStepData = steps[currentStep]; - const Component = currentStepData.component; - return /* @__PURE__ */ jsxs('div', { - className: style['stepper-form'], - children: [ - /* @__PURE__ */ jsx('div', { - className: style['stepper-form__steps'], - children: /* @__PURE__ */ jsx(StepperDS, { - currentStepIndex: currentStep, - loading: isLoading, - children: steps.map((step, index) => { - const { key, navigation, tooltip, name } = step; - const Step = getStepComponent(currentStep, index, !!navigation?.disableCause); - return /* @__PURE__ */ jsx( - Step, - { - tooltip: navigation?.disableCause ?? tooltip, - title: name, - }, - `step-${key}`, - ); - }), - }), - }), - /* @__PURE__ */ jsxs('div', { - className: style['stepper-form__container'], - children: [ - /* @__PURE__ */ jsx(StepHeader, { ...currentStepData.header }), - /* @__PURE__ */ jsx('section', { - className: style['stepper-form__content'], - 'data-testid': currentStepData.key, - children: /* @__PURE__ */ jsx(Component, {}), - }), - ], - }), - ], - }); -}; -StepperForm.displayName = 'StepperForm'; -var StepperForm_component_default = StepperForm; -export { StepperForm_component_default as default }; -//# sourceMappingURL=StepperForm.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.component.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.component.js.map deleted file mode 100644 index 994a1ffe911..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.component.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/components/StepperForm/StepperForm.component.tsx"],"sourcesContent":["import { useContext } from 'react';\n\nimport { Stepper as StepperDS } from '@talend/design-system';\n\nimport { StepHeader } from './StepHeader';\nimport { StepperFormContext } from './StepperForm.context';\nimport { StepperProps } from './StepperForm.types';\nimport { getStepComponent } from './StepperForm.utils';\n\nimport style from './StepperForm.module.css';\n\nconst StepperForm = ({ isLoading }: StepperProps) => {\n\tconst { steps, currentStep } = useContext(StepperFormContext);\n\tconst currentStepData = steps[currentStep];\n\tconst Component = currentStepData.component;\n\n\treturn (\n\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t{steps.map((step, index) => {\n\t\t\t\t\t\tconst { key, navigation, tooltip, name } = step;\n\t\t\t\t\t\tconst Step = getStepComponent(currentStep, index, !!navigation?.disableCause);\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t);\n\t\t\t\t\t})}\n\t\t\t\t\n\t\t\t
\n\t\t\t
\n\t\t\t\t\n\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t);\n};\n\nStepperForm.displayName = 'StepperForm';\n\nexport default StepperForm;\n"],"mappings":"AAyBO,cASJ,YATI;AAzBP,SAAS,kBAAkB;AAE3B,SAAS,WAAW,iBAAiB;AAErC,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAEnC,SAAS,wBAAwB;AAEjC,OAAO,WAAW;AAElB,MAAM,cAAc,CAAC,EAAE,UAAU,MAAoB;AACpD,QAAM,EAAE,OAAO,YAAY,IAAI,WAAW,kBAAkB;AAC5D,QAAM,kBAAkB,MAAM,WAAW;AACzC,QAAM,YAAY,gBAAgB;AAElC,SACC,qBAAC,SAAI,WAAW,MAAM,cAAc,GACnC;AAAA,wBAAC,SAAI,WAAW,MAAM,qBAAqB,GAC1C,8BAAC,aAAU,kBAAkB,aAAa,SAAS,WACjD,gBAAM,IAAI,CAAC,MAAM,UAAU;AAC3B,YAAM,EAAE,KAAK,YAAY,SAAS,KAAK,IAAI;AAC3C,YAAM,OAAO,iBAAiB,aAAa,OAAO,CAAC,CAAC,YAAY,YAAY;AAE5E,aACC;AAAA,QAAC;AAAA;AAAA,UAEA,SAAS,YAAY,gBAAgB;AAAA,UACrC,OAAO;AAAA;AAAA,QAFF,QAAQ,GAAG;AAAA,MAGjB;AAAA,IAEF,CAAC,GACF,GACD;AAAA,IACA,qBAAC,SAAI,WAAW,MAAM,yBAAyB,GAC9C;AAAA,0BAAC,cAAY,GAAG,gBAAgB,QAAQ;AAAA,MAExC,oBAAC,aAAQ,WAAW,MAAM,uBAAuB,GAAG,eAAa,gBAAgB,KAChF,8BAAC,aAAU,GACZ;AAAA,OACD;AAAA,KACD;AAEF;AAEA,YAAY,cAAc;AAE1B,IAAO,gCAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.context.js b/packages/stepper/libx/components/StepperForm/StepperForm.context.js deleted file mode 100644 index 11f44bbf198..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.context.js +++ /dev/null @@ -1,29 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import { createContext } from 'react'; -import { useStepperForm } from '../../hooks/useStepperForm/useStepperForm.hook'; -const emptyFn = () => {}; -const StepperFormContext = createContext({ - disableStep: emptyFn, - enableStep: emptyFn, - onNext: emptyFn, - onPrevious: emptyFn, - steps: [], - currentStep: 0, -}); -const StepperFormProvider = ({ children, initialStepIndex = 0, steps, onSubmit }) => { - const { currentStep, disableStep, enableStep, onNextStep, onPreviousStep, stepperSteps } = - useStepperForm(steps, initialStepIndex, onSubmit); - return /* @__PURE__ */ jsx(StepperFormContext.Provider, { - value: { - currentStep, - disableStep, - enableStep, - onNext: onNextStep, - onPrevious: onPreviousStep, - steps: stepperSteps, - }, - children, - }); -}; -export { StepperFormContext, StepperFormProvider }; -//# sourceMappingURL=StepperForm.context.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.context.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.context.js.map deleted file mode 100644 index cb5fae6806c..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.context.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/components/StepperForm/StepperForm.context.tsx"],"sourcesContent":["import { createContext, ReactNode } from 'react';\n\nimport { useStepperForm } from '../../hooks/useStepperForm/useStepperForm.hook';\nimport { StepperState } from '../../hooks/useStepperForm/useStepperForm.types';\nimport { StepperStep } from './StepperForm.types';\n\nconst emptyFn = () => {};\n\nexport interface StepperFormValues {\n\tcurrentStep: number;\n\tdisableStep: (stepKey: string, cause: string) => void;\n\tenableStep: (stepKey: string) => void;\n\tonNext: () => void;\n\tonPrevious: () => void;\n\tsteps: StepperState;\n}\n\nexport const StepperFormContext = createContext({\n\tdisableStep: emptyFn,\n\tenableStep: emptyFn,\n\tonNext: emptyFn,\n\tonPrevious: emptyFn,\n\tsteps: [],\n\tcurrentStep: 0,\n});\n\nexport interface StepperFormProviderProps {\n\tchildren: ReactNode;\n\tinitialStepIndex?: number;\n\tsteps: StepperStep[];\n\tonSubmit: (currentStep: number) => void;\n}\n\nexport const StepperFormProvider = ({\n\tchildren,\n\tinitialStepIndex = 0,\n\tsteps,\n\tonSubmit,\n}: StepperFormProviderProps) => {\n\tconst { currentStep, disableStep, enableStep, onNextStep, onPreviousStep, stepperSteps } =\n\t\tuseStepperForm(steps, initialStepIndex, onSubmit);\n\n\treturn (\n\t\t\n\t\t\t{children}\n\t\t\n\t);\n};\n"],"mappings":"AA2CE;AA3CF,SAAS,qBAAgC;AAEzC,SAAS,sBAAsB;AAI/B,MAAM,UAAU,MAAM;AAAC;AAWhB,MAAM,qBAAqB,cAAiC;AAAA,EAClE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO,CAAC;AAAA,EACR,aAAa;AACd,CAAC;AASM,MAAM,sBAAsB,CAAC;AAAA,EACnC;AAAA,EACA,mBAAmB;AAAA,EACnB;AAAA,EACA;AACD,MAAgC;AAC/B,QAAM,EAAE,aAAa,aAAa,YAAY,YAAY,gBAAgB,aAAa,IACtF,eAAe,OAAO,kBAAkB,QAAQ;AAEjD,SACC;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACA,OAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,OAAO;AAAA,MACR;AAAA,MAEC;AAAA;AAAA,EACF;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.module.css b/packages/stepper/libx/components/StepperForm/StepperForm.module.css deleted file mode 100644 index 433f2d81523..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.module.css +++ /dev/null @@ -1,41 +0,0 @@ -.stepper-form { - display: flex; - height: calc(100% - var(--coral-sizing-m, 2.25rem) * 2); - padding: var(--coral-sizing-m, 2.25rem) 0; -} -.stepper-form__header__title { - font: var(--coral-heading-l, 600 1.125rem/140% 'Source Sans Pro'); -} -.stepper-form__header__subtitle { - font: var(--coral-paragraph-m, 400 0.875rem/140% 'Source Sans Pro'); - color: var(--coral-color-neutral-text-weak, hsl(0, 0%, 38%)); -} -.stepper-form__steps { - display: flex; - height: fit-content; - padding-right: var(--coral-spacing-l, 1.75rem); - width: 12.5rem; -} -.stepper-form__container { - display: flex; - flex-direction: column; - flex: 1; - padding-right: var(--coral-spacing-l, 1.75rem); -} -.stepper-form__content { - display: flex; - flex: 1; - flex-direction: column; - height: 100%; - padding-top: var(--coral-spacing-l, 1.75rem); - overflow: hidden; -} -.stepper-form__footer { - display: flex; -} -.stepper-form__footer hr { - max-height: var(--coral-sizing-xxxs, 1rem); -} -.stepper-form__loading { - width: 50%; -} diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.types.js b/packages/stepper/libx/components/StepperForm/StepperForm.types.js deleted file mode 100644 index 74c0d087c9b..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.types.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=StepperForm.types.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.types.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.types.js.map deleted file mode 100644 index 84c51b288c4..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.utils.js b/packages/stepper/libx/components/StepperForm/StepperForm.utils.js deleted file mode 100644 index 346e25e1fad..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.utils.js +++ /dev/null @@ -1,26 +0,0 @@ -import { Stepper } from '@talend/design-system'; -const getStepComponent = (current, index, isDisabled = false) => { - if (isDisabled) { - return Stepper.Step.Disabled; - } else if (current === index) { - return Stepper.Step.InProgress; - } else if (current > index) { - return Stepper.Step.Validated; - } - return Stepper.Step.Enabled; -}; -const getStepperState = initialSteps => { - const steps = []; - initialSteps.forEach((step, index) => { - steps.push({ - ...step, - navigation: { - previous: index - 1 >= 0 ? initialSteps[index - 1].key : void 0, - next: index + 1 < initialSteps.length ? initialSteps[index + 1].key : void 0, - }, - }); - }); - return steps; -}; -export { getStepComponent, getStepperState }; -//# sourceMappingURL=StepperForm.utils.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map b/packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map deleted file mode 100644 index 3ea640a5ef3..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperForm.utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/components/StepperForm/StepperForm.utils.ts"],"sourcesContent":["import type { ElementType } from 'react';\n\nimport { Stepper } from '@talend/design-system';\nimport { StepperStep } from './StepperForm.types';\nimport { StepperState } from '../../hooks/useStepperForm/useStepperForm.types';\n\nexport const getStepComponent = (\n\tcurrent: number,\n\tindex: number,\n\tisDisabled = false,\n): ElementType => {\n\tif (isDisabled) {\n\t\treturn Stepper.Step.Disabled;\n\t} else if (current === index) {\n\t\treturn Stepper.Step.InProgress;\n\t} else if (current > index) {\n\t\treturn Stepper.Step.Validated;\n\t}\n\treturn Stepper.Step.Enabled;\n};\n\nexport const getStepperState = (initialSteps: StepperStep[]) => {\n\tconst steps: StepperState = [];\n\n\tinitialSteps.forEach((step: StepperStep, index: number) => {\n\t\tsteps.push({\n\t\t\t...step,\n\t\t\tnavigation: {\n\t\t\t\tprevious: index - 1 >= 0 ? initialSteps[index - 1].key : undefined,\n\t\t\t\tnext: index + 1 < initialSteps.length ? initialSteps[index + 1].key : undefined,\n\t\t\t},\n\t\t});\n\t});\n\n\treturn steps;\n};\n"],"mappings":"AAEA,SAAS,eAAe;AAIjB,MAAM,mBAAmB,CAC/B,SACA,OACA,aAAa,UACI;AACjB,MAAI,YAAY;AACf,WAAO,QAAQ,KAAK;AAAA,EACrB,WAAW,YAAY,OAAO;AAC7B,WAAO,QAAQ,KAAK;AAAA,EACrB,WAAW,UAAU,OAAO;AAC3B,WAAO,QAAQ,KAAK;AAAA,EACrB;AACA,SAAO,QAAQ,KAAK;AACrB;AAEO,MAAM,kBAAkB,CAAC,iBAAgC;AAC/D,QAAM,QAAsB,CAAC;AAE7B,eAAa,QAAQ,CAAC,MAAmB,UAAkB;AAC1D,UAAM,KAAK;AAAA,MACV,GAAG;AAAA,MACH,YAAY;AAAA,QACX,UAAU,QAAQ,KAAK,IAAI,aAAa,QAAQ,CAAC,EAAE,MAAM;AAAA,QACzD,MAAM,QAAQ,IAAI,aAAa,SAAS,aAAa,QAAQ,CAAC,EAAE,MAAM;AAAA,MACvE;AAAA,IACD,CAAC;AAAA,EACF,CAAC;AAED,SAAO;AACR;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js b/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js deleted file mode 100644 index a47454994ca..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js +++ /dev/null @@ -1,14 +0,0 @@ -import { jsx } from 'react/jsx-runtime'; -import StepperForm from '../StepperForm.component'; -import { StepperFormProvider } from '../StepperForm.context'; -const StepperFormContainer = ({ initialStepIndex, steps, onSubmit }) => { - return /* @__PURE__ */ jsx(StepperFormProvider, { - initialStepIndex, - steps, - onSubmit, - children: /* @__PURE__ */ jsx(StepperForm, {}), - }); -}; -StepperFormContainer.displayName = 'StepperFormContainer'; -export { StepperFormContainer }; -//# sourceMappingURL=StepperFormContainer.component.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map b/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map deleted file mode 100644 index ecfabca1673..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperFormContainer/StepperFormContainer.component.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../../src/components/StepperForm/StepperFormContainer/StepperFormContainer.component.tsx"],"sourcesContent":["import StepperForm from '../StepperForm.component';\nimport { StepperFormProvider } from '../StepperForm.context';\nimport { StepperStep } from '../StepperForm.types';\n\nexport interface StepperFormContainerProps {\n\tinitialStepIndex?: number;\n\tonSubmit: (currentStep: number) => void;\n\tsteps: StepperStep[];\n}\n\nexport const StepperFormContainer = ({\n\tinitialStepIndex,\n\tsteps,\n\tonSubmit,\n}: StepperFormContainerProps) => {\n\treturn (\n\t\t\n\t\t\t\n\t\t\n\t);\n};\n\nStepperFormContainer.displayName = 'StepperFormContainer';\n"],"mappings":"AAiBG;AAjBH,OAAO,iBAAiB;AACxB,SAAS,2BAA2B;AAS7B,MAAM,uBAAuB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACD,MAAiC;AAChC,SACC,oBAAC,uBAAoB,kBAAoC,OAAc,UACtE,8BAAC,eAAY,GACd;AAEF;AAEA,qBAAqB,cAAc;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js b/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js deleted file mode 100644 index a1e86c34967..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import { StepperFormContainer } from './StepperFormContainer.component'; -export { StepperFormContainer }; -//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map b/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map deleted file mode 100644 index 5fc01882edd..00000000000 --- a/packages/stepper/libx/components/StepperForm/StepperFormContainer/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../../src/components/StepperForm/StepperFormContainer/index.ts"],"sourcesContent":["export { StepperFormContainer } from './StepperFormContainer.component';\n"],"mappings":"AAAA,SAAS,4BAA4B;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/StepperForm/index.js b/packages/stepper/libx/components/StepperForm/index.js deleted file mode 100644 index 1a41ba4377c..00000000000 --- a/packages/stepper/libx/components/StepperForm/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { StepperFormContainer as StepperForm } from './StepperFormContainer'; -import { StepFooter } from './StepFooter'; -import { StepperFormProvider, StepperFormContext } from './StepperForm.context'; -const StepperFormComponent = StepperForm; -StepperFormComponent.Context = StepperFormContext; -StepperFormComponent.Provider = StepperFormProvider; -StepperFormComponent.Footer = StepFooter; -var StepperForm_default = StepperFormComponent; -export { StepperForm_default as default }; -//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/StepperForm/index.js.map b/packages/stepper/libx/components/StepperForm/index.js.map deleted file mode 100644 index 86df7cd4041..00000000000 --- a/packages/stepper/libx/components/StepperForm/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/components/StepperForm/index.ts"],"sourcesContent":["import { StepperFormContainer as StepperForm } from './StepperFormContainer';\nimport { StepFooter } from './StepFooter';\nimport { StepperFormProvider, StepperFormContext } from './StepperForm.context';\n\nconst StepperFormComponent = StepperForm as typeof StepperForm & {\n\tContext: typeof StepperFormContext;\n\tProvider: typeof StepperFormProvider;\n\tFooter: typeof StepFooter;\n};\n\nStepperFormComponent.Context = StepperFormContext;\nStepperFormComponent.Provider = StepperFormProvider;\nStepperFormComponent.Footer = StepFooter;\n\nexport default StepperFormComponent;\n"],"mappings":"AAAA,SAAS,wBAAwB,mBAAmB;AACpD,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB,0BAA0B;AAExD,MAAM,uBAAuB;AAM7B,qBAAqB,UAAU;AAC/B,qBAAqB,WAAW;AAChC,qBAAqB,SAAS;AAE9B,IAAO,sBAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/components/index.js b/packages/stepper/libx/components/index.js deleted file mode 100644 index 151bd576c5e..00000000000 --- a/packages/stepper/libx/components/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import { Stepper } from '@talend/react-components'; -var components_default = Stepper; -export { components_default as default }; -//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/components/index.js.map b/packages/stepper/libx/components/index.js.map deleted file mode 100644 index 28558f8ddf6..00000000000 --- a/packages/stepper/libx/components/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["import { Stepper } from '@talend/react-components';\n\nexport default Stepper;\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,IAAO,qBAAQ;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/constants/i18n.js b/packages/stepper/libx/constants/i18n.js deleted file mode 100644 index 3f3c29f44b2..00000000000 --- a/packages/stepper/libx/constants/i18n.js +++ /dev/null @@ -1,6 +0,0 @@ -const STEPPER_NAMESPACE = 'tui-stepper'; -var i18n_default = { - STEPPER_NAMESPACE, -}; -export { i18n_default as default }; -//# sourceMappingURL=i18n.js.map diff --git a/packages/stepper/libx/constants/i18n.js.map b/packages/stepper/libx/constants/i18n.js.map deleted file mode 100644 index c3f1681cd25..00000000000 --- a/packages/stepper/libx/constants/i18n.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/constants/i18n.ts"],"sourcesContent":["const STEPPER_NAMESPACE = 'tui-stepper';\n\nexport default {\n\tSTEPPER_NAMESPACE,\n};\n"],"mappings":"AAAA,MAAM,oBAAoB;AAE1B,IAAO,eAAQ;AAAA,EACd;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/containers/Stepper.connect.js b/packages/stepper/libx/containers/Stepper.connect.js deleted file mode 100644 index 918496197b2..00000000000 --- a/packages/stepper/libx/containers/Stepper.connect.js +++ /dev/null @@ -1,9 +0,0 @@ -import { connect } from 'react-redux'; -import Stepper from '@talend/react-components/lib/Stepper'; -import { getStepsForResource } from '../service/Stepper.selectors'; -const mapStateToProps = (state, ownProps) => ({ - steps: getStepsForResource(state, ownProps.resourceType, ownProps.resourceId), -}); -var Stepper_connect_default = connect(mapStateToProps)(Stepper); -export { Stepper_connect_default as default, mapStateToProps }; -//# sourceMappingURL=Stepper.connect.js.map diff --git a/packages/stepper/libx/containers/Stepper.connect.js.map b/packages/stepper/libx/containers/Stepper.connect.js.map deleted file mode 100644 index 57692b8afb6..00000000000 --- a/packages/stepper/libx/containers/Stepper.connect.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/containers/Stepper.connect.js"],"sourcesContent":["import { connect } from 'react-redux';\nimport Stepper from '@talend/react-components/lib/Stepper';\nimport { getStepsForResource } from '../service/Stepper.selectors';\n\nexport const mapStateToProps = (state, ownProps) => ({\n\tsteps: getStepsForResource(state, ownProps.resourceType, ownProps.resourceId),\n});\n\nexport default connect(mapStateToProps)(Stepper);\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,OAAO,aAAa;AACpB,SAAS,2BAA2B;AAE7B,MAAM,kBAAkB,CAAC,OAAO,cAAc;AAAA,EACpD,OAAO,oBAAoB,OAAO,SAAS,cAAc,SAAS,UAAU;AAC7E;AAEA,IAAO,0BAAQ,QAAQ,eAAe,EAAE,OAAO;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js deleted file mode 100644 index 884a9212616..00000000000 --- a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js +++ /dev/null @@ -1,105 +0,0 @@ -import { useState } from 'react'; -import { getStepperState } from '../../components/StepperForm/StepperForm.utils'; -import { NavigationDirection } from './useStepperForm.types'; -const handleStepChange = (state, navigation, direction) => { - const { from, to } = navigation; - const stepState = state.find(step => step.key === from); - if (!stepState) { - return state; - } - const newState = [...state]; - const index = state.indexOf(stepState); - newState[index].navigation = { - ...stepState.navigation, - ...(direction === NavigationDirection.NEXT ? { next: to } : { previous: to }), - }; - return newState; -}; -const disableStep = (state, stepKey, cause) => { - const stepState = state.find(step => step.key === stepKey); - if (!stepState) { - return state; - } - const nextStep = stepState.navigation?.next; - const previousStep = stepState.navigation?.previous; - const index = state.indexOf(stepState); - let newState = [...state]; - newState[index].navigation = { - ...stepState.navigation, - disableCause: cause, - }; - if (nextStep) { - newState = handleStepChange( - newState, - { from: nextStep, to: previousStep }, - NavigationDirection.PREVIOUS, - ); - } - if (previousStep) { - newState = handleStepChange( - newState, - { from: previousStep, to: nextStep }, - NavigationDirection.NEXT, - ); - } - return newState; -}; -const enableStep = (state, stepKey) => { - const stepState = state.find(step => step.key === stepKey); - if (!stepState) { - return state; - } - const nextStep = stepState.navigation?.next; - const previousStep = stepState.navigation?.previous; - const index = state.indexOf(stepState); - let newState = [...state]; - delete newState[index].navigation?.disableCause; - if (nextStep) { - newState = handleStepChange( - newState, - { from: nextStep, to: stepKey }, - NavigationDirection.PREVIOUS, - ); - } - if (previousStep) { - newState = handleStepChange( - newState, - { from: previousStep, to: stepKey }, - NavigationDirection.NEXT, - ); - } - return newState; -}; -const onChangeStep = (stepperState, stepKey) => { - const stepToGo = stepperState.find(step => step.key === stepKey); - if (stepToGo) { - return stepperState.indexOf(stepToGo); - } - return; -}; -const useStepperForm = (steps, stepIndex, onSubmit) => { - const [currentStep, setCurrentStep] = useState(stepIndex); - const [stepperSteps, setStepperSteps] = useState(getStepperState(steps)); - const currentNavigation = stepperSteps[currentStep].navigation; - return { - currentStep, - disableStep: (stepKey, cause) => setStepperSteps(disableStep(stepperSteps, stepKey, cause)), - enableStep: stepKey => setStepperSteps(enableStep(stepperSteps, stepKey)), - onNextStep: () => { - setCurrentStep( - (currentNavigation && onChangeStep(stepperSteps, currentNavigation.next)) ?? currentStep, - ); - if (!currentNavigation?.next) { - onSubmit(currentStep); - } - }, - onPreviousStep: () => - setCurrentStep( - (currentNavigation && onChangeStep(stepperSteps, currentNavigation.previous)) ?? - currentStep, - ), - stepperSteps, - }; -}; -export { useStepperForm }; -//# sourceMappingURL=useStepperForm.hook.js.map diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map deleted file mode 100644 index f528b4026d6..00000000000 --- a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.hook.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/hooks/useStepperForm/useStepperForm.hook.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { StepperStep } from '../../components/StepperForm/StepperForm.types';\nimport { getStepperState } from '../../components/StepperForm/StepperForm.utils';\nimport { NavigationDirection, NavigationStep, StepperState } from './useStepperForm.types';\n\nconst handleStepChange = (\n\tstate: StepperState,\n\tnavigation: NavigationStep,\n\tdirection: NavigationDirection,\n): StepperState => {\n\tconst { from, to } = navigation;\n\tconst stepState = state.find(step => step.key === from);\n\n\tif (!stepState) {\n\t\treturn state;\n\t}\n\n\tconst newState: StepperState = [...state];\n\tconst index = state.indexOf(stepState);\n\n\tnewState[index].navigation = {\n\t\t...stepState.navigation,\n\t\t...(direction === NavigationDirection.NEXT ? { next: to } : { previous: to }),\n\t};\n\n\treturn newState;\n};\n\nconst disableStep = (state: StepperState, stepKey: string, cause: string): StepperState => {\n\tconst stepState = state.find(step => step.key === stepKey);\n\n\tif (!stepState) {\n\t\treturn state;\n\t}\n\n\tconst nextStep = stepState.navigation?.next;\n\tconst previousStep = stepState.navigation?.previous;\n\tconst index = state.indexOf(stepState);\n\tlet newState: StepperState = [...state];\n\n\tnewState[index].navigation = {\n\t\t...stepState.navigation,\n\t\tdisableCause: cause,\n\t};\n\n\tif (nextStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: nextStep, to: previousStep },\n\t\t\tNavigationDirection.PREVIOUS,\n\t\t);\n\t}\n\n\tif (previousStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: previousStep, to: nextStep },\n\t\t\tNavigationDirection.NEXT,\n\t\t);\n\t}\n\n\treturn newState;\n};\n\nconst enableStep = (state: StepperState, stepKey: string): StepperState => {\n\tconst stepState = state.find(step => step.key === stepKey);\n\n\tif (!stepState) {\n\t\treturn state;\n\t}\n\n\tconst nextStep = stepState.navigation?.next;\n\tconst previousStep = stepState.navigation?.previous;\n\tconst index = state.indexOf(stepState);\n\tlet newState: StepperState = [...state];\n\n\tdelete newState[index].navigation?.disableCause;\n\n\tif (nextStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: nextStep, to: stepKey },\n\t\t\tNavigationDirection.PREVIOUS,\n\t\t);\n\t}\n\n\tif (previousStep) {\n\t\tnewState = handleStepChange(\n\t\t\tnewState,\n\t\t\t{ from: previousStep, to: stepKey },\n\t\t\tNavigationDirection.NEXT,\n\t\t);\n\t}\n\n\treturn newState;\n};\n\nconst onChangeStep = (stepperState: StepperState, stepKey?: string) => {\n\tconst stepToGo = stepperState.find(step => step.key === stepKey);\n\n\tif (stepToGo) {\n\t\treturn stepperState.indexOf(stepToGo);\n\t}\n\n\treturn;\n};\n\nexport const useStepperForm = (\n\tsteps: StepperStep[],\n\tstepIndex: number,\n\tonSubmit: (currentStep: number) => void,\n) => {\n\tconst [currentStep, setCurrentStep] = useState(stepIndex);\n\tconst [stepperSteps, setStepperSteps] = useState(getStepperState(steps));\n\n\tconst currentNavigation = stepperSteps[currentStep].navigation;\n\n\treturn {\n\t\tcurrentStep,\n\t\tdisableStep: (stepKey: string, cause: string) =>\n\t\t\tsetStepperSteps(disableStep(stepperSteps, stepKey, cause)),\n\n\t\tenableStep: (stepKey: string) => setStepperSteps(enableStep(stepperSteps, stepKey)),\n\t\tonNextStep: () => {\n\t\t\tsetCurrentStep(\n\t\t\t\t(currentNavigation && onChangeStep(stepperSteps, currentNavigation.next)) ?? currentStep,\n\t\t\t);\n\n\t\t\tif (!currentNavigation?.next) {\n\t\t\t\tonSubmit(currentStep);\n\t\t\t}\n\t\t},\n\t\tonPreviousStep: () =>\n\t\t\tsetCurrentStep(\n\t\t\t\t(currentNavigation && onChangeStep(stepperSteps, currentNavigation.previous)) ??\n\t\t\t\t\tcurrentStep,\n\t\t\t),\n\t\tstepperSteps,\n\t};\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AAGzB,SAAS,uBAAuB;AAChC,SAAS,2BAAyD;AAElE,MAAM,mBAAmB,CACxB,OACA,YACA,cACkB;AAClB,QAAM,EAAE,MAAM,GAAG,IAAI;AACrB,QAAM,YAAY,MAAM,KAAK,UAAQ,KAAK,QAAQ,IAAI;AAEtD,MAAI,CAAC,WAAW;AACf,WAAO;AAAA,EACR;AAEA,QAAM,WAAyB,CAAC,GAAG,KAAK;AACxC,QAAM,QAAQ,MAAM,QAAQ,SAAS;AAErC,WAAS,KAAK,EAAE,aAAa;AAAA,IAC5B,GAAG,UAAU;AAAA,IACb,GAAI,cAAc,oBAAoB,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,UAAU,GAAG;AAAA,EAC5E;AAEA,SAAO;AACR;AAEA,MAAM,cAAc,CAAC,OAAqB,SAAiB,UAAgC;AAC1F,QAAM,YAAY,MAAM,KAAK,UAAQ,KAAK,QAAQ,OAAO;AAEzD,MAAI,CAAC,WAAW;AACf,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,UAAU,YAAY;AACvC,QAAM,eAAe,UAAU,YAAY;AAC3C,QAAM,QAAQ,MAAM,QAAQ,SAAS;AACrC,MAAI,WAAyB,CAAC,GAAG,KAAK;AAEtC,WAAS,KAAK,EAAE,aAAa;AAAA,IAC5B,GAAG,UAAU;AAAA,IACb,cAAc;AA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AAO;AAAA,IACN;AAAA,IACA,aAAa,CAAC,SAAiB,UAC9B,gBAAgB,YAAY,cAAc,SAAS,KAAK,CAAC;AAAA,IAE1D,YAAY,CAAC,YAAoB,gBAAgB,WAAW,cAAc,OAAO,CAAC;AAAA,IAClF,YAAY,MAAM;AACjB;AAAA,SACE,qBAAqB,aAAa,cAAc,kBAAkB,IAAI,MAAM;AAAA,MAC9E;AAEA,UAAI,CAAC,mBAAmB,MAAM;AAC7B,iBAAS,WAAW;AAAA,MACrB;AAAA,IACD;AAAA,IACA,gBAAgB,MACf;AAAA,OACE,qBAAqB,aAAa,cAAc,kBAAkB,QAAQ,MAC1E;AAAA,IACF;AAAA,IACD;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js deleted file mode 100644 index c446eae5224..00000000000 --- a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js +++ /dev/null @@ -1,7 +0,0 @@ -var NavigationDirection = /* @__PURE__ */ (NavigationDirection2 => { - NavigationDirection2['NEXT'] = 'next'; - NavigationDirection2['PREVIOUS'] = 'previous'; - return NavigationDirection2; -})(NavigationDirection || {}); -export { NavigationDirection }; -//# sourceMappingURL=useStepperForm.types.js.map diff --git a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map b/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map deleted file mode 100644 index 51ce6fe1702..00000000000 --- a/packages/stepper/libx/hooks/useStepperForm/useStepperForm.types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../../src/hooks/useStepperForm/useStepperForm.types.ts"],"sourcesContent":["import { StepperStep, StepperStepNavigation } from '../../components/StepperForm/StepperForm.types';\n\nexport interface StepState extends StepperStep {\n\tnavigation?: StepperStepNavigation;\n}\n\nexport type StepperState = StepState[];\nexport type NavigationStep = { from: string; to?: string };\nexport enum NavigationDirection {\n\tNEXT = 'next',\n\tPREVIOUS = 'previous',\n}\n"],"mappings":"AAQO,IAAK,sBAAL,kBAAKA,yBAAL;AACN,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,cAAW;AAFA,SAAAA;AAAA,GAAA;","names":["NavigationDirection"]} \ No newline at end of file diff --git a/packages/stepper/libx/index.js b/packages/stepper/libx/index.js deleted file mode 100644 index 6a13d182f99..00000000000 --- a/packages/stepper/libx/index.js +++ /dev/null @@ -1,47 +0,0 @@ -import { Stepper } from '@talend/react-components'; -import * as constants from './Stepper.constants'; -import StepperForm from './components/StepperForm'; -import StepperContainer from './containers/Stepper.connect'; -import { useStepperForm } from './hooks/useStepperForm/useStepperForm.hook'; -import { initStepper, proceedLoadingEvent, removeStepper } from './service/Stepper.actions'; -import stepperReducer from './service/Stepper.reducer'; -import { getStepsForResource, isResourceLoading } from './service/Stepper.selectors'; -import { getStepperKey } from './service/Stepper.utils'; -const { isAllSuccessful, isStepsLoading, isErrorInSteps } = Stepper; -const cmfModule = { - id: 'dataset-stepper', - reducer: { - [constants.STATE_KEY]: stepperReducer, - }, -}; -const StepperActions = { - initStepper, - proceedLoadingEvent, - removeStepper, -}; -const StepperSelectors = { - getStepsForResource, - isResourceLoading, -}; -const StepperComponents = { - Stepper: StepperContainer, -}; -const StepperUtils = { - isAllSuccessful, - isErrorInSteps, - isStepsLoading, - getStepperKey, -}; -const StepperConstants = constants; -var index_default = { ...cmfModule }; -export { - StepperActions, - StepperComponents, - StepperConstants, - StepperForm, - StepperSelectors, - StepperUtils, - index_default as default, - useStepperForm, -}; -//# sourceMappingURL=index.js.map diff --git a/packages/stepper/libx/index.js.map b/packages/stepper/libx/index.js.map deleted file mode 100644 index 90a032c4875..00000000000 --- a/packages/stepper/libx/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Stepper } from '@talend/react-components';\n\nimport * as constants from './Stepper.constants';\nimport StepperForm from './components/StepperForm';\nimport StepperContainer from './containers/Stepper.connect';\nimport { useStepperForm } from './hooks/useStepperForm/useStepperForm.hook';\nimport { initStepper, proceedLoadingEvent, removeStepper } from './service/Stepper.actions';\nimport stepperReducer from './service/Stepper.reducer';\nimport { getStepsForResource, isResourceLoading } from './service/Stepper.selectors';\nimport { getStepperKey } from './service/Stepper.utils';\n\nconst { isAllSuccessful, isStepsLoading, isErrorInSteps } = Stepper;\n\nconst cmfModule = {\n\tid: 'dataset-stepper',\n\treducer: {\n\t\t[constants.STATE_KEY]: stepperReducer,\n\t},\n};\n\nexport const StepperActions = {\n\tinitStepper,\n\tproceedLoadingEvent,\n\tremoveStepper,\n};\n\nexport const StepperSelectors = {\n\tgetStepsForResource,\n\tisResourceLoading,\n};\n\nexport const StepperComponents = {\n\tStepper: StepperContainer,\n};\n\nexport const StepperUtils = {\n\tisAllSuccessful,\n\tisErrorInSteps,\n\tisStepsLoading,\n\tgetStepperKey,\n};\n\nexport const StepperConstants = constants;\n\nexport { StepperForm, useStepperForm };\nexport default { ...cmfModule };\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,YAAY,eAAe;AAC3B,OAAO,iBAAiB;AACxB,OAAO,sBAAsB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,aAAa,qBAAqB,qBAAqB;AAChE,OAAO,oBAAoB;AAC3B,SAAS,qBAAqB,yBAAyB;AACvD,SAAS,qBAAqB;AAE9B,MAAM,EAAE,iBAAiB,gBAAgB,eAAe,IAAI;AAE5D,MAAM,YAAY;AAAA,EACjB,IAAI;AAAA,EACJ,SAAS;AAAA,IACR,CAAC,UAAU,SAAS,GAAG;AAAA,EACxB;AACD;AAEO,MAAM,iBAAiB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA;AACD;AAEO,MAAM,oBAAoB;AAAA,EAChC,SAAS;AACV;AAEO,MAAM,eAAe;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,mBAAmB;AAGhC,IAAO,gBAAQ,EAAE,GAAG,UAAU;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.actions.js b/packages/stepper/libx/service/Stepper.actions.js deleted file mode 100644 index 09495e430c0..00000000000 --- a/packages/stepper/libx/service/Stepper.actions.js +++ /dev/null @@ -1,42 +0,0 @@ -import { - LOADING_STEPS_INIT, - LOADING_STEPS_PROCEED_EVENT, - LOADING_STEPS_REMOVE, -} from '../Stepper.constants'; -function checkResourceParameters(resourceType, resourceId) { - if (!resourceType) { - throw new Error('Stepper Reducer : resourceType should be present in the action'); - } - if (!resourceId) { - throw new Error('Stepper Reducer : resourceId should be present in the action'); - } -} -function initStepper(resourceType, resourceId, steps = []) { - checkResourceParameters(resourceType, resourceId); - return { - type: LOADING_STEPS_INIT, - resourceType, - resourceId, - steps, - }; -} -function proceedLoadingEvent(resourceType, resourceId, event, messageLabel) { - checkResourceParameters(resourceType, resourceId); - return { - type: LOADING_STEPS_PROCEED_EVENT, - resourceType, - resourceId, - event, - message: { label: messageLabel }, - }; -} -function removeStepper(resourceType, resourceId) { - checkResourceParameters(resourceType, resourceId); - return { - type: LOADING_STEPS_REMOVE, - resourceType, - resourceId, - }; -} -export { initStepper, proceedLoadingEvent, removeStepper }; -//# sourceMappingURL=Stepper.actions.js.map diff --git a/packages/stepper/libx/service/Stepper.actions.js.map b/packages/stepper/libx/service/Stepper.actions.js.map deleted file mode 100644 index f1a6cf065a4..00000000000 --- a/packages/stepper/libx/service/Stepper.actions.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/service/Stepper.actions.js"],"sourcesContent":["import {\n\tLOADING_STEPS_INIT,\n\tLOADING_STEPS_PROCEED_EVENT,\n\tLOADING_STEPS_REMOVE,\n} from '../Stepper.constants';\n\nfunction checkResourceParameters(resourceType, resourceId) {\n\tif (!resourceType) {\n\t\tthrow new Error('Stepper Reducer : resourceType should be present in the action');\n\t}\n\tif (!resourceId) {\n\t\tthrow new Error('Stepper Reducer : resourceId should be present in the action');\n\t}\n}\n\n/**\n * This function init the store for some loading steps component\n * @param {string} resourceType the resource type we load\n * @param {string} resourceId the id of the resource we load\n * @param {array} steps the steps we have to load\n */\nexport function initStepper(resourceType, resourceId, steps = []) {\n\tcheckResourceParameters(resourceType, resourceId);\n\treturn {\n\t\ttype: LOADING_STEPS_INIT,\n\t\tresourceType,\n\t\tresourceId,\n\t\tsteps,\n\t};\n}\n\n/**\n * This function generate an action to tell the loading that we have\n * intercept some event to proceed in the loading process\n * @param {string} resourceType the resource type we load\n * @param {string} resourceId the id of the resource we load\n * @param {string} event event catch\n */\nexport function proceedLoadingEvent(resourceType, resourceId, event, messageLabel) {\n\tcheckResourceParameters(resourceType, resourceId);\n\treturn {\n\t\ttype: LOADING_STEPS_PROCEED_EVENT,\n\t\tresourceType,\n\t\tresourceId,\n\t\tevent,\n\t\tmessage: { label: messageLabel },\n\t};\n}\n\n/**\n * This function return an action to remove a loading from the store\n * @param {string} resourceType the resource type we load\n * @param {string} resourceId the id of the resource we load\n */\nexport function removeStepper(resourceType, resourceId) {\n\tcheckResourceParameters(resourceType, resourceId);\n\treturn {\n\t\ttype: LOADING_STEPS_REMOVE,\n\t\tresourceType,\n\t\tresourceId,\n\t};\n}\n"],"mappings":"AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,wBAAwB,cAAc,YAAY;AAC1D,MAAI,CAAC,cAAc;AAClB,UAAM,IAAI,MAAM,gEAAgE;AAAA,EACjF;AACA,MAAI,CAAC,YAAY;AAChB,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAC/E;AACD;AAQO,SAAS,YAAY,cAAc,YAAY,QAAQ,CAAC,GAAG;AACjE,0BAAwB,cAAc,UAAU;AAChD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AASO,SAAS,oBAAoB,cAAc,YAAY,OAAO,cAAc;AAClF,0BAAwB,cAAc,UAAU;AAChD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,EAAE,OAAO,aAAa;AAAA,EAChC;AACD;AAOO,SAAS,cAAc,cAAc,YAAY;AACvD,0BAAwB,cAAc,UAAU;AAChD,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.reducer.js b/packages/stepper/libx/service/Stepper.reducer.js deleted file mode 100644 index 9057c52c5a3..00000000000 --- a/packages/stepper/libx/service/Stepper.reducer.js +++ /dev/null @@ -1,119 +0,0 @@ -import omit from 'lodash/omit'; -import get from 'lodash/get'; -import invariant from 'invariant'; -import Stepper from '@talend/react-components/lib/Stepper'; -import { - LOADING_STEP_STATUSES, - initialState, - LOADING_STEPS_INIT, - LOADING_STEPS_REMOVE, - LOADING_STEPS_PROCEED_EVENT, -} from '../Stepper.constants'; -import { getStepperKey } from './Stepper.utils'; -const isInStepAttribute = (stepAttribute, value) => - (typeof stepAttribute === 'string' && stepAttribute === value) || - (Array.isArray(stepAttribute) && stepAttribute.includes(value)); -const checkAttribute = attributeName => (step, event) => - isInStepAttribute(step[attributeName], event); -const isEventTriggerFail = checkAttribute('failureOn'); -const isEventTriggerSuccess = checkAttribute('successOn'); -const isEventTriggerLoading = checkAttribute('loadingOn'); -function mapStepWithNoError(step, action) { - if (isEventTriggerSuccess(step, action.event)) { - return { - ...step, - status: LOADING_STEP_STATUSES.SUCCESS, - }; - } - if (isEventTriggerLoading(step, action.event) && step.status !== LOADING_STEP_STATUSES.SUCCESS) { - return { - ...step, - status: LOADING_STEP_STATUSES.LOADING, - }; - } - return step; -} -function getNewStepsWithError(steps, action) { - let errorHandled = false; - return steps.map(step => { - if (step.status !== LOADING_STEP_STATUSES.SUCCESS) { - if (!errorHandled && isEventTriggerFail(step, action.event)) { - errorHandled = true; - return { - ...step, - status: LOADING_STEP_STATUSES.FAILURE, - message: action.message, - }; - } - return { - ...step, - status: LOADING_STEP_STATUSES.ABORTED, - }; - } - return step; - }); -} -const hasAttribute = (step, attribute) => - step[attribute] || (Array.isArray(step[attribute]) && step[attribute].length > 0); -const hasStepFailure = step => hasAttribute(step, 'failureOn'); -const hasStepSuccess = step => hasAttribute(step, 'successOn'); -const hasStepLoading = step => hasAttribute(step, 'loadingOn'); -function checkSteps(steps) { - return steps.map(step => { - if (!hasStepFailure(step)) { - invariant( - process.env.NODE_ENV === 'production', - `Stepper : No failureOn step for ${step.label} step`, - ); - } - if (!hasStepSuccess(step)) { - invariant( - process.env.NODE_ENV === 'production', - `Stepper : No successOn step for ${step.label} step`, - ); - } - if (!hasStepLoading(step) && !step.status) { - invariant( - process.env.NODE_ENV === 'production', - `Stepper : No loadingOn step or initial status for ${step.label} step`, - ); - } - if (!step.status) { - return { ...step, status: LOADING_STEP_STATUSES.PENDING }; - } - return step; - }); -} -function handleEvent(state, action) { - const loadingKey = getStepperKey(action); - const loadingResource = get(state, [loadingKey], {}); - const steps = get(loadingResource, 'steps', []); - if (!Stepper.isStepsLoading(steps)) { - return state; - } - const isErrorTriggered = !!steps.find(step => isInStepAttribute(step.failureOn, action.event)); - let newSteps; - if (isErrorTriggered) { - newSteps = getNewStepsWithError(steps, action); - } else { - newSteps = steps.map(step => mapStepWithNoError(step, action)); - } - return { - ...state, - [loadingKey]: { ...loadingResource, steps: newSteps }, - }; -} -function stepperReducer(state = initialState, action) { - switch (action.type) { - case LOADING_STEPS_INIT: - return { ...state, [getStepperKey(action)]: { steps: checkSteps(action.steps) } }; - case LOADING_STEPS_REMOVE: - return omit(state, getStepperKey(action)); - case LOADING_STEPS_PROCEED_EVENT: - return handleEvent(state, action); - default: - return state; - } -} -export { stepperReducer as default }; -//# sourceMappingURL=Stepper.reducer.js.map diff --git a/packages/stepper/libx/service/Stepper.reducer.js.map b/packages/stepper/libx/service/Stepper.reducer.js.map deleted file mode 100644 index d81d527ff9a..00000000000 --- a/packages/stepper/libx/service/Stepper.reducer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/service/Stepper.reducer.js"],"sourcesContent":["import omit from 'lodash/omit';\nimport get from 'lodash/get';\nimport invariant from 'invariant';\nimport Stepper from '@talend/react-components/lib/Stepper';\nimport {\n\tLOADING_STEP_STATUSES,\n\tinitialState,\n\tLOADING_STEPS_INIT,\n\tLOADING_STEPS_REMOVE,\n\tLOADING_STEPS_PROCEED_EVENT,\n} from '../Stepper.constants';\nimport { getStepperKey } from './Stepper.utils';\n\nconst isInStepAttribute = (stepAttribute, value) =>\n\t(typeof stepAttribute === 'string' && stepAttribute === value) ||\n\t(Array.isArray(stepAttribute) && stepAttribute.includes(value));\n\nconst checkAttribute = attributeName => (step, event) =>\n\tisInStepAttribute(step[attributeName], event);\n\nconst isEventTriggerFail = checkAttribute('failureOn');\nconst isEventTriggerSuccess = checkAttribute('successOn');\nconst isEventTriggerLoading = checkAttribute('loadingOn');\n\nfunction mapStepWithNoError(step, action) {\n\tif (isEventTriggerSuccess(step, action.event)) {\n\t\treturn {\n\t\t\t...step,\n\t\t\tstatus: LOADING_STEP_STATUSES.SUCCESS,\n\t\t};\n\t}\n\tif (isEventTriggerLoading(step, action.event) && step.status !== LOADING_STEP_STATUSES.SUCCESS) {\n\t\treturn {\n\t\t\t...step,\n\t\t\tstatus: LOADING_STEP_STATUSES.LOADING,\n\t\t};\n\t}\n\treturn step;\n}\n\nfunction getNewStepsWithError(steps, action) {\n\tlet errorHandled = false;\n\treturn steps.map(step => {\n\t\tif (step.status !== LOADING_STEP_STATUSES.SUCCESS) {\n\t\t\tif (!errorHandled && isEventTriggerFail(step, action.event)) {\n\t\t\t\terrorHandled = true;\n\t\t\t\treturn {\n\t\t\t\t\t...step,\n\t\t\t\t\tstatus: LOADING_STEP_STATUSES.FAILURE,\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...step,\n\t\t\t\tstatus: LOADING_STEP_STATUSES.ABORTED,\n\t\t\t};\n\t\t}\n\t\treturn step;\n\t});\n}\n\nconst hasAttribute = (step, attribute) =>\n\tstep[attribute] || (Array.isArray(step[attribute]) && step[attribute].length > 0);\n\nconst hasStepFailure = step => hasAttribute(step, 'failureOn');\nconst hasStepSuccess = step => hasAttribute(step, 'successOn');\nconst hasStepLoading = step => hasAttribute(step, 'loadingOn');\n\n/**\n * This function check & mutate the steps\n * @param {array} steps the loading steps\n */\nfunction checkSteps(steps) {\n\treturn steps.map(step => {\n\t\tif (!hasStepFailure(step)) {\n\t\t\tinvariant(\n\t\t\t\tprocess.env.NODE_ENV === 'production',\n\t\t\t\t`Stepper : No failureOn step for ${step.label} step`,\n\t\t\t);\n\t\t}\n\t\tif (!hasStepSuccess(step)) {\n\t\t\tinvariant(\n\t\t\t\tprocess.env.NODE_ENV === 'production',\n\t\t\t\t`Stepper : No successOn step for ${step.label} step`,\n\t\t\t);\n\t\t}\n\t\tif (!hasStepLoading(step) && !step.status) {\n\t\t\tinvariant(\n\t\t\t\tprocess.env.NODE_ENV === 'production',\n\t\t\t\t`Stepper : No loadingOn step or initial status for ${step.label} step`,\n\t\t\t);\n\t\t}\n\t\tif (!step.status) {\n\t\t\treturn { ...step, status: LOADING_STEP_STATUSES.PENDING };\n\t\t}\n\t\treturn step;\n\t});\n}\n\n/**\n * This function change the status of the steps in order to reflect the event\n * @param {object} state redux state\n * @param {object} action the redux action\n */\nfunction handleEvent(state, action) {\n\tconst loadingKey = getStepperKey(action);\n\tconst loadingResource = get(state, [loadingKey], {});\n\tconst steps = get(loadingResource, 'steps', []);\n\tif (!Stepper.isStepsLoading(steps)) {\n\t\treturn state;\n\t}\n\tconst isErrorTriggered = !!steps.find(step => isInStepAttribute(step.failureOn, action.event));\n\tlet newSteps;\n\tif (isErrorTriggered) {\n\t\tnewSteps = getNewStepsWithError(steps, action);\n\t} else {\n\t\tnewSteps = steps.map(step => mapStepWithNoError(step, action));\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[loadingKey]: { ...loadingResource, steps: newSteps },\n\t};\n}\n\n/**\n * This function is a classic reducer\n * It handle the Loading Steps of a resource\n * @param {object} state Redux state\n * @param {object} action Redux Action\n */\nexport default function stepperReducer(state = initialState, action) {\n\tswitch (action.type) {\n\t\tcase LOADING_STEPS_INIT:\n\t\t\treturn { ...state, [getStepperKey(action)]: { steps: checkSteps(action.steps) } };\n\t\tcase LOADING_STEPS_REMOVE:\n\t\t\treturn omit(state, getStepperKey(action));\n\t\tcase LOADING_STEPS_PROCEED_EVENT:\n\t\t\treturn handleEvent(state, action);\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n"],"mappings":"AAAA,OAAO,UAAU;AACjB,OAAO,SAAS;AAChB,OAAO,eAAe;AACtB,OAAO,aAAa;AACpB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,qBAAqB;AAE9B,MAAM,oBAAoB,CAAC,eAAe,UACxC,OAAO,kBAAkB,YAAY,kBAAkB,SACvD,MAAM,QAAQ,aAAa,KAAK,cAAc,SAAS,KAAK;AAE9D,MAAM,iBAAiB,mBAAiB,CAAC,MAAM,UAC9C,kBAAkB,KAAK,aAAa,GAAG,KAAK;AAE7C,MAAM,qBAAqB,eAAe,WAAW;AACrD,MAAM,wBAAwB,eAAe,WAAW;AACxD,MAAM,wBAAwB,eAAe,WAAW;AAExD,SAAS,mBAAmB,MAAM,QAAQ;AACzC,MAAI,sBAAsB,MAAM,OAAO,KAAK,GAAG;AAC9C,WAAO;AAAA,MACN,GAAG;AAAA,MACH,QAAQ,sBAAsB;AAAA,IAC/B;AAAA,EACD;AACA,MAAI,sBAAsB,MAAM,OAAO,KAAK,KAAK,KAAK,WAAW,sBAAsB,SAAS;AAC/F,WAAO;AAAA,MACN,GAAG;AAAA,MACH,QAAQ,sBAAsB;AAAA,IAC/B;AAAA,EACD;AACA,SAAO;AACR;AAEA,SAAS,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R,CAAC;AACF;AAOA,SAAS,YAAY,OAAO,QAAQ;AACnC,QAAM,aAAa,cAAc,MAAM;AACvC,QAAM,kBAAkB,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC;AACnD,QAAM,QAAQ,IAAI,iBAAiB,SAAS,CAAC,CAAC;AAC9C,MAAI,CAAC,QAAQ,eAAe,KAAK,GAAG;AACnC,WAAO;AAAA,EACR;AACA,QAAM,mBAAmB,CAAC,CAAC,MAAM,KAAK,UAAQ,kBAAkB,KAAK,WAAW,OAAO,KAAK,CAAC;AAC7F,MAAI;AACJ,MAAI,kBAAkB;AACrB,eAAW,qBAAqB,OAAO,MAAM;AAAA,EAC9C,OAAO;AACN,eAAW,MAAM,IAAI,UAAQ,mBAAmB,MAAM,MAAM,CAAC;AAAA,EAC9D;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAC,UAAU,GAAG,EAAE,GAAG,iBAAiB,OAAO,SAAS;AAAA,EACrD;AACD;AAQe,SAAR,eAAgC,QAAQ,cAAc,QAAQ;AACpE,UAAQ,OAAO,MAAM;AAAA,IACpB,KAAK;AACJ,aAAO,EAAE,GAAG,OAAO,CAAC,cAAc,MAAM,CAAC,GAAG,EAAE,OAAO,WAAW,OAAO,KAAK,EAAE,EAAE;AAAA,IACjF,KAAK;AACJ,aAAO,KAAK,OAAO,cAAc,MAAM,CAAC;AAAA,IACzC,KAAK;AACJ,aAAO,YAAY,OAAO,MAAM;AAAA,IACjC;AACC,aAAO;AAAA,EACT;AACD;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.selectors.js b/packages/stepper/libx/service/Stepper.selectors.js deleted file mode 100644 index 052d29b5350..00000000000 --- a/packages/stepper/libx/service/Stepper.selectors.js +++ /dev/null @@ -1,12 +0,0 @@ -import get from 'lodash/get'; -import Stepper from '@talend/react-components/lib/Stepper'; -import { STATE_KEY } from '../Stepper.constants'; -import { getStepperKey } from './Stepper.utils'; -function getStepsForResource(store, resourceType, resourceId) { - return get(store, [STATE_KEY, getStepperKey({ resourceType, resourceId }), 'steps'], []); -} -function isResourceLoading(store, resourceType, resourceId) { - return Stepper.isStepsLoading(getStepsForResource(store, resourceType, resourceId)); -} -export { getStepsForResource, isResourceLoading }; -//# sourceMappingURL=Stepper.selectors.js.map diff --git a/packages/stepper/libx/service/Stepper.selectors.js.map b/packages/stepper/libx/service/Stepper.selectors.js.map deleted file mode 100644 index e9fa235d655..00000000000 --- a/packages/stepper/libx/service/Stepper.selectors.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/service/Stepper.selectors.js"],"sourcesContent":["import get from 'lodash/get';\nimport Stepper from '@talend/react-components/lib/Stepper';\nimport { STATE_KEY } from '../Stepper.constants';\nimport { getStepperKey } from './Stepper.utils';\n\nexport function getStepsForResource(store, resourceType, resourceId) {\n\treturn get(store, [STATE_KEY, getStepperKey({ resourceType, resourceId }), 'steps'], []);\n}\n\nexport function isResourceLoading(store, resourceType, resourceId) {\n\treturn Stepper.isStepsLoading(getStepsForResource(store, resourceType, resourceId));\n}\n"],"mappings":"AAAA,OAAO,SAAS;AAChB,OAAO,aAAa;AACpB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAEvB,SAAS,oBAAoB,OAAO,cAAc,YAAY;AACpE,SAAO,IAAI,OAAO,CAAC,WAAW,cAAc,EAAE,cAAc,WAAW,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC;AACxF;AAEO,SAAS,kBAAkB,OAAO,cAAc,YAAY;AAClE,SAAO,QAAQ,eAAe,oBAAoB,OAAO,cAAc,UAAU,CAAC;AACnF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/service/Stepper.utils.js b/packages/stepper/libx/service/Stepper.utils.js deleted file mode 100644 index 6f9c0bf23f5..00000000000 --- a/packages/stepper/libx/service/Stepper.utils.js +++ /dev/null @@ -1,3 +0,0 @@ -const getStepperKey = action => `${action.resourceType}-${action.resourceId}`; -export { getStepperKey }; -//# sourceMappingURL=Stepper.utils.js.map diff --git a/packages/stepper/libx/service/Stepper.utils.js.map b/packages/stepper/libx/service/Stepper.utils.js.map deleted file mode 100644 index 82d2a5c7ee7..00000000000 --- a/packages/stepper/libx/service/Stepper.utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/service/Stepper.utils.js"],"sourcesContent":["/**\n * This function returns the key to point the loading step in the store\n * It's based on the resourceType / resourceId\n * internally usage only in the loading step service\n * @param {object} action redux action\n */\n// eslint-disable-next-line\nexport const getStepperKey = action => `${action.resourceType}-${action.resourceId}`;\n"],"mappings":"AAOO,MAAM,gBAAgB,YAAU,GAAG,OAAO,YAAY,IAAI,OAAO,UAAU;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/stories/Stepper.components.js b/packages/stepper/libx/stories/Stepper.components.js deleted file mode 100644 index c494f4fcad9..00000000000 --- a/packages/stepper/libx/stories/Stepper.components.js +++ /dev/null @@ -1,186 +0,0 @@ -import { jsx, jsxs } from 'react/jsx-runtime'; -import { createContext, useContext, useEffect } from 'react'; -import { FormProvider, useController, useForm } from 'react-hook-form'; -import { Form, InlineMessageDestructive } from '@talend/design-system'; -import StepperForm from '../components/StepperForm'; -const BusinessContext = createContext({}); -const FormComponentStep1 = () => { - const { disableStep, enableStep, onNext } = useContext(StepperForm.Context); - const { stepsData, setStepsData } = useContext(BusinessContext); - const rhf = useForm({ - defaultValues: { ...stepsData[0] }, - }); - const { field, fieldState } = useController({ - control: rhf.control, - name: 'randomInput', - rules: { - required: true, - }, - }); - useEffect(() => { - const data = stepsData; - data[0] = { [field.name]: field.value }; - setStepsData(data); - }, [field]); - return /* @__PURE__ */ jsx(FormProvider, { - ...rhf, - children: /* @__PURE__ */ jsxs(Form, { - children: [ - /* @__PURE__ */ jsxs(Form.Fieldset, { - children: [ - /* @__PURE__ */ jsx(Form.Checkbox, { - id: 'disable1', - name: 'disable-steps', - label: 'Disable step 2', - onChange: e => { - if (e.target.checked) { - disableStep('STEP2', 'Disabled cause'); - } else { - enableStep('STEP2'); - } - }, - }), - /* @__PURE__ */ jsx(Form.Checkbox, { - id: 'disable2', - name: 'disable-steps', - label: 'Disable step 3', - onChange: e => { - if (e.target.checked) { - disableStep('STEP3', 'Just because'); - } else { - enableStep('STEP3'); - } - }, - }), - fieldState.invalid && - /* @__PURE__ */ jsx(InlineMessageDestructive, { - description: 'This field is required', - withBackground: true, - }), - /* @__PURE__ */ jsx(Form.Input, { - id: 'randomInput', - label: 'Random input', - name: field.name, - onChange: e => { - field.onChange(e); - }, - value: field.value, - }), - ], - }), - /* @__PURE__ */ jsx(StepperForm.Footer, { - onCancel: () => alert('Cancel action'), - onNext: () => rhf.handleSubmit(onNext)(), - }), - ], - }), - }); -}; -const FormComponentStep2 = () => { - const { disableStep, enableStep, onNext, onPrevious } = useContext(StepperForm.Context); - const { stepsData, setStepsData } = useContext(BusinessContext); - const rhf = useForm({ - defaultValues: { ...stepsData[1] }, - }); - const { field, fieldState } = useController({ - control: rhf.control, - name: 'randomInput', - rules: { - required: true, - }, - }); - useEffect(() => { - const data = stepsData; - data[1] = { [field.name]: field.value }; - setStepsData(data); - }, [field]); - return /* @__PURE__ */ jsx(FormProvider, { - ...rhf, - children: /* @__PURE__ */ jsxs(Form, { - children: [ - /* @__PURE__ */ jsxs(Form.Fieldset, { - children: [ - /* @__PURE__ */ jsx(Form.Checkbox, { - id: 'disable1', - name: 'disable-steps', - label: 'Disable step 3', - onChange: e => { - if (e.target.checked) { - disableStep('STEP3', 'Disabled cause'); - } else { - enableStep('STEP3'); - } - }, - }), - fieldState.invalid && - /* @__PURE__ */ jsx(InlineMessageDestructive, { - description: 'This field is required', - withBackground: true, - }), - /* @__PURE__ */ jsx(Form.Input, { - id: 'randomInput', - label: 'Random input', - name: field.name, - onChange: field.onChange, - value: field.value, - }), - ], - }), - /* @__PURE__ */ jsx(StepperForm.Footer, { - onCancel: () => alert('Cancel action'), - onNext: () => rhf.handleSubmit(onNext)(), - onPrevious, - }), - ], - }), - }); -}; -const FormComponentStep3 = () => { - const { onNext, onPrevious } = useContext(StepperForm.Context); - const { stepsData, setStepsData } = useContext(BusinessContext); - const rhf = useForm({ - defaultValues: { ...stepsData[2] }, - }); - const { field, fieldState } = useController({ - control: rhf.control, - name: 'randomInput', - rules: { - required: true, - }, - }); - useEffect(() => { - const data = stepsData; - data[2] = { [field.name]: field.value }; - setStepsData(data); - }, [field]); - return /* @__PURE__ */ jsx(FormProvider, { - ...rhf, - children: /* @__PURE__ */ jsxs(Form, { - children: [ - /* @__PURE__ */ jsxs(Form.Fieldset, { - children: [ - fieldState.invalid && - /* @__PURE__ */ jsx(InlineMessageDestructive, { - description: 'This field is required', - withBackground: true, - }), - /* @__PURE__ */ jsx(Form.Input, { - id: 'randomInput', - label: 'Random input', - name: field.name, - onChange: field.onChange, - value: field.value, - }), - ], - }), - /* @__PURE__ */ jsx(StepperForm.Footer, { - onCancel: () => alert('Cancel action'), - onNext: () => rhf.handleSubmit(onNext)(), - onPrevious, - }), - ], - }), - }); -}; -export { BusinessContext, FormComponentStep1, FormComponentStep2, FormComponentStep3 }; -//# sourceMappingURL=Stepper.components.js.map diff --git a/packages/stepper/libx/stories/Stepper.components.js.map b/packages/stepper/libx/stories/Stepper.components.js.map deleted file mode 100644 index 5d764ed9f78..00000000000 --- a/packages/stepper/libx/stories/Stepper.components.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../../src/stories/Stepper.components.tsx"],"sourcesContent":["import { createContext, useContext, useEffect } from 'react';\nimport { FormProvider, useController, useForm } from 'react-hook-form';\n\nimport { Form, InlineMessageDestructive } from '@talend/design-system';\n\nimport StepperForm from '../components/StepperForm';\n\ninterface BusinessContextApi {\n\tsetStepsData: (stepData: any) => void;\n\tstepsData: any[];\n}\n\nexport const BusinessContext = createContext({} as BusinessContextApi);\n\nexport const FormComponentStep1 = () => {\n\tconst { disableStep, enableStep, onNext } = useContext(StepperForm.Context);\n\tconst { stepsData, setStepsData } = useContext(BusinessContext);\n\n\tconst rhf = useForm({\n\t\tdefaultValues: { ...stepsData[0] },\n\t});\n\n\tconst { field, fieldState } = useController({\n\t\tcontrol: rhf.control,\n\t\tname: 'randomInput',\n\t\trules: {\n\t\t\trequired: true,\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst data = stepsData;\n\t\tdata[0] = { [field.name]: field.value };\n\t\tsetStepsData(data);\n\t}, [field]);\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (e.target.checked) {\n\t\t\t\t\t\t\t\tdisableStep('STEP2', 'Disabled cause');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableStep('STEP2');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (e.target.checked) {\n\t\t\t\t\t\t\t\tdisableStep('STEP3', 'Just because');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableStep('STEP3');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{fieldState.invalid && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\t {\n\t\t\t\t\t\t\tfield.onChange(e);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tvalue={field.value}\n\t\t\t\t\t/>\n\t\t\t\t\n\t\t\t\t alert('Cancel action')}\n\t\t\t\t\tonNext={() => rhf.handleSubmit(onNext)()}\n\t\t\t\t/>\n\t\t\t\n\t\t
\n\t);\n};\n\nexport const FormComponentStep2 = () => {\n\tconst { disableStep, enableStep, onNext, onPrevious } = useContext(StepperForm.Context);\n\tconst { stepsData, setStepsData } = useContext(BusinessContext);\n\n\tconst rhf = useForm<{ randomInput: string }>({\n\t\tdefaultValues: { ...stepsData[1] },\n\t});\n\n\tconst { field, fieldState } = useController({\n\t\tcontrol: rhf.control,\n\t\tname: 'randomInput',\n\t\trules: {\n\t\t\trequired: true,\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst data = stepsData;\n\t\tdata[1] = { [field.name]: field.value };\n\t\tsetStepsData(data);\n\t}, [field]);\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\tif (e.target.checked) {\n\t\t\t\t\t\t\t\tdisableStep('STEP3', 'Disabled cause');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableStep('STEP3');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{fieldState.invalid && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t alert('Cancel action')}\n\t\t\t\t\tonNext={() => rhf.handleSubmit(onNext)()}\n\t\t\t\t\tonPrevious={onPrevious}\n\t\t\t\t/>\n\t\t\t\n\t\t
\n\t);\n};\n\nexport const FormComponentStep3 = () => {\n\tconst { onNext, onPrevious } = useContext(StepperForm.Context);\n\tconst { stepsData, setStepsData } = useContext(BusinessContext);\n\n\tconst rhf = useForm<{ randomInput: string }>({\n\t\tdefaultValues: { ...stepsData[2] },\n\t});\n\n\tconst { field, fieldState } = useController({\n\t\tcontrol: rhf.control,\n\t\tname: 'randomInput',\n\t\trules: {\n\t\t\trequired: true,\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst data = stepsData;\n\t\tdata[2] = { [field.name]: field.value };\n\t\tsetStepsData(data);\n\t}, [field]);\n\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t{fieldState.invalid && (\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t alert('Cancel action')}\n\t\t\t\t\tonNext={() => rhf.handleSubmit(onNext)()}\n\t\t\t\t\tonPrevious={onPrevious}\n\t\t\t\t/>\n\t\t\t\n\t\t
\n\t);\n};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,QAAL;AAAA,UACA,IAAG;AAAA,UACH,OAAM;AAAA,UACN,MAAM,MAAM;AAAA,UACZ,UAAU,MAAM;AAAA,UAChB,OAAO,MAAM;AAAA;AAAA,MACd;AAAA,OACD;AAAA,IACA;AAAA,MAAC,YAAY;AAAA,MAAZ;AAAA,QACA,UAAU,MAAM,MAAM,eAAe;AAAA,QACrC,QAAQ,MAAM,IAAI,aAAa,MAAM,EAAE;AAAA,QACvC;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;","names":[]} \ No newline at end of file diff --git a/packages/stepper/libx/translate.js b/packages/stepper/libx/translate.js deleted file mode 100644 index 5e1fd4f589a..00000000000 --- a/packages/stepper/libx/translate.js +++ /dev/null @@ -1,11 +0,0 @@ -import i18next from 'i18next'; -import { setI18n, getI18n } from 'react-i18next'; -function getDefaultT() { - return getI18n().t.bind(getI18n()); -} -if (!getI18n()) { - console.warn('@talend/react-stepper used without i18n host.'); - setI18n(i18next.createInstance({}, () => {})); -} -export { getDefaultT as default }; -//# sourceMappingURL=translate.js.map diff --git a/packages/stepper/libx/translate.js.map b/packages/stepper/libx/translate.js.map deleted file mode 100644 index 3c7ce19ab37..00000000000 --- a/packages/stepper/libx/translate.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/translate.js"],"sourcesContent":["import i18next from 'i18next';\nimport { setI18n, getI18n } from 'react-i18next';\n\nexport default function getDefaultT() {\n\treturn getI18n().t.bind(getI18n());\n}\n\nif (!getI18n()) {\n\t// eslint-disable-next-line no-console\n\tconsole.warn('@talend/react-stepper used without i18n host.');\n\tsetI18n(i18next.createInstance({}, () => {}));\n}\n"],"mappings":"AAAA,OAAO,aAAa;AACpB,SAAS,SAAS,eAAe;AAElB,SAAR,cAA+B;AACrC,SAAO,QAAQ,EAAE,EAAE,KAAK,QAAQ,CAAC;AAClC;AAEA,IAAI,CAAC,QAAQ,GAAG;AAEf,UAAQ,KAAK,+CAA+C;AAC5D,UAAQ,QAAQ,eAAe,CAAC,GAAG,MAAM;AAAA,EAAC,CAAC,CAAC;AAC7C;","names":[]} \ No newline at end of file diff --git a/packages/stepper/package.json b/packages/stepper/package.json index f42f8e4f3f4..49a67253946 100644 --- a/packages/stepper/package.json +++ b/packages/stepper/package.json @@ -54,6 +54,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/icons": "^8.0.0", diff --git a/packages/storybook-cmf/package.json b/packages/storybook-cmf/package.json index 681c383bf4d..51a995ecbbc 100644 --- a/packages/storybook-cmf/package.json +++ b/packages/storybook-cmf/package.json @@ -36,6 +36,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@vitejs/plugin-react": "^5.1.4", "@vitest/coverage-v8": "^4.0.18", "@talend/eslint-config": "^14.1.2", diff --git a/packages/storybook-docs/package.json b/packages/storybook-docs/package.json index e9a375a1dac..fdaeb6932bf 100644 --- a/packages/storybook-docs/package.json +++ b/packages/storybook-docs/package.json @@ -42,6 +42,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@figma/rest-api-spec": "^0.36.0", "@storybook/addon-a11y": "^10.2.1", "@storybook/react-vite": "^10.2.1", diff --git a/packages/utils/package.json b/packages/utils/package.json index 19ce09c8a2c..5b4368b95ca 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -35,6 +35,7 @@ }, "devDependencies": { "@talend/scripts-config-tsup": "^1.0.0", + "tsup": "^8.3.0", "@talend/eslint-config": "^14.1.2", "@talend/eslint-plugin": "^1.8.1", "@talend/scripts-core": "^20.0.0", From 8454b550c5006d021c7dece1c2fe479e78fc121a Mon Sep 17 00:00:00 2001 From: Jean-Michel FRANCOIS Date: Wed, 11 Mar 2026 12:01:31 +0100 Subject: [PATCH 3/3] chore: drop libx --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ed9f9e57949..f03ab8513e1 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,8 @@ build/ tmp/ lib/ lib-esm/ +libx/ +libx-esm/ storybook-static/ dist/ eslint-report.json