@strapi/design-system 1.6.4 → 1.6.6

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 (168) hide show
  1. package/dist/Accordion/Accordion.cjs +1 -1
  2. package/dist/Accordion/Accordion.js +1 -1
  3. package/dist/Accordion/AccordionToggle.cjs +6 -6
  4. package/dist/Accordion/AccordionToggle.js +48 -51
  5. package/dist/BaseButton/BaseButton.cjs +3 -3
  6. package/dist/BaseButton/BaseButton.js +17 -16
  7. package/dist/BaseRadio/BaseRadio.cjs +1 -1
  8. package/dist/BaseRadio/BaseRadio.js +1 -1
  9. package/dist/Box/Box.cjs +3 -3
  10. package/dist/Box/Box.js +26 -26
  11. package/dist/Card/Card.cjs +1 -1
  12. package/dist/Card/Card.js +1 -1
  13. package/dist/CarouselInput/CarouselActions.cjs +1 -1
  14. package/dist/CarouselInput/CarouselActions.js +16 -4
  15. package/dist/CarouselInput/CarouselInput.cjs +1 -1
  16. package/dist/CarouselInput/CarouselInput.js +13 -13
  17. package/dist/Checkbox/Checkbox.cjs +2 -2
  18. package/dist/Checkbox/Checkbox.js +13 -13
  19. package/dist/Combobox/Combobox.cjs +1 -1
  20. package/dist/Combobox/Combobox.js +62 -63
  21. package/dist/DatePicker/DatePicker.cjs +8 -1
  22. package/dist/DatePicker/DatePicker.js +71 -98
  23. package/dist/DatePicker/DatePickerCalendar.cjs +1 -1
  24. package/dist/DatePicker/DatePickerCalendar.js +125 -57
  25. package/dist/DatePicker/DatePickerTd.cjs +4 -4
  26. package/dist/DatePicker/DatePickerTd.js +43 -26
  27. package/dist/DatePicker/DatePickerTh.cjs +3 -3
  28. package/dist/DatePicker/DatePickerTh.js +31 -15
  29. package/dist/DatePicker/components.cjs +8 -6
  30. package/dist/DatePicker/components.js +15 -13
  31. package/dist/DatePicker/utils/getDayOfWeek.js +8 -8
  32. package/dist/DatePicker/utils/getMonths.cjs +1 -1
  33. package/dist/DatePicker/utils/getMonths.js +3 -3
  34. package/dist/DatePicker/utils/getYears.cjs +1 -1
  35. package/dist/DatePicker/utils/getYears.js +1 -1
  36. package/dist/DateTimePicker/DateTimePicker.cjs +1 -1
  37. package/dist/DateTimePicker/DateTimePicker.js +97 -104
  38. package/dist/Dialog/Dialog.cjs +4 -4
  39. package/dist/Dialog/Dialog.js +2 -2
  40. package/dist/Dialog/DialogFooter.cjs +3 -3
  41. package/dist/Dialog/DialogFooter.js +2 -2
  42. package/dist/Field/Field.cjs +1 -1
  43. package/dist/Field/Field.js +31 -27
  44. package/dist/Field/FieldAction.cjs +2 -8
  45. package/dist/Field/FieldAction.js +27 -16
  46. package/dist/Field/FieldContext.cjs +1 -1
  47. package/dist/Field/FieldContext.js +2 -2
  48. package/dist/Field/FieldError.cjs +1 -1
  49. package/dist/Field/FieldError.js +14 -4
  50. package/dist/Field/FieldHint.cjs +1 -1
  51. package/dist/Field/FieldHint.js +17 -7
  52. package/dist/Field/FieldInput.cjs +14 -16
  53. package/dist/Field/FieldInput.js +104 -72
  54. package/dist/Field/FieldLabel.cjs +6 -3
  55. package/dist/Field/FieldLabel.js +43 -25
  56. package/dist/FocusTrap/FocusTrap.cjs +1 -1
  57. package/dist/FocusTrap/FocusTrap.js +34 -38
  58. package/dist/IconButton/IconButton.cjs +4 -4
  59. package/dist/IconButton/IconButton.js +32 -30
  60. package/dist/JSONInput/JSONInput.cjs +1 -1
  61. package/dist/JSONInput/JSONInput.js +29 -27
  62. package/dist/Layout/HeaderLayout.cjs +2 -2
  63. package/dist/Layout/HeaderLayout.js +3 -3
  64. package/dist/MainNav/NavSection.cjs +1 -1
  65. package/dist/MainNav/NavSection.js +33 -13
  66. package/dist/MainNav/NavSections.cjs +2 -2
  67. package/dist/MainNav/NavSections.js +20 -10
  68. package/dist/ModalLayout/ModalLayout.cjs +1 -1
  69. package/dist/ModalLayout/ModalLayout.js +1 -1
  70. package/dist/NumberInput/NumberInput.cjs +2 -2
  71. package/dist/NumberInput/NumberInput.js +32 -32
  72. package/dist/Popover/Popover.cjs +3 -3
  73. package/dist/Popover/Popover.js +1 -1
  74. package/dist/RawTable/RawCell.cjs +1 -1
  75. package/dist/RawTable/RawCell.js +64 -67
  76. package/dist/RawTable/RawTable.cjs +1 -1
  77. package/dist/RawTable/RawTable.js +39 -37
  78. package/dist/RawTable/RawTbody.cjs +1 -1
  79. package/dist/RawTable/RawTbody.js +14 -11
  80. package/dist/RawTable/RawThead.cjs +1 -1
  81. package/dist/RawTable/RawThead.js +13 -8
  82. package/dist/RawTable/RawTr.cjs +1 -1
  83. package/dist/RawTable/RawTr.js +20 -13
  84. package/dist/Searchbar/Searchbar.cjs +2 -2
  85. package/dist/Searchbar/Searchbar.js +7 -6
  86. package/dist/Select/Select.cjs +2 -2
  87. package/dist/Select/Select.js +66 -65
  88. package/dist/Select/SelectButton.cjs +3 -3
  89. package/dist/Select/SelectButton.js +17 -15
  90. package/dist/Select/SelectList.cjs +1 -1
  91. package/dist/Select/SelectList.js +10 -8
  92. package/dist/SimpleMenu/SimpleMenu.cjs +1 -1
  93. package/dist/SimpleMenu/SimpleMenu.js +1 -1
  94. package/dist/SubNav/SubNavHeader.cjs +2 -2
  95. package/dist/SubNav/SubNavHeader.js +2 -2
  96. package/dist/SubNav/SubNavLinkSection.cjs +3 -3
  97. package/dist/SubNav/SubNavLinkSection.js +1 -1
  98. package/dist/SubNav/SubNavSection.cjs +2 -2
  99. package/dist/SubNav/SubNavSection.js +7 -7
  100. package/dist/SubNav/SubNavSections.cjs +1 -1
  101. package/dist/SubNav/SubNavSections.js +17 -7
  102. package/dist/Tabs/TabGroup.cjs +1 -1
  103. package/dist/Tabs/TabGroup.js +1 -1
  104. package/dist/Tag/Tag.cjs +8 -8
  105. package/dist/Tag/Tag.js +52 -49
  106. package/dist/TextButton/TextButton.cjs +6 -12
  107. package/dist/TextButton/TextButton.js +32 -46
  108. package/dist/TextInput/TextInput.cjs +1 -1
  109. package/dist/TextInput/TextInput.js +48 -47
  110. package/dist/Textarea/Textarea.cjs +2 -2
  111. package/dist/Textarea/Textarea.js +12 -13
  112. package/dist/Textarea/TextareaInput.cjs +4 -4
  113. package/dist/Textarea/TextareaInput.js +13 -12
  114. package/dist/TimePicker/TimePicker.cjs +5 -7
  115. package/dist/TimePicker/TimePicker.js +48 -100
  116. package/dist/ToggleCheckbox/ToggleCheckbox.cjs +2 -2
  117. package/dist/ToggleCheckbox/ToggleCheckbox.js +1 -0
  118. package/dist/ToggleInput/ToggleInput.cjs +3 -3
  119. package/dist/ToggleInput/ToggleInput.js +28 -29
  120. package/dist/Tooltip/Tooltip.cjs +1 -1
  121. package/dist/Tooltip/Tooltip.js +1 -1
  122. package/dist/helpers/deprecations.cjs +1 -1
  123. package/dist/helpers/deprecations.js +7 -7
  124. package/dist/helpers/useElementOnScreen.cjs +1 -1
  125. package/dist/helpers/useElementOnScreen.js +4 -13
  126. package/dist/helpers/useId.cjs +1 -1
  127. package/dist/helpers/useId.js +4 -11
  128. package/dist/helpers/useIntersection.cjs +1 -1
  129. package/dist/helpers/useIntersection.js +4 -21
  130. package/dist/helpers/useLockScroll.cjs +1 -1
  131. package/dist/helpers/useLockScroll.js +4 -7
  132. package/dist/helpers/usePrevious.cjs +1 -1
  133. package/dist/helpers/usePrevious.js +4 -8
  134. package/dist/helpers/useResizeObserver.cjs +1 -1
  135. package/dist/helpers/useResizeObserver.js +4 -14
  136. package/dist/hooks/useElementOnScreen.cjs +1 -0
  137. package/dist/hooks/useElementOnScreen.js +15 -0
  138. package/dist/hooks/useIntersection.cjs +1 -1
  139. package/dist/hooks/useIntersection.js +3 -3
  140. package/dist/hooks/useLockScroll.cjs +1 -0
  141. package/dist/hooks/useLockScroll.js +9 -0
  142. package/dist/hooks/usePrevious.cjs +1 -0
  143. package/dist/hooks/usePrevious.js +10 -0
  144. package/dist/hooks/useResizeObserver.cjs +1 -0
  145. package/dist/hooks/useResizeObserver.js +16 -0
  146. package/dist/v2/MainNav/NavSection.cjs +1 -1
  147. package/dist/v2/MainNav/NavSection.js +33 -13
  148. package/dist/v2/MainNav/NavSections.cjs +2 -2
  149. package/dist/v2/MainNav/NavSections.js +20 -10
  150. package/dist/v2/SimpleMenu/SimpleMenu.cjs +1 -1
  151. package/dist/v2/SimpleMenu/SimpleMenu.js +1 -1
  152. package/dist/v2/SubNav/SubNavHeader.cjs +2 -2
  153. package/dist/v2/SubNav/SubNavHeader.js +2 -2
  154. package/dist/v2/SubNav/SubNavLinkSection.cjs +3 -3
  155. package/dist/v2/SubNav/SubNavLinkSection.js +1 -1
  156. package/dist/v2/SubNav/SubNavSection.cjs +2 -2
  157. package/dist/v2/SubNav/SubNavSection.js +10 -10
  158. package/dist/v2/SubNav/SubNavSections.cjs +1 -1
  159. package/dist/v2/SubNav/SubNavSections.js +17 -7
  160. package/package.json +5 -3
  161. package/dist/DateTimePicker/DateTimePickerProps.cjs +0 -1
  162. package/dist/DateTimePicker/DateTimePickerProps.js +0 -40
  163. package/dist/DateTimePicker/__tests__/parseDate.test.cjs +0 -1
  164. package/dist/DateTimePicker/__tests__/parseDate.test.js +0 -8
  165. package/dist/DateTimePicker/parseDate.cjs +0 -1
  166. package/dist/DateTimePicker/parseDate.js +0 -7
  167. package/dist/Select/SingleSelect.cjs +0 -82
  168. package/dist/Select/SingleSelect.js +0 -285
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/design-system",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,11 +29,12 @@
29
29
  "devDependencies": {
30
30
  "@juggle/resize-observer": "^3.4.0",
31
31
  "@playwright/test": "1.27.1",
32
- "@strapi/icons": "^1.6.4",
32
+ "@strapi/icons": "^1.6.6",
33
33
  "@swc/core": "^1.3.11",
34
34
  "@swc/jest": "^0.2.23",
35
35
  "@testing-library/jest-dom": "5.16.5",
36
36
  "@testing-library/react": "12.1.4",
37
+ "@testing-library/user-event": "^14.4.3",
37
38
  "@types/jest": "^29.2.6",
38
39
  "@types/react": "17.0.2",
39
40
  "@types/react-dom": "17.0.2",
@@ -61,6 +62,7 @@
61
62
  "develop": "vite build --watch",
62
63
  "build": "yarn build:prod",
63
64
  "build:prod": "vite build",
65
+ "clean": "rm -rf dist node_modules",
64
66
  "generate:types": "tsc --noEmit false --emitDeclarationOnly --declarationDir dist",
65
67
  "lint": "eslint . --ext .js,.jsx,.tsx,.ts",
66
68
  "format": "yarn lint --fix",
@@ -76,5 +78,5 @@
76
78
  "@types/react": "17.0.2",
77
79
  "@types/react-dom": "17.0.2"
78
80
  },
79
- "gitHead": "6c4710e399055cb8831c50d3b4a02bfbcc57aa04"
81
+ "gitHead": "be5ac8aa421db6f7c845c29a8df3c9528882d856"
80
82
  }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),d=require("prop-types"),l=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},u=l(o),e=l(d),a=t=>u.default.createElement("div",{...t}),r={ariaLabel:void 0,clearLabel:"clear",disabled:!1,error:void 0,hint:void 0,label:void 0,labelAction:void 0,onClear:void 0,required:!1,selectButtonTitle:"select",size:"M",step:1,value:void 0},i={ariaLabel:e.default.string,clearLabel:e.default.string,disabled:e.default.bool,error:e.default.oneOfType([e.default.string,e.default.bool]),hint:e.default.string,label:e.default.string,labelAction:e.default.element,name:e.default.string.isRequired,onChange:e.default.func.isRequired,onClear:e.default.func,required:e.default.bool,selectButtonTitle:e.default.string,size:e.default.oneOf(["S","M"]),step:e.default.number,value:e.default.instanceOf(Date)};a.defaultProps=r;a.propTypes=i;exports.DateTimePickerProps=a;exports.dateTimePickerDefaultProps=r;exports.dateTimePickerPropTypes=i;
@@ -1,40 +0,0 @@
1
- import t from "react";
2
- import e from "prop-types";
3
- const i = (r) => /* @__PURE__ */ t.createElement("div", { ...r }), o = {
4
- ariaLabel: void 0,
5
- clearLabel: "clear",
6
- disabled: !1,
7
- error: void 0,
8
- hint: void 0,
9
- label: void 0,
10
- labelAction: void 0,
11
- onClear: void 0,
12
- required: !1,
13
- selectButtonTitle: "select",
14
- size: "M",
15
- step: 1,
16
- value: void 0
17
- }, l = {
18
- ariaLabel: e.string,
19
- clearLabel: e.string,
20
- disabled: e.bool,
21
- error: e.oneOfType([e.string, e.bool]),
22
- hint: e.string,
23
- label: e.string,
24
- labelAction: e.element,
25
- name: e.string.isRequired,
26
- onChange: e.func.isRequired,
27
- onClear: e.func,
28
- required: e.bool,
29
- selectButtonTitle: e.string,
30
- size: e.oneOf(["S", "M"]),
31
- step: e.number,
32
- value: e.instanceOf(Date)
33
- };
34
- i.defaultProps = o;
35
- i.propTypes = l;
36
- export {
37
- i as DateTimePickerProps,
38
- o as dateTimePickerDefaultProps,
39
- l as dateTimePickerPropTypes
40
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("../parseDate.cjs");describe("parseDate",()=>{it("should return a date",()=>{expect(e.parseDate("2021-11-05T15:37:29.592Z")instanceof Date).toBeTruthy()}),it("should return null if the passed params has not the right format",()=>{expect(e.parseDate("test")).toBeNull()})});
@@ -1,8 +0,0 @@
1
- import { parseDate as t } from "../parseDate.js";
2
- describe("parseDate", () => {
3
- it("should return a date", () => {
4
- expect(t("2021-11-05T15:37:29.592Z") instanceof Date).toBeTruthy();
5
- }), it("should return null if the passed params has not the right format", () => {
6
- expect(t("test")).toBeNull();
7
- });
8
- });
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=t=>{const e=Date.parse(t);return Number.isNaN(e)?null:new Date(e)};exports.parseDate=r;
@@ -1,7 +0,0 @@
1
- const r = (t) => {
2
- const e = Date.parse(t);
3
- return Number.isNaN(e) ? null : new Date(e);
4
- };
5
- export {
6
- r as parseDate
7
- };
@@ -1,82 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),W=require("react"),U=require("@radix-ui/react-select"),w=require("@strapi/icons"),Y=require("styled-components"),G=require("../Field/Field.cjs"),J=require("../Field/FieldLabel.cjs");require("../Field/FieldInput.cjs");const Q=require("../Field/FieldHint.cjs"),X=require("../Field/FieldError.cjs");require("../Field/FieldContext.cjs");require("../Field/FieldAction.cjs");const Z=require("../Stack/Stack.cjs"),g=require("../Box/Box.cjs"),q=require("../Flex/Flex.cjs"),j=require("../Typography/Typography.cjs"),ee=require("../hooks/useId.cjs"),te=require("../hooks/useIntersection.cjs"),I=require("../themes/utils.cjs"),re=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function k(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const h=k(W),o=k(U),c=re(Y),ne=[" ","Enter","ArrowUp","ArrowDown"],oe=({children:e,clearLabel:n="Clear",customizeContent:s=p=>p.toString(),disabled:i,error:b,hint:v,id:R,label:T,labelAction:O,onChange:$,onClear:a,onReachEnd:m,placeholder:_,required:y,selectButtonTitle:he,startIcon:S,size:B="M",value:f})=>{const p=h.useRef(null),x=h.useRef(null),d=h.useRef(null),[D,C]=h.useState(""),[E,P]=h.useState(!1),u=ee.useId(R),V=`${u}-hint`,M=`${u}-error`,N=r=>{$?$(typeof f=="number"?Number(r):r):C(r)},z=r=>{a&&!i&&(a(r),x.current.focus())},A=r=>{P(r)},H=r=>{d.current&&d.current===r.target.closest("div")&&r.preventDefault()},K=r=>{ne.includes(r.key)&&d.current&&d.current===r.target.closest("div")&&!i&&a&&(r.preventDefault(),a(r),x.current.focus())},F=`intersection-${u}`,L=r=>{m&&m(r)};te.useIntersection(p,L,{selectorToWatch:`#${F}`,skipWhen:!E});const l=typeof f<"u"?f.toString():D;return t.jsx(G.Field,{hint:v,error:b,id:u,required:y,children:t.jsxs(Z.Stack,{spacing:1,children:[t.jsx(J.FieldLabel,{action:O,children:T}),t.jsxs(o.Root,{onOpenChange:A,disabled:i,required:y,onValueChange:N,value:l,children:[t.jsxs(ie,{id:u,"aria-labelledby":`${V} ${M}`,"aria-disabled":i,$hasError:Boolean(b),$size:B,onPointerDown:H,onKeyDown:K,ref:x,children:[t.jsxs(q.Flex,{as:"span",gap:4,children:[S&&t.jsx(g.Box,{as:"span","aria-hidden":!0,children:S}),t.jsx(j.Typography,{ellipsis:!0,textColor:l?"neutral800":"neutral600",children:t.jsx(o.Value,{"aria-label":l,children:l?s(l):_})})]}),t.jsxs(q.Flex,{as:"span",gap:3,children:[l&&a?t.jsx(se,{hasRadius:!0,background:"transparent",role:"button",tabIndex:0,onClick:z,"aria-disabled":i,"aria-label":n,title:n,ref:d,children:t.jsx(w.Cross,{})}):null,t.jsx(le,{children:t.jsx(w.CarretDown,{})})]})]}),t.jsx(o.Portal,{children:t.jsx(ce,{position:"popper",sideOffset:4,children:t.jsxs(ae,{ref:p,children:[e,t.jsx(g.Box,{id:F,width:"100%",height:"1px"})]})})})]}),t.jsx(Q.FieldHint,{}),t.jsx(X.FieldError,{})]})})},se=c.default(g.Box)`
2
- border: none;
3
-
4
- svg {
5
- height: ${11/16}rem;
6
- width: ${11/16}rem;
7
- }
8
-
9
- svg path {
10
- fill: ${({theme:e})=>e.colors.neutral600};
11
- }
12
- `,ie=c.default(o.Trigger)`
13
- position: relative;
14
- border: 1px solid ${({theme:e,$hasError:n})=>n?e.colors.danger600:e.colors.neutral200};
15
- padding-right: ${({theme:e})=>e.spaces[3]};
16
- padding-left: ${({theme:e})=>e.spaces[3]};
17
- border-radius: ${({theme:e})=>e.borderRadius};
18
- background: ${({theme:e})=>e.colors.neutral0};
19
- overflow: hidden;
20
- min-height: ${({theme:e,$size:n})=>I.getThemeSize("input")({theme:e,size:n})};
21
- display: flex;
22
- align-items: center;
23
- justify-content: space-between;
24
- gap: ${({theme:e})=>e.spaces[4]};
25
-
26
- &[aria-disabled='true'] {
27
- color: ${e=>e.theme.colors.neutral600};
28
- background: ${e=>e.theme.colors.neutral150};
29
- }
30
-
31
- /* Required to ensure the below inputFocusStyles are adhered too */
32
- &:focus-visible {
33
- outline: none;
34
- }
35
-
36
- ${({theme:e,$hasError:n})=>I.inputFocusStyle()({theme:e,hasError:n})};
37
- `,le=c.default(o.Icon)`
38
- & > svg {
39
- width: ${6/16}rem;
40
-
41
- & > path {
42
- fill: ${({theme:e})=>e.colors.neutral600};
43
- }
44
- }
45
- `,ce=c.default(o.Content)`
46
- background: ${({theme:e})=>e.colors.neutral0};
47
- box-shadow: ${({theme:e})=>e.shadows.filterShadow};
48
- border: 1px solid ${({theme:e})=>e.colors.neutral150};
49
- border-radius: ${({theme:e})=>e.borderRadius};
50
- width: var(--radix-select-trigger-width);
51
- /* This is from the design-system figma file. */
52
- max-height: 15rem;
53
- `,ae=c.default(o.Viewport)`
54
- padding: ${({theme:e})=>e.spaces[1]};
55
- `,de=({children:e,startIcon:n,value:s})=>t.jsxs(ue,{textValue:e.toString(),value:s.toString(),children:[n&&t.jsx(g.Box,{as:"span",paddingRight:2,"aria-hidden":!0,children:n}),t.jsx(j.Typography,{textColor:"neutral800",children:t.jsx(o.ItemText,{children:e})})]}),ue=c.default(o.Item)`
56
- width: 100%;
57
- border: none;
58
- text-align: left;
59
- outline-offset: -3px;
60
- border-radius: ${e=>e.theme.borderRadius};
61
- padding: ${e=>`${e.theme.spaces[2]} ${e.theme.spaces[4]}`};
62
- padding-left: ${({theme:e})=>e.spaces[4]};
63
- background-color: ${({theme:e})=>e.colors.neutral0};
64
- display: flex;
65
- align-items: center;
66
-
67
- &:focus-visible {
68
- outline: none;
69
- background-color: ${({theme:e})=>e.colors.primary100};
70
- }
71
-
72
- &:hover {
73
- background-color: ${({theme:e})=>e.colors.primary100};
74
- }
75
-
76
- &[data-state='checked'] {
77
- ${j.Typography} {
78
- font-weight: bold;
79
- color: ${({theme:e})=>e.colors.primary600};
80
- }
81
- }
82
- `;exports.SingleSelect=oe;exports.SingleSelectOption=de;
@@ -1,285 +0,0 @@
1
- import { jsx as t, jsxs as i } from "react/jsx-runtime";
2
- import * as h from "react";
3
- import * as n from "@radix-ui/react-select";
4
- import { Cross as H, CarretDown as M } from "@strapi/icons";
5
- import s from "styled-components";
6
- import { Field as U } from "../Field/Field.js";
7
- import { FieldLabel as Y } from "../Field/FieldLabel.js";
8
- import "../Field/FieldInput.js";
9
- import { FieldHint as _ } from "../Field/FieldHint.js";
10
- import { FieldError as G } from "../Field/FieldError.js";
11
- import "../Field/FieldContext.js";
12
- import "../Field/FieldAction.js";
13
- import { Stack as J } from "../Stack/Stack.js";
14
- import { Box as m } from "../Box/Box.js";
15
- import { Flex as I } from "../Flex/Flex.js";
16
- import { Typography as b } from "../Typography/Typography.js";
17
- import { useId as L } from "../hooks/useId.js";
18
- import { useIntersection as Q } from "../hooks/useIntersection.js";
19
- import { getThemeSize as X, inputFocusStyle as Z } from "../themes/utils.js";
20
- const ee = [" ", "Enter", "ArrowUp", "ArrowDown"], Te = ({
21
- children: e,
22
- clearLabel: o = "Clear",
23
- customizeContent: g = (p) => p.toString(),
24
- disabled: a,
25
- error: w,
26
- hint: k,
27
- id: T,
28
- label: C,
29
- labelAction: D,
30
- onChange: x,
31
- onClear: c,
32
- onReachEnd: y,
33
- placeholder: E,
34
- required: S,
35
- selectButtonTitle: se,
36
- startIcon: v,
37
- size: F = "M",
38
- value: f
39
- }) => {
40
- const p = h.useRef(null), $ = h.useRef(null), d = h.useRef(null), [O, B] = h.useState(""), [V, N] = h.useState(!1), u = L(T), P = `${u}-hint`, j = `${u}-error`, z = (r) => {
41
- x ? x(typeof f == "number" ? Number(r) : r) : B(r);
42
- }, K = (r) => {
43
- c && !a && (c(r), $.current.focus());
44
- }, q = (r) => {
45
- N(r);
46
- }, A = (r) => {
47
- d.current && d.current === r.target.closest("div") && r.preventDefault();
48
- }, W = (r) => {
49
- ee.includes(r.key) && d.current && d.current === r.target.closest("div") && !a && c && (r.preventDefault(), c(r), $.current.focus());
50
- }, R = `intersection-${u}`;
51
- Q(p, (r) => {
52
- y && y(r);
53
- }, {
54
- selectorToWatch: `#${R}`,
55
- skipWhen: !V
56
- });
57
- const l = typeof f < "u" ? f.toString() : O;
58
- return t(U, {
59
- hint: k,
60
- error: w,
61
- id: u,
62
- required: S,
63
- children: i(J, {
64
- spacing: 1,
65
- children: [t(Y, {
66
- action: D,
67
- children: C
68
- }), i(n.Root, {
69
- onOpenChange: q,
70
- disabled: a,
71
- required: S,
72
- onValueChange: z,
73
- value: l,
74
- children: [i(te, {
75
- id: u,
76
- "aria-labelledby": `${P} ${j}`,
77
- "aria-disabled": a,
78
- $hasError: Boolean(w),
79
- $size: F,
80
- onPointerDown: A,
81
- onKeyDown: W,
82
- ref: $,
83
- children: [i(I, {
84
- as: "span",
85
- gap: 4,
86
- children: [v && t(m, {
87
- as: "span",
88
- "aria-hidden": !0,
89
- children: v
90
- }), t(b, {
91
- ellipsis: !0,
92
- textColor: l ? "neutral800" : "neutral600",
93
- children: t(n.Value, {
94
- "aria-label": l,
95
- children: l ? g(l) : E
96
- })
97
- })]
98
- }), i(I, {
99
- as: "span",
100
- gap: 3,
101
- children: [l && c ? t(re, {
102
- hasRadius: !0,
103
- background: "transparent",
104
- role: "button",
105
- tabIndex: 0,
106
- onClick: K,
107
- "aria-disabled": a,
108
- "aria-label": o,
109
- title: o,
110
- ref: d,
111
- children: t(H, {})
112
- }) : null, t(oe, {
113
- children: t(M, {})
114
- })]
115
- })]
116
- }), t(n.Portal, {
117
- children: t(ne, {
118
- position: "popper",
119
- sideOffset: 4,
120
- children: i(ie, {
121
- ref: p,
122
- children: [e, t(m, {
123
- id: R,
124
- width: "100%",
125
- height: "1px"
126
- })]
127
- })
128
- })
129
- })]
130
- }), t(_, {}), t(G, {})]
131
- })
132
- });
133
- }, re = s(m)`
134
- border: none;
135
-
136
- svg {
137
- height: ${11 / 16}rem;
138
- width: ${11 / 16}rem;
139
- }
140
-
141
- svg path {
142
- fill: ${({
143
- theme: e
144
- }) => e.colors.neutral600};
145
- }
146
- `, te = s(n.Trigger)`
147
- position: relative;
148
- border: 1px solid ${({
149
- theme: e,
150
- $hasError: o
151
- }) => o ? e.colors.danger600 : e.colors.neutral200};
152
- padding-right: ${({
153
- theme: e
154
- }) => e.spaces[3]};
155
- padding-left: ${({
156
- theme: e
157
- }) => e.spaces[3]};
158
- border-radius: ${({
159
- theme: e
160
- }) => e.borderRadius};
161
- background: ${({
162
- theme: e
163
- }) => e.colors.neutral0};
164
- overflow: hidden;
165
- min-height: ${({
166
- theme: e,
167
- $size: o
168
- }) => X("input")({
169
- theme: e,
170
- size: o
171
- })};
172
- display: flex;
173
- align-items: center;
174
- justify-content: space-between;
175
- gap: ${({
176
- theme: e
177
- }) => e.spaces[4]};
178
-
179
- &[aria-disabled='true'] {
180
- color: ${(e) => e.theme.colors.neutral600};
181
- background: ${(e) => e.theme.colors.neutral150};
182
- }
183
-
184
- /* Required to ensure the below inputFocusStyles are adhered too */
185
- &:focus-visible {
186
- outline: none;
187
- }
188
-
189
- ${({
190
- theme: e,
191
- $hasError: o
192
- }) => Z()({
193
- theme: e,
194
- hasError: o
195
- })};
196
- `, oe = s(n.Icon)`
197
- & > svg {
198
- width: ${6 / 16}rem;
199
-
200
- & > path {
201
- fill: ${({
202
- theme: e
203
- }) => e.colors.neutral600};
204
- }
205
- }
206
- `, ne = s(n.Content)`
207
- background: ${({
208
- theme: e
209
- }) => e.colors.neutral0};
210
- box-shadow: ${({
211
- theme: e
212
- }) => e.shadows.filterShadow};
213
- border: 1px solid ${({
214
- theme: e
215
- }) => e.colors.neutral150};
216
- border-radius: ${({
217
- theme: e
218
- }) => e.borderRadius};
219
- width: var(--radix-select-trigger-width);
220
- /* This is from the design-system figma file. */
221
- max-height: 15rem;
222
- `, ie = s(n.Viewport)`
223
- padding: ${({
224
- theme: e
225
- }) => e.spaces[1]};
226
- `, Ce = ({
227
- children: e,
228
- startIcon: o,
229
- value: g
230
- }) => i(le, {
231
- textValue: e.toString(),
232
- value: g.toString(),
233
- children: [o && t(m, {
234
- as: "span",
235
- paddingRight: 2,
236
- "aria-hidden": !0,
237
- children: o
238
- }), t(b, {
239
- textColor: "neutral800",
240
- children: t(n.ItemText, {
241
- children: e
242
- })
243
- })]
244
- }), le = s(n.Item)`
245
- width: 100%;
246
- border: none;
247
- text-align: left;
248
- outline-offset: -3px;
249
- border-radius: ${(e) => e.theme.borderRadius};
250
- padding: ${(e) => `${e.theme.spaces[2]} ${e.theme.spaces[4]}`};
251
- padding-left: ${({
252
- theme: e
253
- }) => e.spaces[4]};
254
- background-color: ${({
255
- theme: e
256
- }) => e.colors.neutral0};
257
- display: flex;
258
- align-items: center;
259
-
260
- &:focus-visible {
261
- outline: none;
262
- background-color: ${({
263
- theme: e
264
- }) => e.colors.primary100};
265
- }
266
-
267
- &:hover {
268
- background-color: ${({
269
- theme: e
270
- }) => e.colors.primary100};
271
- }
272
-
273
- &[data-state='checked'] {
274
- ${b} {
275
- font-weight: bold;
276
- color: ${({
277
- theme: e
278
- }) => e.colors.primary600};
279
- }
280
- }
281
- `;
282
- export {
283
- Te as SingleSelect,
284
- Ce as SingleSelectOption
285
- };