@caspeco/casper-ui-library 8.0.2 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +25 -1
  2. package/dist/components/accordion/accordion.visual.test.d.ts +2 -0
  3. package/dist/components/accordion/accordion.visual.test.d.ts.map +1 -0
  4. package/dist/components/alert/alert.visual.test.d.ts +2 -0
  5. package/dist/components/alert/alert.visual.test.d.ts.map +1 -0
  6. package/dist/components/badge/badge.visual.test.d.ts +2 -0
  7. package/dist/components/badge/badge.visual.test.d.ts.map +1 -0
  8. package/dist/components/box/box.visual.test.d.ts +2 -0
  9. package/dist/components/box/box.visual.test.d.ts.map +1 -0
  10. package/dist/components/breadcrumbs/breadcrumbs.visual.test.d.ts +2 -0
  11. package/dist/components/breadcrumbs/breadcrumbs.visual.test.d.ts.map +1 -0
  12. package/dist/components/button/button.visual.test.d.ts +2 -0
  13. package/dist/components/button/button.visual.test.d.ts.map +1 -0
  14. package/dist/components/checkbox/checkbox.visual.test.d.ts +2 -0
  15. package/dist/components/checkbox/checkbox.visual.test.d.ts.map +1 -0
  16. package/dist/components/checkbox-group/checkbox-group.visual.test.d.ts +2 -0
  17. package/dist/components/checkbox-group/checkbox-group.visual.test.d.ts.map +1 -0
  18. package/dist/components/combobox/combobox-item.d.ts +2 -1
  19. package/dist/components/combobox/combobox-item.d.ts.map +1 -1
  20. package/dist/components/combobox/combobox-item.js +12 -11
  21. package/dist/components/combobox/combobox-menu.d.ts +1 -1
  22. package/dist/components/combobox/combobox-menu.d.ts.map +1 -1
  23. package/dist/components/combobox/combobox-menu.js +250 -169
  24. package/dist/components/combobox/combobox.composition.d.ts +1 -0
  25. package/dist/components/combobox/combobox.composition.d.ts.map +1 -1
  26. package/dist/components/combobox/combobox.d.ts +1 -1
  27. package/dist/components/combobox/combobox.d.ts.map +1 -1
  28. package/dist/components/combobox/combobox.js +187 -148
  29. package/dist/components/combobox/combobox.visual.test.d.ts +2 -0
  30. package/dist/components/combobox/combobox.visual.test.d.ts.map +1 -0
  31. package/dist/components/combobox/types.d.ts +41 -0
  32. package/dist/components/combobox/types.d.ts.map +1 -1
  33. package/dist/components/date-picker/date-picker.composition.d.ts +6 -2
  34. package/dist/components/date-picker/date-picker.composition.d.ts.map +1 -1
  35. package/dist/components/date-picker/date-picker.visual.test.d.ts +2 -0
  36. package/dist/components/date-picker/date-picker.visual.test.d.ts.map +1 -0
  37. package/dist/components/divider/divider.visual.test.d.ts +2 -0
  38. package/dist/components/divider/divider.visual.test.d.ts.map +1 -0
  39. package/dist/components/drawer/drawer.composition.d.ts +0 -1
  40. package/dist/components/drawer/drawer.composition.d.ts.map +1 -1
  41. package/dist/components/drawer/drawer.visual.test.d.ts +2 -0
  42. package/dist/components/drawer/drawer.visual.test.d.ts.map +1 -0
  43. package/dist/components/flex/flex.visual.test.d.ts +2 -0
  44. package/dist/components/flex/flex.visual.test.d.ts.map +1 -0
  45. package/dist/components/form-control/form-control.visual.test.d.ts +2 -0
  46. package/dist/components/form-control/form-control.visual.test.d.ts.map +1 -0
  47. package/dist/components/grid/grid.composition.d.ts +3 -0
  48. package/dist/components/grid/grid.composition.d.ts.map +1 -0
  49. package/dist/components/grid/grid.visual.test.d.ts +2 -0
  50. package/dist/components/grid/grid.visual.test.d.ts.map +1 -0
  51. package/dist/components/heading/heading.visual.test.d.ts +2 -0
  52. package/dist/components/heading/heading.visual.test.d.ts.map +1 -0
  53. package/dist/components/highlight/highlight.composition.d.ts +3 -0
  54. package/dist/components/highlight/highlight.composition.d.ts.map +1 -0
  55. package/dist/components/highlight/highlight.d.ts +5 -0
  56. package/dist/components/highlight/highlight.d.ts.map +1 -1
  57. package/dist/components/highlight/highlight.visual.test.d.ts +2 -0
  58. package/dist/components/highlight/highlight.visual.test.d.ts.map +1 -0
  59. package/dist/components/icon/icon.composition.d.ts +1 -1
  60. package/dist/components/icon/icon.composition.d.ts.map +1 -1
  61. package/dist/components/icon/icon.visual.test.d.ts +2 -0
  62. package/dist/components/icon/icon.visual.test.d.ts.map +1 -0
  63. package/dist/components/icon-button/icon-button.d.ts +1 -1
  64. package/dist/components/icon-button/icon-button.d.ts.map +1 -1
  65. package/dist/components/icon-button/icon-button.visual.test.d.ts +2 -0
  66. package/dist/components/icon-button/icon-button.visual.test.d.ts.map +1 -0
  67. package/dist/components/icon-button/types.d.ts +2 -2
  68. package/dist/components/icon-button/types.d.ts.map +1 -1
  69. package/dist/components/image/image.composition.d.ts.map +1 -1
  70. package/dist/components/image/image.visual.test.d.ts +2 -0
  71. package/dist/components/image/image.visual.test.d.ts.map +1 -0
  72. package/dist/components/image-upload/image-upload.composition.d.ts.map +1 -1
  73. package/dist/components/image-upload/image-upload.visual.test.d.ts +2 -0
  74. package/dist/components/image-upload/image-upload.visual.test.d.ts.map +1 -0
  75. package/dist/components/input/input.visual.test.d.ts +2 -0
  76. package/dist/components/input/input.visual.test.d.ts.map +1 -0
  77. package/dist/components/link/link.visual.test.d.ts +2 -0
  78. package/dist/components/link/link.visual.test.d.ts.map +1 -0
  79. package/dist/components/list/list.visual.test.d.ts +2 -0
  80. package/dist/components/list/list.visual.test.d.ts.map +1 -0
  81. package/dist/components/menu/menu.visual.test.d.ts +2 -0
  82. package/dist/components/menu/menu.visual.test.d.ts.map +1 -0
  83. package/dist/components/message/message.visual.test.d.ts +2 -0
  84. package/dist/components/message/message.visual.test.d.ts.map +1 -0
  85. package/dist/components/modal/modal.composition.d.ts.map +1 -1
  86. package/dist/components/modal/modal.visual.test.d.ts +2 -0
  87. package/dist/components/modal/modal.visual.test.d.ts.map +1 -0
  88. package/dist/components/navigation-list/navigation-list.visual.test.d.ts +2 -0
  89. package/dist/components/navigation-list/navigation-list.visual.test.d.ts.map +1 -0
  90. package/dist/components/paginator/paginator.visual.test.d.ts +2 -0
  91. package/dist/components/paginator/paginator.visual.test.d.ts.map +1 -0
  92. package/dist/components/quantity-button/quantity-button.composition.d.ts.map +1 -1
  93. package/dist/components/quantity-button/quantity-button.visual.test.d.ts +2 -0
  94. package/dist/components/quantity-button/quantity-button.visual.test.d.ts.map +1 -0
  95. package/dist/components/radio/radio.visual.test.d.ts +2 -0
  96. package/dist/components/radio/radio.visual.test.d.ts.map +1 -0
  97. package/dist/components/radio-group/radio-group.visual.test.d.ts +2 -0
  98. package/dist/components/radio-group/radio-group.visual.test.d.ts.map +1 -0
  99. package/dist/components/segmented-control/segmented-control.visual.test.d.ts +2 -0
  100. package/dist/components/segmented-control/segmented-control.visual.test.d.ts.map +1 -0
  101. package/dist/components/select/select.visual.test.d.ts +2 -0
  102. package/dist/components/select/select.visual.test.d.ts.map +1 -0
  103. package/dist/components/skeleton/skeleton.visual.test.d.ts +2 -0
  104. package/dist/components/skeleton/skeleton.visual.test.d.ts.map +1 -0
  105. package/dist/components/stack/stack.visual.test.d.ts +2 -0
  106. package/dist/components/stack/stack.visual.test.d.ts.map +1 -0
  107. package/dist/components/stepper/stepper.visual.test.d.ts +2 -0
  108. package/dist/components/stepper/stepper.visual.test.d.ts.map +1 -0
  109. package/dist/components/switch/switch.visual.test.d.ts +2 -0
  110. package/dist/components/switch/switch.visual.test.d.ts.map +1 -0
  111. package/dist/components/table/table.visual.test.d.ts +2 -0
  112. package/dist/components/table/table.visual.test.d.ts.map +1 -0
  113. package/dist/components/tabs/tabs.composition.d.ts.map +1 -1
  114. package/dist/components/tabs/tabs.visual.test.d.ts +2 -0
  115. package/dist/components/tabs/tabs.visual.test.d.ts.map +1 -0
  116. package/dist/components/tag/tag.visual.test.d.ts +2 -0
  117. package/dist/components/tag/tag.visual.test.d.ts.map +1 -0
  118. package/dist/components/text/text.visual.test.d.ts +2 -0
  119. package/dist/components/text/text.visual.test.d.ts.map +1 -0
  120. package/dist/components/textarea/textarea.visual.test.d.ts +2 -0
  121. package/dist/components/textarea/textarea.visual.test.d.ts.map +1 -0
  122. package/dist/components/toast/toast.visual.test.d.ts +2 -0
  123. package/dist/components/toast/toast.visual.test.d.ts.map +1 -0
  124. package/dist/components/toggle-button/toggle-button.visual.test.d.ts +2 -0
  125. package/dist/components/toggle-button/toggle-button.visual.test.d.ts.map +1 -0
  126. package/dist/components/tooltip/tooltip.composition.d.ts +4 -1
  127. package/dist/components/tooltip/tooltip.composition.d.ts.map +1 -1
  128. package/dist/components/tooltip/tooltip.visual.test.d.ts +2 -0
  129. package/dist/components/tooltip/tooltip.visual.test.d.ts.map +1 -0
  130. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +123 -120
  131. package/dist/test-utils/create-visual-tests.d.ts +21 -0
  132. package/dist/test-utils/create-visual-tests.d.ts.map +1 -0
  133. package/dist/test-utils/render-for-visual-test.d.ts +8 -0
  134. package/dist/test-utils/render-for-visual-test.d.ts.map +1 -0
  135. package/package.json +16 -8
package/README.md CHANGED
@@ -21,7 +21,10 @@ All commands are run from the root of the project, from a terminal.
21
21
  | `npm run dev` | Build a local development version of the entire library, compiled into a single .js file for improved HMR. Automatically rebuilds when the file contents change. |
22
22
  | `npm run build` | Build the library as it will be shipped on npm. Does not automatically rebuild when files change, but you can still use this build output to verify your changes in the documentation website or in another project. |
23
23
  | `cd ../docs && npm run dev` | Starts the documentation website. Usually you want to run this alongside the library in dev mode, so open a new terminal for this. See [/docs](../docs) for more info. |
24
- | `npm run test` | Run tests. |
24
+ | `npm run test` | Run unit tests. |
25
+ | `npm run test:visual` | Run visual regression tests using Playwright in Docker. Automatically starts/stops Docker container. |
26
+ | `npm run test:visual:ui` | Opens the HTML report viewer for visual test results. |
27
+ | `npm run test:visual:update` | Update visual regression baseline screenshots. Run this after intentional UI changes. |
25
28
  | `npm run lint` | Run linting with [@caspeco/eslint-config](https://github.com/Caspeco/eslint-config). If you use the recommended [ESLint VSCode extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) you can see your eslint errors directly in your editor without having to run this. |
26
29
  | `npm run prettier:fix` | Reformat all files with [@caspeco/prettier-config](https://github.com/Caspeco/prettier-config). If you use the recommended [Prettier VSCode extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) you can have your files automatically formatted on file save. |
27
30
 
@@ -50,6 +53,27 @@ export default defineConfig({
50
53
  });
51
54
  ```
52
55
 
56
+ ### Visual Regression Tests
57
+
58
+ Visual regression tests catch unintended UI changes by comparing screenshots of component variants to committed baselines in `__screenshots__/`. They run with Playwright in Docker to ensure consistent rendering across different development environments and CI.
59
+
60
+ **Requirements**: Docker must be installed and running.
61
+
62
+ **Running tests**:
63
+
64
+ - `npm run test:visual` - Runs all visual tests
65
+ - `npm run test:visual:ui` - Opens the HTML report viewer
66
+ - `npm run test:visual:update` - Updates baseline screenshots after intentional UI changes
67
+
68
+ > [!TIP]
69
+ > CI fails but local passes?
70
+ >
71
+ > 1. Go to the `visual-tests` job in GitHub Actions
72
+ > 2. Download and extract the HTML artifact under the `Upload visual test report` step
73
+ > 3. Run `npx vite preview --outDir .` in the extracted directory to see diff report from CI
74
+
75
+ You may need to tweak the [pixelmatch comparator options](https://vitest.dev/api/browser/assertions.html#pixelmatch-comparator-options) if you see false positives due to anti-aliasing or sub-pixel rendering differences. See existing tests for examples.
76
+
53
77
  ## Contributing
54
78
 
55
79
  1. Make sure your repository is up to date.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=accordion.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accordion.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/accordion/accordion.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=alert.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/alert/alert.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=badge.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/badge/badge.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=box.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/box/box.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=breadcrumbs.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumbs.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/breadcrumbs/breadcrumbs.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=button.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/button/button.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=checkbox.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkbox.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/checkbox/checkbox.visual.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=checkbox-group.visual.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkbox-group.visual.test.d.ts","sourceRoot":"","sources":["../../../lib/components/checkbox-group/checkbox-group.visual.test.tsx"],"names":[],"mappings":""}
@@ -3,7 +3,8 @@ type ComboboxItemProps = {
3
3
  item: ComboboxItemType;
4
4
  asPlainText?: boolean;
5
5
  isDeleting?: boolean;
6
+ highlightQuery?: string;
6
7
  };
7
- export declare function ComboboxItem({ item, asPlainText, isDeleting }: ComboboxItemProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ComboboxItem({ item, asPlainText, isDeleting, highlightQuery }: ComboboxItemProps): import("react/jsx-runtime").JSX.Element;
8
9
  export {};
9
10
  //# sourceMappingURL=combobox-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-item.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAahE,KAAK,iBAAiB,GAAG;IACxB,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,iBAAiB,2CAkBhF"}
1
+ {"version":3,"file":"combobox-item.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAchE,KAAK,iBAAiB,GAAG;IACxB,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,iBAAiB,2CAoBhG"}
@@ -1,9 +1,10 @@
1
- import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { Flex as t } from "@chakra-ui/react";
3
- import { Box as a } from "../box/box.js";
1
+ import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
+ import { Flex as s } from "@chakra-ui/react";
3
+ import { Box as n } from "../box/box.js";
4
+ import { Highlight as l } from "../highlight/highlight.js";
4
5
  import { Tag as o } from "../tag/tag.js";
5
- import { ThemeSpaceVariable as c } from "../../theme/theme-types.js";
6
- const s = {
6
+ import { ThemeSpaceVariable as m } from "../../theme/theme-types.js";
7
+ const f = {
7
8
  info: o.Info,
8
9
  success: o.Success,
9
10
  warning: o.Warning,
@@ -13,14 +14,14 @@ const s = {
13
14
  neutral: o,
14
15
  undefined: o.ComboboxItem
15
16
  };
16
- function b({ item: r, asPlainText: p, isDeleting: n }) {
17
- const l = n ? "primary" : r.variant || "neutral", d = s[l];
18
- return p ? /* @__PURE__ */ i(t, { gap: c.XSmall, overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", children: [
17
+ function y({ item: r, asPlainText: d, isDeleting: p, highlightQuery: a }) {
18
+ const i = p ? "primary" : r.variant || "neutral", c = f[i];
19
+ return d ? /* @__PURE__ */ t(s, { gap: m.XSmall, overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", children: [
19
20
  r.prepend,
20
- r.label,
21
+ /* @__PURE__ */ e(n, { children: /* @__PURE__ */ e(l, { query: a ?? "", children: r.label }) }),
21
22
  r.append
22
- ] }) : /* @__PURE__ */ e(a, { overflow: "hidden", children: /* @__PURE__ */ e(d, { prepend: r.prepend, append: r.append, dot: r.dot, solid: n, children: /* @__PURE__ */ e(a, { display: "block", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", children: r.label }) }) });
23
+ ] }) : /* @__PURE__ */ e(n, { overflow: "hidden", children: /* @__PURE__ */ e(c, { prepend: r.prepend, append: r.append, dot: r.dot, solid: p, children: /* @__PURE__ */ e(n, { display: "block", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", children: /* @__PURE__ */ e(l, { query: a ?? "", children: r.label }) }) }) });
23
24
  }
24
25
  export {
25
- b as ComboboxItem
26
+ y as ComboboxItem
26
27
  };
@@ -3,5 +3,5 @@ export declare function CheckboxOrRadioButton({ isSingleSelect, isChecked, }: {
3
3
  isSingleSelect: boolean;
4
4
  isChecked: boolean;
5
5
  }): import("react/jsx-runtime").JSX.Element;
6
- export declare function ComboboxMenu({ asPlainText, inputValue, selectedItems, displayItems, toggleItem, highlightState, openState, parentStrings, isSingleSelect, isSearching, isReadOnly, isHidingItems, popoverWidth, popoverPlacement, previousSelectedItems, parentRef, popupRef, footerContent, subMenuState, translation, }: ComboboxInnerProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ComboboxMenu(props: ComboboxInnerProps): import("react/jsx-runtime").JSX.Element;
7
7
  //# sourceMappingURL=combobox-menu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox-menu.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-menu.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAyClD,wBAAgB,qBAAqB,CAAC,EACrC,cAAc,EACd,SAAS,GACT,EAAE;IACF,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;CACnB,2CAwBA;AAED,wBAAgB,YAAY,CAAC,EAC5B,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,WAAW,GACX,EAAE,kBAAkB,2CAwJpB"}
1
+ {"version":3,"file":"combobox-menu.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-menu.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACX,kBAAkB,EAIlB,MAAM,SAAS,CAAC;AA2CjB,wBAAgB,qBAAqB,CAAC,EACrC,cAAc,EACd,SAAS,GACT,EAAE;IACF,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;CACnB,2CAEA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,2CAiGrD"}
@@ -1,117 +1,93 @@
1
- import { jsxs as l, jsx as i, Fragment as G } from "react/jsx-runtime";
2
- import { Box as d, Flex as g } from "@chakra-ui/react";
3
- import { autoUpdate as J, computePosition as K, flip as L } from "../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
4
- import { Fragment as z, useState as N, useEffect as Q } from "react";
5
- import { ComboboxItem as Z } from "./combobox-item.js";
6
- import { interpolate as R } from "./translations.js";
7
- import { ThemeColorVariable as o, ThemeShadowVariable as oo, ThemeRadiusVariable as D, ThemeSpaceVariable as t, ThemeIconSizeVariable as $, ThemeFontSizeVariable as ro, ThemeBorderVariable as no } from "../../theme/theme-types.js";
1
+ import { jsxs as g, jsx as n, Fragment as _ } from "react/jsx-runtime";
2
+ import { Box as C, Flex as y } from "@chakra-ui/react";
3
+ import { autoUpdate as G, computePosition as Q, flip as U } from "../../node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
4
+ import { useState as Y, useEffect as q, Fragment as T } from "react";
5
+ import { ComboboxItem as H } from "./combobox-item.js";
6
+ import { interpolate as J } from "./translations.js";
7
+ import { ThemeColorVariable as d, ThemeShadowVariable as K, ThemeRadiusVariable as Z, ThemeSpaceVariable as c, ThemeFontSizeVariable as R, ThemeBorderVariable as N, ThemeIconSizeVariable as F } from "../../theme/theme-types.js";
8
8
  import { Text as V } from "../text/text.js";
9
- import { Icon as B } from "../icon/icon.js";
10
- import { Icons as C } from "../icon/types.js";
11
- const eo = (n, e, u, a, p) => {
12
- const [s, m] = N({
9
+ import { Icon as z } from "../icon/icon.js";
10
+ import { Icons as D } from "../icon/types.js";
11
+ import { Checkbox as W } from "../checkbox/checkbox.js";
12
+ import { Radio as ee } from "../radio/radio.js";
13
+ const ne = (o, t, s, h, a) => {
14
+ const [b, x] = Y({
13
15
  transform: "translate(0, 0)",
14
16
  minWidth: 0
15
17
  });
16
- return Q(() => {
17
- if (!n.current || !e.current || !u) return () => {
18
+ return q(() => {
19
+ if (!o.current || !t.current || !s) return () => {
18
20
  };
19
- const S = async () => {
20
- if (n.current && e.current && u) {
21
- const { width: b } = n.current.getBoundingClientRect(), { x, y: k } = await K(n.current, e.current, {
22
- placement: p || "bottom-start",
23
- middleware: [L()]
21
+ const k = async () => {
22
+ if (o.current && t.current && s) {
23
+ const { width: S } = o.current.getBoundingClientRect(), { x: P, y: u } = await Q(o.current, t.current, {
24
+ placement: a || "bottom-start",
25
+ middleware: [U()]
24
26
  });
25
- m({
26
- transform: `translate(${x}px, ${k}px)`,
27
- minWidth: a || b
27
+ x({
28
+ transform: `translate(${P}px, ${u}px)`,
29
+ minWidth: h || S
28
30
  });
29
31
  }
30
- }, h = () => {
31
- S().catch(console.error);
32
+ }, w = () => {
33
+ k().catch(console.error);
32
34
  };
33
- return J(n.current, e.current, h);
34
- }, [n, e, u, p, a]), s;
35
+ return G(o.current, t.current, w);
36
+ }, [o, t, s, a, h]), b;
35
37
  };
36
- function to({
37
- isSingleSelect: n,
38
- isChecked: e
38
+ function X({
39
+ isSingleSelect: o,
40
+ isChecked: t
39
41
  }) {
40
- return /* @__PURE__ */ i(
41
- d,
42
- {
43
- position: "relative",
44
- width: "24px",
45
- height: "24px",
46
- flexShrink: "0",
47
- border: `${n && e ? 8 : 2}px solid ${e ? o.Primary : o.OnBackground}`,
48
- backgroundColor: e && !n ? o.Primary : "auto",
49
- borderRadius: n ? "50%" : D.Small,
50
- children: !n && e && /* @__PURE__ */ i(
51
- B,
52
- {
53
- top: "-2px",
54
- position: "absolute",
55
- width: $.Small,
56
- color: o.Surface,
57
- icon: C.Checkbox
58
- }
59
- )
60
- }
61
- );
42
+ return o ? /* @__PURE__ */ n(ee, { isChecked: t }) : /* @__PURE__ */ n(W, { isChecked: t });
62
43
  }
63
- function fo({
64
- asPlainText: n,
65
- inputValue: e,
66
- selectedItems: u,
67
- displayItems: a,
68
- toggleItem: p,
69
- highlightState: s,
70
- openState: m,
71
- parentStrings: S,
72
- isSingleSelect: h,
73
- isSearching: b,
74
- isReadOnly: x,
75
- isHidingItems: k,
76
- popoverWidth: I,
77
- popoverPlacement: X,
78
- previousSelectedItems: w,
79
- parentRef: j,
80
- popupRef: O,
81
- footerContent: v,
82
- subMenuState: M,
83
- translation: T
84
- }) {
85
- const H = eo(
86
- j,
87
- O,
88
- m.isOpen,
89
- I,
90
- X
91
- ), A = (r) => {
92
- s.set(r);
44
+ function pe(o) {
45
+ const {
46
+ inputValue: t,
47
+ displayItems: s,
48
+ highlightState: h,
49
+ openState: a,
50
+ isSingleSelect: b,
51
+ isSearching: x,
52
+ isHidingItems: k,
53
+ popoverWidth: w,
54
+ popoverPlacement: S,
55
+ parentRef: P,
56
+ popupRef: u,
57
+ footerContent: l,
58
+ translation: e,
59
+ folderStyle: i
60
+ } = o, r = ne(
61
+ P,
62
+ u,
63
+ a.isOpen,
64
+ w,
65
+ S
66
+ ), v = (m) => {
67
+ h.set(m);
93
68
  };
94
- return /* @__PURE__ */ l(
95
- d,
69
+ return /* @__PURE__ */ g(
70
+ C,
96
71
  {
97
- display: m.isOpen ? "block" : "none",
72
+ display: a.isOpen ? "block" : "none",
98
73
  inset: "0 auto auto 0",
99
74
  position: "fixed",
100
75
  zIndex: "50",
101
76
  visibility: "visible",
102
- backgroundColor: o.Surface,
103
- borderRadius: D.Medium,
104
- boxShadow: oo.Medium,
105
- color: o.OnSurface,
77
+ backgroundColor: d.Surface,
78
+ borderRadius: Z.Medium,
79
+ boxShadow: K.Medium,
80
+ color: d.OnSurface,
106
81
  overflow: "hidden",
107
- style: H,
108
- ref: O,
109
- onClick: (r) => {
110
- r.preventDefault(), r.stopPropagation(), h && m.close();
82
+ style: r,
83
+ ref: u,
84
+ maxW: "90%",
85
+ onClick: (m) => {
86
+ m.preventDefault(), m.stopPropagation(), b && a.close();
111
87
  },
112
88
  children: [
113
- /* @__PURE__ */ l(
114
- g,
89
+ /* @__PURE__ */ g(
90
+ y,
115
91
  {
116
92
  as: "ul",
117
93
  flexDirection: "column",
@@ -119,103 +95,208 @@ function fo({
119
95
  overflowY: "auto",
120
96
  overflowX: "hidden",
121
97
  role: "listbox",
122
- "aria-multiselectable": !h,
123
- padding: `${t.Small} 0`,
98
+ "aria-multiselectable": !b,
99
+ padding: `${c.Small} 0`,
124
100
  children: [
125
- b && a.length === 0 && e.length > 0 && /* @__PURE__ */ i(
101
+ x && s.length === 0 && t.length > 0 && /* @__PURE__ */ n(
126
102
  V,
127
103
  {
128
- px: t.Small,
129
- color: o.OnSurfaceSubdued,
130
- children: `${T.noMatchFor} "${e}"`
104
+ px: c.Small,
105
+ color: d.OnSurfaceSubdued,
106
+ children: `${e.noMatchFor} "${t}"`
131
107
  }
132
108
  ),
133
- a.map((r, f) => {
134
- const y = u.some((c) => c.id === r.id), E = (c) => {
135
- c.stopPropagation(), c.preventDefault(), p(r);
136
- }, U = r.children?.length, P = r.id === "_back", W = M.opened[M.opened.length - 1], F = r.id === W?.id, Y = P ? /* @__PURE__ */ l(g, { gap: t.XSmall, alignItems: "center", children: [
137
- /* @__PURE__ */ i(B, { icon: C.Back, size: $.Small }),
138
- r.label
139
- ] }) : /* @__PURE__ */ l(G, { children: [
140
- /* @__PURE__ */ l(g, { gap: t.XSmall, alignItems: "center", whiteSpace: "nowrap", children: [
141
- S[r.id]?.map((c) => /* @__PURE__ */ l(z, { children: [
142
- /* @__PURE__ */ i(d, { color: o.OnSurfaceSubdued, children: c }),
143
- /* @__PURE__ */ i(d, { color: o.OnSurfaceSubdued, children: "/" })
144
- ] }, c)),
145
- /* @__PURE__ */ i(Z, { item: r, asPlainText: n })
146
- ] }),
147
- x ? void 0 : U && !F && !b ? /* @__PURE__ */ i(
148
- B,
149
- {
150
- icon: C.Forward,
151
- size: $.Small,
152
- color: o.OnBackgroundSubdued
153
- }
154
- ) : /* @__PURE__ */ i(to, { isSingleSelect: h, isChecked: y })
155
- ] }), _ = w.length > 0 && w.length - 1 === f && w.length < a.length, q = !x && !b && (_ || (P || F));
156
- return /* @__PURE__ */ l(z, { children: [
157
- /* @__PURE__ */ i(
158
- g,
159
- {
160
- as: "li",
161
- role: "option",
162
- width: "100%",
163
- flexDirection: "row",
164
- justifyContent: "space-between",
165
- padding: `${t.Small} ${t.Medium}`,
166
- gap: t.Medium,
167
- textDecoration: "none",
168
- backgroundColor: s.index === f ? o.AccentHoverAlpha : "",
169
- onClick: E,
170
- tabIndex: -1,
171
- onMouseEnter: () => A(f),
172
- "data-is-active-index": s.index === f,
173
- "aria-selected": y,
174
- children: Y
175
- }
176
- ),
177
- q && /* @__PURE__ */ i(
178
- d,
179
- {
180
- margin: `${t.Small} ${P ? 0 : t.Medium}`,
181
- height: "1px",
182
- flexShrink: 0,
183
- backgroundColor: o.OnBackgroundBorder
184
- }
185
- )
186
- ] }, r.id);
187
- }),
188
- k && /* @__PURE__ */ i(
109
+ i === "stacked" ? /* @__PURE__ */ n(oe, { ...o, onHover: v }) : /* @__PURE__ */ n(re, { ...o, onHover: v }),
110
+ k && /* @__PURE__ */ n(
189
111
  V,
190
112
  {
191
- px: t.Small,
192
- py: t.Small,
193
- color: o.OnSurfaceSubdued,
194
- fontSize: ro.Small,
195
- children: R(T.showMaxItems, {
196
- count: a.length
113
+ px: c.Small,
114
+ py: c.Small,
115
+ color: d.OnSurfaceSubdued,
116
+ fontSize: R.Small,
117
+ children: J(e.showMaxItems, {
118
+ count: s.length
197
119
  })
198
120
  }
199
121
  )
200
122
  ]
201
123
  }
202
124
  ),
203
- v && /* @__PURE__ */ i(
204
- d,
125
+ l && /* @__PURE__ */ n(
126
+ C,
205
127
  {
206
128
  position: "sticky",
207
129
  bottom: "0",
208
- backgroundColor: o.Surface,
209
- padding: `${t.Small} ${t.Medium}`,
210
- borderTop: `${no.XSmall} ${o.OnSurfaceBorder}`,
211
- children: v
130
+ backgroundColor: d.Surface,
131
+ padding: `${c.Small} ${c.Medium}`,
132
+ borderTop: `${N.XSmall} ${d.OnSurfaceBorder}`,
133
+ children: l
212
134
  }
213
135
  )
214
136
  ]
215
137
  }
216
138
  );
217
139
  }
140
+ const A = ({
141
+ children: o,
142
+ isChecked: t,
143
+ onClick: s,
144
+ isActive: h,
145
+ onHover: a
146
+ }) => /* @__PURE__ */ n(
147
+ y,
148
+ {
149
+ as: "li",
150
+ role: "option",
151
+ width: "100%",
152
+ flexDirection: "row",
153
+ justifyContent: "space-between",
154
+ padding: `${c.Small} ${c.Medium}`,
155
+ gap: c.Medium,
156
+ textDecoration: "none",
157
+ backgroundColor: h ? d.AccentHoverAlpha : "",
158
+ onClick: s,
159
+ tabIndex: -1,
160
+ onMouseEnter: a,
161
+ "data-is-active-index": h,
162
+ "aria-selected": t,
163
+ children: o
164
+ }
165
+ ), oe = ({
166
+ displayItems: o,
167
+ selectedItems: t,
168
+ toggleItem: s,
169
+ onHover: h,
170
+ parentSelectsChildren: a,
171
+ highlightState: b,
172
+ inputValue: x,
173
+ isSingleSelect: k
174
+ }) => {
175
+ const w = (l, e) => l.children && l.children.length > 0 ? l.children.every((i) => w(i, e)) : e.some((i) => i.id === l.id), S = (l) => l.children && l.children.length > 0 ? l.children.some((e) => S(e)) : t.some((e) => e.id === l.id);
176
+ let P = 0;
177
+ const u = (l, e, i = []) => l.map((r) => {
178
+ const v = (p) => {
179
+ p.stopPropagation(), p.preventDefault(), s(r);
180
+ };
181
+ i.length > 0 && (i[i.length - 1] -= 1);
182
+ const m = P++, B = r.children && r.children.length > 0, I = !B || r.isSelectableParent;
183
+ let $ = e.some((p) => p.id === r.id);
184
+ return a && B && !r.isSelectableParent && w(r, e) && ($ = !0), /* @__PURE__ */ g(T, { children: [
185
+ /* @__PURE__ */ g(
186
+ A,
187
+ {
188
+ isActive: b.index === m,
189
+ isChecked: $,
190
+ onClick: v,
191
+ onHover: () => h(m),
192
+ children: [
193
+ /* @__PURE__ */ g(y, { alignItems: "center", whiteSpace: "nowrap", minW: 0, children: [
194
+ i.map((p, O, M) => {
195
+ const f = M.length === O + 1, j = p > 0, E = p === 0, L = j || f;
196
+ return /* @__PURE__ */ g(
197
+ y,
198
+ {
199
+ w: c.Medium,
200
+ minW: c.Medium,
201
+ alignItems: "center",
202
+ my: "-0.5rem",
203
+ h: "2.5rem",
204
+ children: [
205
+ L && /* @__PURE__ */ n(
206
+ C,
207
+ {
208
+ w: "1px",
209
+ h: E ? "52%" : "100%",
210
+ backgroundColor: d.OnSurface,
211
+ mb: "auto"
212
+ }
213
+ ),
214
+ f && /* @__PURE__ */ n(
215
+ C,
216
+ {
217
+ w: "inherit",
218
+ height: "1px",
219
+ backgroundColor: d.OnSurface,
220
+ mr: c.XSmall
221
+ }
222
+ )
223
+ ]
224
+ },
225
+ `${r.id}_${O}`
226
+ );
227
+ }),
228
+ /* @__PURE__ */ n(H, { item: r, asPlainText: !0, highlightQuery: x })
229
+ ] }),
230
+ I ? /* @__PURE__ */ n(X, { isSingleSelect: k, isChecked: $ }) : a && !k && /* @__PURE__ */ n(W, { isIndeterminate: S(r), isChecked: $ })
231
+ ]
232
+ }
233
+ ),
234
+ r.children && u(r.children, e, [...i, r.children.length])
235
+ ] }, r.id);
236
+ });
237
+ return u(o, t);
238
+ }, re = ({
239
+ displayItems: o,
240
+ selectedItems: t,
241
+ toggleItem: s,
242
+ onHover: h,
243
+ highlightState: a,
244
+ isSingleSelect: b,
245
+ subMenuState: x,
246
+ parentStrings: k,
247
+ asPlainText: w,
248
+ isSearching: S,
249
+ isReadOnly: P,
250
+ previousSelectedItems: u
251
+ }) => {
252
+ const l = (e, i) => {
253
+ e.stopPropagation(), e.preventDefault(), s(i);
254
+ };
255
+ return o.map((e, i) => {
256
+ const r = t.some((f) => f.id === e.id), v = e.children?.length, m = e.id === "_back", B = x.opened[x.opened.length - 1], I = e.id === B?.id, $ = m ? /* @__PURE__ */ g(y, { gap: c.XSmall, alignItems: "center", children: [
257
+ /* @__PURE__ */ n(z, { icon: D.Back, size: F.Small }),
258
+ e.label
259
+ ] }) : /* @__PURE__ */ g(_, { children: [
260
+ /* @__PURE__ */ g(y, { gap: c.XSmall, alignItems: "center", whiteSpace: "nowrap", children: [
261
+ k[e.id]?.map((f) => /* @__PURE__ */ g(T, { children: [
262
+ /* @__PURE__ */ n(C, { color: d.OnSurfaceSubdued, children: f }),
263
+ /* @__PURE__ */ n(C, { color: d.OnSurfaceSubdued, children: "/" })
264
+ ] }, f)),
265
+ /* @__PURE__ */ n(H, { item: e, asPlainText: w })
266
+ ] }),
267
+ P ? void 0 : v && !I && !S ? /* @__PURE__ */ n(
268
+ z,
269
+ {
270
+ icon: D.Forward,
271
+ size: F.Small,
272
+ color: d.OnBackgroundSubdued
273
+ }
274
+ ) : /* @__PURE__ */ n(X, { isSingleSelect: b, isChecked: r })
275
+ ] }), p = u.length > 0 && u.length - 1 === i && u.length < o.length, M = !P && !S && (p || (m || I));
276
+ return /* @__PURE__ */ g(T, { children: [
277
+ /* @__PURE__ */ n(
278
+ A,
279
+ {
280
+ isActive: a.index === i,
281
+ isChecked: r,
282
+ onClick: (f) => l(f, e),
283
+ onHover: () => h(i),
284
+ children: $
285
+ }
286
+ ),
287
+ M && /* @__PURE__ */ n(
288
+ C,
289
+ {
290
+ margin: `${c.Small} ${m ? 0 : c.Medium}`,
291
+ height: "1px",
292
+ flexShrink: 0,
293
+ backgroundColor: d.OnBackgroundBorder
294
+ }
295
+ )
296
+ ] }, e.id);
297
+ });
298
+ };
218
299
  export {
219
- to as CheckboxOrRadioButton,
220
- fo as ComboboxMenu
300
+ X as CheckboxOrRadioButton,
301
+ pe as ComboboxMenu
221
302
  };