@namroodinc/liquid-editorial 0.1.6 → 0.1.8

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 (203) hide show
  1. package/AGENTS.md +4 -0
  2. package/README.md +42 -0
  3. package/UPGRADING.md +93 -11
  4. package/dist/chunks/Board-BLhB5_xx.cjs +2 -0
  5. package/dist/chunks/Board-BLhB5_xx.cjs.map +1 -0
  6. package/dist/chunks/Board-BTFSzn6c.js +239 -0
  7. package/dist/chunks/Board-BTFSzn6c.js.map +1 -0
  8. package/dist/chunks/EntryEditor-CcyYtH74.js +191 -0
  9. package/dist/chunks/EntryEditor-CcyYtH74.js.map +1 -0
  10. package/dist/chunks/EntryEditor-DIpc1iPF.cjs +2 -0
  11. package/dist/chunks/EntryEditor-DIpc1iPF.cjs.map +1 -0
  12. package/dist/chunks/{RichTextEditor-DC_0oN1s.cjs → RichTextEditor-BxtlbjXj.cjs} +2 -2
  13. package/dist/chunks/RichTextEditor-BxtlbjXj.cjs.map +1 -0
  14. package/dist/chunks/{RichTextEditor-CSpjsL1z.js → RichTextEditor-Dnx4i7bQ.js} +104 -93
  15. package/dist/chunks/RichTextEditor-Dnx4i7bQ.js.map +1 -0
  16. package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs +2 -0
  17. package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs.map +1 -0
  18. package/dist/chunks/mergeRefs-DGM402mE.js +10 -0
  19. package/dist/chunks/mergeRefs-DGM402mE.js.map +1 -0
  20. package/dist/components/AppShell/index.cjs +2 -0
  21. package/dist/components/AppShell/index.cjs.map +1 -0
  22. package/dist/components/AppShell/index.d.cts +15 -0
  23. package/dist/components/AppShell/index.d.cts.map +1 -0
  24. package/dist/components/AppShell/index.d.ts +15 -0
  25. package/dist/components/AppShell/index.d.ts.map +1 -0
  26. package/dist/components/AppShell/index.js +93 -0
  27. package/dist/components/AppShell/index.js.map +1 -0
  28. package/dist/components/AppShell/style.css +79 -0
  29. package/dist/components/AssetGrid/index.cjs +1 -1
  30. package/dist/components/AssetGrid/index.cjs.map +1 -1
  31. package/dist/components/AssetGrid/index.d.cts.map +1 -1
  32. package/dist/components/AssetGrid/index.d.ts.map +1 -1
  33. package/dist/components/AssetGrid/index.js +57 -59
  34. package/dist/components/AssetGrid/index.js.map +1 -1
  35. package/dist/components/AssetGrid/style.css +8 -16
  36. package/dist/components/Board/index.cjs +1 -2
  37. package/dist/components/Board/index.d.cts.map +1 -1
  38. package/dist/components/Board/index.d.ts.map +1 -1
  39. package/dist/components/Board/index.js +1 -227
  40. package/dist/components/Board/keyboard.d.cts +7 -0
  41. package/dist/components/Board/keyboard.d.cts.map +1 -0
  42. package/dist/components/Board/keyboard.d.ts +7 -0
  43. package/dist/components/Board/keyboard.d.ts.map +1 -0
  44. package/dist/components/Board/keyboard.test.d.cts +2 -0
  45. package/dist/components/Board/keyboard.test.d.cts.map +1 -0
  46. package/dist/components/Board/keyboard.test.d.ts +2 -0
  47. package/dist/components/Board/keyboard.test.d.ts.map +1 -0
  48. package/dist/components/Board/moves.d.cts +5 -0
  49. package/dist/components/Board/moves.d.cts.map +1 -0
  50. package/dist/components/Board/moves.d.ts +5 -0
  51. package/dist/components/Board/moves.d.ts.map +1 -0
  52. package/dist/components/Board/moves.test.d.cts +2 -0
  53. package/dist/components/Board/moves.test.d.cts.map +1 -0
  54. package/dist/components/Board/moves.test.d.ts +2 -0
  55. package/dist/components/Board/moves.test.d.ts.map +1 -0
  56. package/dist/components/Board/style.css +17 -28
  57. package/dist/components/Button/index.cjs +1 -1
  58. package/dist/components/Button/index.cjs.map +1 -1
  59. package/dist/components/Button/index.d.cts +3 -2
  60. package/dist/components/Button/index.d.cts.map +1 -1
  61. package/dist/components/Button/index.d.ts +3 -2
  62. package/dist/components/Button/index.d.ts.map +1 -1
  63. package/dist/components/Button/index.js +1 -1
  64. package/dist/components/Button/index.js.map +1 -1
  65. package/dist/components/Button/style.css +21 -15
  66. package/dist/components/DatePicker/index.cjs +1 -1
  67. package/dist/components/DatePicker/index.cjs.map +1 -1
  68. package/dist/components/DatePicker/index.d.cts.map +1 -1
  69. package/dist/components/DatePicker/index.d.ts.map +1 -1
  70. package/dist/components/DatePicker/index.js +76 -72
  71. package/dist/components/DatePicker/index.js.map +1 -1
  72. package/dist/components/DatePicker/style.css +4 -61
  73. package/dist/components/Drawer/index.cjs +1 -1
  74. package/dist/components/Drawer/index.cjs.map +1 -1
  75. package/dist/components/Drawer/index.d.cts +10 -1
  76. package/dist/components/Drawer/index.d.cts.map +1 -1
  77. package/dist/components/Drawer/index.d.ts +10 -1
  78. package/dist/components/Drawer/index.d.ts.map +1 -1
  79. package/dist/components/Drawer/index.js +78 -49
  80. package/dist/components/Drawer/index.js.map +1 -1
  81. package/dist/components/Drawer/style.css +106 -0
  82. package/dist/components/EntryEditor/index.cjs +1 -1
  83. package/dist/components/EntryEditor/index.d.cts.map +1 -1
  84. package/dist/components/EntryEditor/index.d.ts.map +1 -1
  85. package/dist/components/EntryEditor/index.js +1 -1
  86. package/dist/components/EntryEditor/model.d.cts.map +1 -1
  87. package/dist/components/EntryEditor/model.d.ts.map +1 -1
  88. package/dist/components/EntryPicker/index.cjs +1 -1
  89. package/dist/components/EntryPicker/index.cjs.map +1 -1
  90. package/dist/components/EntryPicker/index.d.cts.map +1 -1
  91. package/dist/components/EntryPicker/index.d.ts.map +1 -1
  92. package/dist/components/EntryPicker/index.js +12 -11
  93. package/dist/components/EntryPicker/index.js.map +1 -1
  94. package/dist/components/EntryPicker/style.css +3 -30
  95. package/dist/components/Field/style.css +11 -3
  96. package/dist/components/Menu/index.cjs +1 -1
  97. package/dist/components/Menu/index.cjs.map +1 -1
  98. package/dist/components/Menu/index.d.cts.map +1 -1
  99. package/dist/components/Menu/index.d.ts.map +1 -1
  100. package/dist/components/Menu/index.js +11 -16
  101. package/dist/components/Menu/index.js.map +1 -1
  102. package/dist/components/Menu/style.css +7 -41
  103. package/dist/components/Modal/index.cjs +1 -1
  104. package/dist/components/Modal/index.cjs.map +1 -1
  105. package/dist/components/Modal/index.d.cts.map +1 -1
  106. package/dist/components/Modal/index.d.ts.map +1 -1
  107. package/dist/components/Modal/index.js +12 -12
  108. package/dist/components/Modal/index.js.map +1 -1
  109. package/dist/components/NumberField/index.cjs +1 -1
  110. package/dist/components/NumberField/index.cjs.map +1 -1
  111. package/dist/components/NumberField/index.js +13 -17
  112. package/dist/components/NumberField/index.js.map +1 -1
  113. package/dist/components/NumberField/style.css +1 -41
  114. package/dist/components/Pagination/index.cjs +1 -1
  115. package/dist/components/Pagination/index.cjs.map +1 -1
  116. package/dist/components/Pagination/index.js +1 -1
  117. package/dist/components/Pagination/index.js.map +1 -1
  118. package/dist/components/Pagination/style.css +0 -1
  119. package/dist/components/Popover/index.cjs +1 -1
  120. package/dist/components/Popover/index.cjs.map +1 -1
  121. package/dist/components/Popover/index.js +4 -4
  122. package/dist/components/RichTextEditor/index.cjs +1 -1
  123. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  124. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  125. package/dist/components/RichTextEditor/index.js +1 -1
  126. package/dist/components/SearchField/index.cjs +1 -1
  127. package/dist/components/SearchField/index.cjs.map +1 -1
  128. package/dist/components/SearchField/index.d.cts.map +1 -1
  129. package/dist/components/SearchField/index.d.ts.map +1 -1
  130. package/dist/components/SearchField/index.js +26 -27
  131. package/dist/components/SearchField/index.js.map +1 -1
  132. package/dist/components/SearchField/style.css +0 -21
  133. package/dist/components/Select/index.cjs +1 -1
  134. package/dist/components/Select/index.cjs.map +1 -1
  135. package/dist/components/Select/index.d.cts.map +1 -1
  136. package/dist/components/Select/index.d.ts.map +1 -1
  137. package/dist/components/Select/index.js +101 -80
  138. package/dist/components/Select/index.js.map +1 -1
  139. package/dist/components/Select/style.css +5 -38
  140. package/dist/components/SideNav/index.cjs +1 -1
  141. package/dist/components/SideNav/index.cjs.map +1 -1
  142. package/dist/components/SideNav/index.d.cts.map +1 -1
  143. package/dist/components/SideNav/index.d.ts.map +1 -1
  144. package/dist/components/SideNav/index.js +52 -49
  145. package/dist/components/SideNav/index.js.map +1 -1
  146. package/dist/components/SideNav/style.css +2 -27
  147. package/dist/components/SortableList/index.cjs +1 -1
  148. package/dist/components/SortableList/index.cjs.map +1 -1
  149. package/dist/components/SortableList/index.d.cts.map +1 -1
  150. package/dist/components/SortableList/index.d.ts.map +1 -1
  151. package/dist/components/SortableList/index.js +55 -53
  152. package/dist/components/SortableList/index.js.map +1 -1
  153. package/dist/components/SortableList/style.css +9 -15
  154. package/dist/components/Stepper/index.cjs +1 -1
  155. package/dist/components/Stepper/index.cjs.map +1 -1
  156. package/dist/components/Stepper/index.d.cts.map +1 -1
  157. package/dist/components/Stepper/index.d.ts.map +1 -1
  158. package/dist/components/Stepper/index.js +48 -39
  159. package/dist/components/Stepper/index.js.map +1 -1
  160. package/dist/components/Stepper/style.css +24 -18
  161. package/dist/components/SubNav/index.cjs +1 -1
  162. package/dist/components/SubNav/index.cjs.map +1 -1
  163. package/dist/components/SubNav/index.d.cts.map +1 -1
  164. package/dist/components/SubNav/index.d.ts.map +1 -1
  165. package/dist/components/SubNav/index.js +27 -28
  166. package/dist/components/SubNav/index.js.map +1 -1
  167. package/dist/components/SubNav/style.css +13 -0
  168. package/dist/components/Switch/index.cjs +1 -1
  169. package/dist/components/Switch/index.cjs.map +1 -1
  170. package/dist/components/Switch/index.d.cts.map +1 -1
  171. package/dist/components/Switch/index.d.ts.map +1 -1
  172. package/dist/components/Switch/index.js +23 -21
  173. package/dist/components/Switch/index.js.map +1 -1
  174. package/dist/components/Switch/style.css +2 -28
  175. package/dist/components/TagsInput/index.cjs +1 -1
  176. package/dist/components/TagsInput/index.cjs.map +1 -1
  177. package/dist/components/TagsInput/index.js +8 -10
  178. package/dist/components/TagsInput/index.js.map +1 -1
  179. package/dist/components/TagsInput/style.css +2 -24
  180. package/dist/index.cjs +1 -1
  181. package/dist/index.d.cts +2 -0
  182. package/dist/index.d.cts.map +1 -1
  183. package/dist/index.d.ts +2 -0
  184. package/dist/index.d.ts.map +1 -1
  185. package/dist/index.js +39 -38
  186. package/dist/internal/mergeRefs.d.cts +4 -0
  187. package/dist/internal/mergeRefs.d.cts.map +1 -0
  188. package/dist/internal/mergeRefs.d.ts +4 -0
  189. package/dist/internal/mergeRefs.d.ts.map +1 -0
  190. package/dist/styles.css +1 -0
  191. package/dist/test/dragEvent.d.cts +3 -0
  192. package/dist/test/dragEvent.d.cts.map +1 -0
  193. package/dist/test/dragEvent.d.ts +3 -0
  194. package/dist/test/dragEvent.d.ts.map +1 -0
  195. package/package.json +2 -2
  196. package/dist/chunks/EntryEditor-C32lKKnV.cjs +0 -2
  197. package/dist/chunks/EntryEditor-C32lKKnV.cjs.map +0 -1
  198. package/dist/chunks/EntryEditor-xVuiqtFo.js +0 -181
  199. package/dist/chunks/EntryEditor-xVuiqtFo.js.map +0 -1
  200. package/dist/chunks/RichTextEditor-CSpjsL1z.js.map +0 -1
  201. package/dist/chunks/RichTextEditor-DC_0oN1s.cjs.map +0 -1
  202. package/dist/components/Board/index.cjs.map +0 -1
  203. package/dist/components/Board/index.js.map +0 -1
@@ -119,39 +119,12 @@
119
119
  list-style: none;
120
120
  }
121
121
 
122
- .ds-entry-picker__result {
123
- display: flex;
124
- align-items: center;
122
+ .ds-entry-picker__result.ds-button {
125
123
  justify-content: space-between;
126
- gap: var(--space-3);
127
124
  inline-size: 100%;
128
- padding: var(--space-2) var(--space-3);
129
- border: var(--control-border-width) solid transparent;
130
- border-radius: var(--radius-md);
131
- background: transparent;
132
- color: var(--color-text);
125
+ height: auto;
126
+ min-block-size: var(--field-height-lg);
133
127
  text-align: start;
134
- cursor: pointer;
135
- transition: background-color var(--duration-fast) var(--ease-standard);
136
- }
137
-
138
- .ds-entry-picker__result:hover:not(:disabled) {
139
- background: var(--field-hover);
140
- }
141
-
142
- .ds-entry-picker__result:focus-visible {
143
- outline: var(--control-border-width) solid var(--color-focus);
144
- outline-offset: 2px;
145
- }
146
-
147
- .ds-entry-picker__result[aria-pressed="true"] {
148
- background: var(--color-primary-soft);
149
- box-shadow: inset var(--rail-width) 0 0 0 var(--rail-color);
150
- }
151
-
152
- .ds-entry-picker__result:disabled {
153
- opacity: 45%;
154
- cursor: not-allowed;
155
128
  }
156
129
 
157
130
  .ds-entry-picker__no-results {
@@ -11,6 +11,11 @@
11
11
  transition: background-color var(--duration-fast) var(--ease-standard);
12
12
  }
13
13
 
14
+ .ds-button.ds-field-skin {
15
+ font-weight: var(--font-weight-regular);
16
+ line-height: normal;
17
+ }
18
+
14
19
  .ds-field-skin::placeholder {
15
20
  color: var(--color-text-muted);
16
21
  }
@@ -43,19 +48,22 @@
43
48
  cursor: default;
44
49
  }
45
50
 
46
- input.ds-field-skin[data-size="sm"] {
51
+ input.ds-field-skin[data-size="sm"],
52
+ .ds-button.ds-field-skin[data-size="sm"] {
47
53
  block-size: var(--field-height-sm);
48
54
  padding: 0 10px;
49
55
  font-size: var(--field-font-size-sm);
50
56
  }
51
57
 
52
- input.ds-field-skin[data-size="md"] {
58
+ input.ds-field-skin[data-size="md"],
59
+ .ds-button.ds-field-skin[data-size="md"] {
53
60
  block-size: var(--field-height-md);
54
61
  padding: 0 10px;
55
62
  font-size: var(--field-font-size-md);
56
63
  }
57
64
 
58
- input.ds-field-skin[data-size="lg"] {
65
+ input.ds-field-skin[data-size="lg"],
66
+ .ds-button.ds-field-skin[data-size="lg"] {
59
67
  block-size: var(--field-height-lg);
60
68
  padding: 0 10px;
61
69
  font-size: var(--field-font-size-md);
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CWsA1W83.cjs"),t=require("../Popover/index.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=(0,n.forwardRef)(function({trigger:e,align:a=`start`,className:o,children:s,onClick:c,onKeyDown:l,...u},d){let[f,p]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(null),_=(0,n.useId)(),v=(0,n.useCallback)(()=>p(!1),[]),y=(0,n.useCallback)(()=>{(h.current?.querySelector(`button, [href], [tabindex]`)??h.current)?.focus()},[]);(0,n.useEffect)(()=>{typeof d==`function`?d(g.current):d&&(d.current=g.current)},[f,d]),(0,n.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.target;!m.current?.contains(t)&&!g.current?.contains(t)&&v()},t=e=>{e.key===`Escape`&&(v(),y())};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),g.current?.querySelector(`button:not(:disabled)`)?.focus(),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[f,v,y]);let b=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=Array.from(g.current?.querySelectorAll(`button:not(:disabled)`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement);(e.key===`ArrowDown`?t[(n+1)%t.length]:t[(n-1+t.length)%t.length])?.focus()};return(0,r.jsxs)(`div`,{className:`ds-menu-root`,ref:m,children:[(0,r.jsx)(`span`,{ref:h,className:`ds-menu-root`,children:e({"aria-haspopup":`menu`,"aria-expanded":f,"aria-controls":f?_:void 0,onClick:()=>p(e=>!e)})}),(0,r.jsx)(t.Popover,{anchorRef:h,isOpen:f,align:a,offset:8,id:_,role:`menu`,className:i(`ds-surface-raised`,`ds-menu`,o),panelRef:g,children:(0,r.jsx)(`div`,{className:`ds-menu__list`,onKeyDown:e=>{l?.(e),e.defaultPrevented||b(e)},onClick:e=>{c?.(e),e.defaultPrevented||(v(),y())},...u,children:s})})]})}),o=(0,n.forwardRef)(function({icon:t,tone:n=`neutral`,shortcut:a,isDisabled:o=!1,className:s,children:c,...l},u){return(0,r.jsxs)(`button`,{ref:u,type:`button`,role:`menuitem`,disabled:o,"data-tone":n===`danger`?`danger`:void 0,className:i(`ds-menu-item`,s),...l,children:[t&&(0,r.jsx)(e.t,{name:t,size:16}),c,a&&(0,r.jsx)(`span`,{className:`ds-menu-item__shortcut`,children:a})]})});function s(){return(0,r.jsx)(`div`,{className:`ds-menu-separator`,role:`separator`})}function c({children:e}){return(0,r.jsx)(`div`,{className:`ds-menu-label`,children:e})}exports.Menu=a,exports.MenuItem=o,exports.MenuLabel=c,exports.MenuSeparator=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs"),t=require("../Popover/index.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=(0,n.forwardRef)(function({trigger:e,align:a=`start`,className:o,children:s,onClick:c,onKeyDown:l,...u},d){let[f,p]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(null),_=(0,n.useId)(),v=(0,n.useCallback)(()=>p(!1),[]),y=(0,n.useCallback)(()=>{(h.current?.querySelector(`button, [href], [tabindex]`)??h.current)?.focus()},[]);(0,n.useEffect)(()=>{typeof d==`function`?d(g.current):d&&(d.current=g.current)},[f,d]),(0,n.useEffect)(()=>{if(!f)return;let e=e=>{let t=e.target;!m.current?.contains(t)&&!g.current?.contains(t)&&v()},t=e=>{e.key===`Escape`&&(e.preventDefault(),v(),y())};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),g.current?.querySelector(`button:not(:disabled)`)?.focus(),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[f,v,y]);let b=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=Array.from(g.current?.querySelectorAll(`button:not(:disabled)`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement);(e.key===`ArrowDown`?t[(n+1)%t.length]:t[(n-1+t.length)%t.length])?.focus()};return(0,r.jsxs)(`div`,{className:`ds-menu-root`,ref:m,children:[(0,r.jsx)(`span`,{ref:h,className:`ds-menu-root`,children:e({"aria-haspopup":`menu`,"aria-expanded":f,"aria-controls":f?_:void 0,onClick:()=>p(e=>!e)})}),(0,r.jsx)(t.Popover,{anchorRef:h,isOpen:f,align:a,offset:8,id:_,role:`menu`,className:i(`ds-surface-raised`,`ds-menu`,o),panelRef:g,children:(0,r.jsx)(`div`,{className:`ds-menu__list`,onKeyDown:e=>{l?.(e),e.defaultPrevented||b(e)},onClick:e=>{c?.(e),e.defaultPrevented||(v(),y())},...u,children:s})})]})}),o=(0,n.forwardRef)(function({icon:t,tone:n=`neutral`,shortcut:a,isDisabled:o=!1,className:s,children:c,...l},u){return(0,r.jsxs)(e.Button,{ref:u,variant:n===`danger`?`danger`:`simple`,size:`sm`,iconStart:t,role:`menuitem`,isDisabled:o,"data-tone":n===`danger`?`danger`:void 0,className:i(`ds-menu-item`,s),...l,children:[c,a&&(0,r.jsx)(`span`,{className:`ds-menu-item__shortcut`,children:a})]})});function s(){return(0,r.jsx)(`div`,{className:`ds-menu-separator`,role:`separator`})}function c({children:e}){return(0,r.jsx)(`div`,{className:`ds-menu-label`,children:e})}exports.Menu=a,exports.MenuItem=o,exports.MenuLabel=c,exports.MenuSeparator=s;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","useId","useCallback","Popover","Icon","require_Icon","require_components_Popover_index","react","react_jsx_runtime","cx","parts","Menu","rest","isOpen","setOpen","rootRef","triggerRef","listRef","menuId","close","restoreTriggerFocus","ref","onPointerDown","target","event","onKeyDown","onListKeyDown","items","index","trigger","open","className","onClick","MenuItem","isDisabled","tone","icon","children","shortcut","MenuSeparator","MenuLabel"],"sources":["../../../src/components/Menu/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Popover } from \"../Popover\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport type MenuAlign = \"start\" | \"end\";\n\nexport interface MenuProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Receives the props that open the menu — usually a `Button`. */\n trigger: (props: {\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\"?: string;\n onClick: () => void;\n }) => ReactElement;\n align?: MenuAlign;\n /** Menu items, labels and separators. */\n children: ReactNode;\n}\n\n/**\n * A short list of actions attached to a control. Closes on Escape, on outside\n * click and after any item is chosen; arrow keys walk the items.\n */\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n { trigger, align = \"start\", className, children, onClick, onKeyDown, ...rest },\n ref,\n) {\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const listRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n\n const close = useCallback(() => setOpen(false), []);\n const restoreTriggerFocus = useCallback(() => {\n const focusTarget =\n triggerRef.current?.querySelector<HTMLElement>(\"button, [href], [tabindex]\") ??\n triggerRef.current;\n focusTarget?.focus();\n }, []);\n\n useEffect(() => {\n if (typeof ref === \"function\") ref(listRef.current);\n else if (ref) ref.current = listRef.current;\n }, [isOpen, ref]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !listRef.current?.contains(target)) close();\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n close();\n restoreTriggerFocus();\n }\n };\n\n document.addEventListener(\"mousedown\", onPointerDown);\n document.addEventListener(\"keydown\", onKeyDown);\n listRef.current?.querySelector<HTMLButtonElement>(\"button:not(:disabled)\")?.focus();\n\n return () => {\n document.removeEventListener(\"mousedown\", onPointerDown);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [isOpen, close, restoreTriggerFocus]);\n\n const onListKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n event.preventDefault();\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\"button:not(:disabled)\") ?? [],\n );\n if (items.length === 0) return;\n const index = items.indexOf(document.activeElement as HTMLButtonElement);\n const next =\n event.key === \"ArrowDown\"\n ? items[(index + 1) % items.length]\n : items[(index - 1 + items.length) % items.length];\n next?.focus();\n };\n\n return (\n <div className=\"ds-menu-root\" ref={rootRef}>\n <span ref={triggerRef} className=\"ds-menu-root\">\n {trigger({\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? menuId : undefined,\n onClick: () => setOpen((open) => !open),\n })}\n </span>\n <Popover\n anchorRef={triggerRef}\n isOpen={isOpen}\n align={align}\n offset={8}\n id={menuId}\n role=\"menu\"\n className={cx(\"ds-surface-raised\", \"ds-menu\", className)}\n panelRef={listRef}\n >\n <div\n className=\"ds-menu__list\"\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) onListKeyDown(event);\n }}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n close();\n restoreTriggerFocus();\n }\n }}\n {...rest}\n >\n {children}\n </div>\n </Popover>\n </div>\n );\n});\n\nexport type MenuItemTone = \"neutral\" | \"danger\";\n\nexport interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n icon?: IconName;\n tone?: MenuItemTone;\n /** Rendered right-aligned and muted, e.g. \"⌘K\". */\n shortcut?: string;\n isDisabled?: boolean;\n children?: ReactNode;\n}\n\nexport const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(function MenuItem(\n { icon, tone = \"neutral\", shortcut, isDisabled = false, className, children, ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"menuitem\"\n disabled={isDisabled}\n data-tone={tone === \"danger\" ? \"danger\" : undefined}\n className={cx(\"ds-menu-item\", className)}\n {...rest}\n >\n {icon && <Icon name={icon} size={16} />}\n {children}\n {shortcut && <span className=\"ds-menu-item__shortcut\">{shortcut}</span>}\n </button>\n );\n});\n\nexport function MenuSeparator() {\n return <div className=\"ds-menu-separator\" role=\"separator\" />;\n}\n\nexport function MenuLabel({ children }: { children: ReactNode }) {\n return <div className=\"ds-menu-label\">{children}</div>;\n}\n"],"mappings":"A,6MAiBA,SAASW,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAqBA,IAAaC,GAAA,EAAOb,EAAAA,WAAAA,CAAsC,SACxD,CAAE,UAAS,QAAQ,QAAS,YAAW,WAAU,UAAS,YAAW,GAAGc,GACxE,EACA,CACA,GAAM,CAACC,EAAQC,IAAA,EAAWf,EAAAA,SAAAA,CAAS,EAAK,EAClCgB,GAAA,EAAUf,EAAAA,OAAAA,CAA8B,IAAI,EAC5CgB,GAAA,EAAahB,EAAAA,OAAAA,CAA2B,IAAI,EAC5CiB,GAAA,EAAUjB,EAAAA,OAAAA,CAA8B,IAAI,EAC5CkB,GAAA,EAASjB,EAAAA,MAAAA,CAAM,EAEfkB,GAAA,EAAQjB,EAAAA,YAAAA,KAAkBY,EAAQ,EAAK,EAAG,CAAC,CAAC,EAC5CM,GAAA,EAAsBlB,EAAAA,YAAAA,KAAkB,EAE1Cc,EAAW,SAAS,cAA2B,4BAA4B,GAC3EA,EAAW,QAAA,EACA,MAAM,CACrB,EAAG,CAAC,CAAC,GAEL,EAAAT,EAAA,UAAA,KAAgB,CACV,OAAOc,GAAQ,WAAYA,EAAIJ,EAAQ,OAAO,EACzCI,IAAK,EAAI,QAAUJ,EAAQ,QACtC,EAAG,CAACJ,EAAQQ,CAAG,CAAC,GAEhB,EAAAd,EAAA,UAAA,KAAgB,CACd,GAAI,CAACM,EAAQ,OAEb,IAAMS,EAAiB,GAAsB,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,UAAWT,EAAG,oBAAqB,UAAWsB,CAAS,EACvD,SAAUd,EAEV,UAAA,EAAAT,EAAA,IAAA,CAAC,MAAD,CACE,UAAU,gBACV,UAAY,GAAU,CACpBiB,IAAYD,CAAK,EACZA,EAAM,kBAAkBE,EAAcF,CAAK,CAClD,EACA,QAAU,GAAU,CAClBQ,IAAUR,CAAK,EACVA,EAAM,mBACTL,EAAM,EACNC,EAAoB,EAExB,EACA,GAAIR,EAEH,UACE,CAAA,CACE,CAAA,CACN,C,EAET,CAAC,EAaYqB,GAAA,EAAWnC,EAAAA,WAAAA,CAA6C,SACnE,CAAE,OAAM,OAAO,UAAW,WAAU,aAAa,GAAO,YAAW,WAAU,GAAGc,GAChF,EACA,CACA,OACE,EAAAJ,EAAA,KAAA,CAAC,SAAD,CACO,MACL,KAAK,SACL,KAAK,WACL,SAAU0B,EACV,YAAWC,IAAS,SAAW,SAAW,IAAA,GAC1C,UAAW1B,EAAG,eAAgBsB,CAAS,EACvC,GAAInB,EAPN,SAAA,CASGwB,IAAQ,EAAA5B,EAAA,IAAA,CAACJ,EAAAA,EAAD,CAAM,KAAMgC,EAAM,KAAM,EAAK,CAAA,EACrCC,EACAC,IAAY,EAAA9B,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,yBAA0B,SAAA8B,CAAe,CAAA,CAChE,C,EAEZ,CAAC,EAED,SAAgBC,GAAgB,CAC9B,OAAO,EAAA/B,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,oBAAoB,KAAK,WAAa,CAAA,CAC9D,CAEA,SAAgBgC,EAAU,CAAE,YAAqC,CAC/D,OAAO,EAAAhC,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,gBAAiB,UAAc,CAAA,CACvD,C"}
1
+ {"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","useId","useCallback","Popover","Button","require_components_Button_index","require_components_Popover_index","react","react_jsx_runtime","cx","parts","Menu","rest","isOpen","setOpen","rootRef","triggerRef","listRef","menuId","close","restoreTriggerFocus","ref","onPointerDown","target","event","onKeyDown","onListKeyDown","items","index","trigger","open","className","onClick","MenuItem","tone","icon","children","shortcut","MenuSeparator","MenuLabel"],"sources":["../../../src/components/Menu/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Popover } from \"../Popover\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport type MenuAlign = \"start\" | \"end\";\n\nexport interface MenuProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Receives the props that open the menu — usually a `Button`. */\n trigger: (props: {\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\"?: string;\n onClick: () => void;\n }) => ReactElement;\n align?: MenuAlign;\n /** Menu items, labels and separators. */\n children: ReactNode;\n}\n\n/**\n * A short list of actions attached to a control. Closes on Escape, on outside\n * click and after any item is chosen; arrow keys walk the items.\n */\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n { trigger, align = \"start\", className, children, onClick, onKeyDown, ...rest },\n ref,\n) {\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const listRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n\n const close = useCallback(() => setOpen(false), []);\n const restoreTriggerFocus = useCallback(() => {\n const focusTarget =\n triggerRef.current?.querySelector<HTMLElement>(\"button, [href], [tabindex]\") ??\n triggerRef.current;\n focusTarget?.focus();\n }, []);\n\n useEffect(() => {\n if (typeof ref === \"function\") ref(listRef.current);\n else if (ref) ref.current = listRef.current;\n }, [isOpen, ref]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !listRef.current?.contains(target)) close();\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n restoreTriggerFocus();\n }\n };\n\n document.addEventListener(\"mousedown\", onPointerDown);\n document.addEventListener(\"keydown\", onKeyDown);\n listRef.current?.querySelector<HTMLButtonElement>(\"button:not(:disabled)\")?.focus();\n\n return () => {\n document.removeEventListener(\"mousedown\", onPointerDown);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [isOpen, close, restoreTriggerFocus]);\n\n const onListKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n event.preventDefault();\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\"button:not(:disabled)\") ?? [],\n );\n if (items.length === 0) return;\n const index = items.indexOf(document.activeElement as HTMLButtonElement);\n const next =\n event.key === \"ArrowDown\"\n ? items[(index + 1) % items.length]\n : items[(index - 1 + items.length) % items.length];\n next?.focus();\n };\n\n return (\n <div className=\"ds-menu-root\" ref={rootRef}>\n <span ref={triggerRef} className=\"ds-menu-root\">\n {trigger({\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? menuId : undefined,\n onClick: () => setOpen((open) => !open),\n })}\n </span>\n <Popover\n anchorRef={triggerRef}\n isOpen={isOpen}\n align={align}\n offset={8}\n id={menuId}\n role=\"menu\"\n className={cx(\"ds-surface-raised\", \"ds-menu\", className)}\n panelRef={listRef}\n >\n <div\n className=\"ds-menu__list\"\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) onListKeyDown(event);\n }}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n close();\n restoreTriggerFocus();\n }\n }}\n {...rest}\n >\n {children}\n </div>\n </Popover>\n </div>\n );\n});\n\nexport type MenuItemTone = \"neutral\" | \"danger\";\n\nexport interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n icon?: IconName;\n tone?: MenuItemTone;\n /** Rendered right-aligned and muted, e.g. \"⌘K\". */\n shortcut?: string;\n isDisabled?: boolean;\n children?: ReactNode;\n}\n\nexport const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(function MenuItem(\n { icon, tone = \"neutral\", shortcut, isDisabled = false, className, children, ...rest },\n ref,\n) {\n return (\n <Button\n ref={ref}\n variant={tone === \"danger\" ? \"danger\" : \"simple\"}\n size=\"sm\"\n iconStart={icon}\n role=\"menuitem\"\n isDisabled={isDisabled}\n data-tone={tone === \"danger\" ? \"danger\" : undefined}\n className={cx(\"ds-menu-item\", className)}\n {...rest}\n >\n {children}\n {shortcut && <span className=\"ds-menu-item__shortcut\">{shortcut}</span>}\n </Button>\n );\n});\n\nexport function MenuSeparator() {\n return <div className=\"ds-menu-separator\" role=\"separator\" />;\n}\n\nexport function MenuLabel({ children }: { children: ReactNode }) {\n return <div className=\"ds-menu-label\">{children}</div>;\n}\n"],"mappings":"A,kMAiBA,SAASW,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAqBA,IAAaC,GAAA,EAAOb,EAAAA,WAAAA,CAAsC,SACxD,CAAE,UAAS,QAAQ,QAAS,YAAW,WAAU,UAAS,YAAW,GAAGc,GACxE,EACA,CACA,GAAM,CAACC,EAAQC,IAAA,EAAWf,EAAAA,SAAAA,CAAS,EAAK,EAClCgB,GAAA,EAAUf,EAAAA,OAAAA,CAA8B,IAAI,EAC5CgB,GAAA,EAAahB,EAAAA,OAAAA,CAA2B,IAAI,EAC5CiB,GAAA,EAAUjB,EAAAA,OAAAA,CAA8B,IAAI,EAC5CkB,GAAA,EAASjB,EAAAA,MAAAA,CAAM,EAEfkB,GAAA,EAAQjB,EAAAA,YAAAA,KAAkBY,EAAQ,EAAK,EAAG,CAAC,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AAC;IAC9F,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,QAAQ,6GAoBnB,CAAC;AAEH,wBAAgB,aAAa,gCAE5B;AAED,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAE9D"}
@@ -1,4 +1,4 @@
1
- import { t as e } from "../../chunks/Icon-CGY1FNXT.js";
1
+ import { Button as e } from "../Button/index.js";
2
2
  import { Popover as t } from "../Popover/index.js";
3
3
  import { forwardRef as n, useCallback as r, useEffect as i, useId as a, useRef as o, useState as s } from "react";
4
4
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
@@ -18,7 +18,7 @@ var d = n(function({ trigger: e, align: n = "start", className: d, children: f,
18
18
  let t = e.target;
19
19
  !y.current?.contains(t) && !x.current?.contains(t) && C();
20
20
  }, t = (e) => {
21
- e.key === "Escape" && (C(), w());
21
+ e.key === "Escape" && (e.preventDefault(), C(), w());
22
22
  };
23
23
  return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), x.current?.querySelector("button:not(:disabled)")?.focus(), () => {
24
24
  document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
@@ -71,25 +71,20 @@ var d = n(function({ trigger: e, align: n = "start", className: d, children: f,
71
71
  })]
72
72
  });
73
73
  }), f = n(function({ icon: t, tone: n = "neutral", shortcut: r, isDisabled: i = !1, className: a, children: o, ...s }, d) {
74
- return /* @__PURE__ */ l("button", {
74
+ return /* @__PURE__ */ l(e, {
75
75
  ref: d,
76
- type: "button",
76
+ variant: n === "danger" ? "danger" : "simple",
77
+ size: "sm",
78
+ iconStart: t,
77
79
  role: "menuitem",
78
- disabled: i,
80
+ isDisabled: i,
79
81
  "data-tone": n === "danger" ? "danger" : void 0,
80
82
  className: u("ds-menu-item", a),
81
83
  ...s,
82
- children: [
83
- t && /* @__PURE__ */ c(e, {
84
- name: t,
85
- size: 16
86
- }),
87
- o,
88
- r && /* @__PURE__ */ c("span", {
89
- className: "ds-menu-item__shortcut",
90
- children: r
91
- })
92
- ]
84
+ children: [o, r && /* @__PURE__ */ c("span", {
85
+ className: "ds-menu-item__shortcut",
86
+ children: r
87
+ })]
93
88
  });
94
89
  });
95
90
  function p() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Icon","cx","parts","Menu","forwardRef","rest","isOpen","setOpen","useState","rootRef","useRef","triggerRef","listRef","menuId","useId","close","useCallback","restoreTriggerFocus","useEffect","ref","onPointerDown","target","event","onKeyDown","onListKeyDown","items","index","trigger","open","Popover","className","onClick","MenuItem","isDisabled","tone","icon","children","shortcut","MenuSeparator","MenuLabel"],"sources":["../../../src/components/Menu/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Popover } from \"../Popover\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport type MenuAlign = \"start\" | \"end\";\n\nexport interface MenuProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Receives the props that open the menu — usually a `Button`. */\n trigger: (props: {\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\"?: string;\n onClick: () => void;\n }) => ReactElement;\n align?: MenuAlign;\n /** Menu items, labels and separators. */\n children: ReactNode;\n}\n\n/**\n * A short list of actions attached to a control. Closes on Escape, on outside\n * click and after any item is chosen; arrow keys walk the items.\n */\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n { trigger, align = \"start\", className, children, onClick, onKeyDown, ...rest },\n ref,\n) {\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const listRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n\n const close = useCallback(() => setOpen(false), []);\n const restoreTriggerFocus = useCallback(() => {\n const focusTarget =\n triggerRef.current?.querySelector<HTMLElement>(\"button, [href], [tabindex]\") ??\n triggerRef.current;\n focusTarget?.focus();\n }, []);\n\n useEffect(() => {\n if (typeof ref === \"function\") ref(listRef.current);\n else if (ref) ref.current = listRef.current;\n }, [isOpen, ref]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !listRef.current?.contains(target)) close();\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n close();\n restoreTriggerFocus();\n }\n };\n\n document.addEventListener(\"mousedown\", onPointerDown);\n document.addEventListener(\"keydown\", onKeyDown);\n listRef.current?.querySelector<HTMLButtonElement>(\"button:not(:disabled)\")?.focus();\n\n return () => {\n document.removeEventListener(\"mousedown\", onPointerDown);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [isOpen, close, restoreTriggerFocus]);\n\n const onListKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n event.preventDefault();\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\"button:not(:disabled)\") ?? [],\n );\n if (items.length === 0) return;\n const index = items.indexOf(document.activeElement as HTMLButtonElement);\n const next =\n event.key === \"ArrowDown\"\n ? items[(index + 1) % items.length]\n : items[(index - 1 + items.length) % items.length];\n next?.focus();\n };\n\n return (\n <div className=\"ds-menu-root\" ref={rootRef}>\n <span ref={triggerRef} className=\"ds-menu-root\">\n {trigger({\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? menuId : undefined,\n onClick: () => setOpen((open) => !open),\n })}\n </span>\n <Popover\n anchorRef={triggerRef}\n isOpen={isOpen}\n align={align}\n offset={8}\n id={menuId}\n role=\"menu\"\n className={cx(\"ds-surface-raised\", \"ds-menu\", className)}\n panelRef={listRef}\n >\n <div\n className=\"ds-menu__list\"\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) onListKeyDown(event);\n }}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n close();\n restoreTriggerFocus();\n }\n }}\n {...rest}\n >\n {children}\n </div>\n </Popover>\n </div>\n );\n});\n\nexport type MenuItemTone = \"neutral\" | \"danger\";\n\nexport interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n icon?: IconName;\n tone?: MenuItemTone;\n /** Rendered right-aligned and muted, e.g. \"⌘K\". */\n shortcut?: string;\n isDisabled?: boolean;\n children?: ReactNode;\n}\n\nexport const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(function MenuItem(\n { icon, tone = \"neutral\", shortcut, isDisabled = false, className, children, ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"menuitem\"\n disabled={isDisabled}\n data-tone={tone === \"danger\" ? \"danger\" : undefined}\n className={cx(\"ds-menu-item\", className)}\n {...rest}\n >\n {icon && <Icon name={icon} size={16} />}\n {children}\n {shortcut && <span className=\"ds-menu-item__shortcut\">{shortcut}</span>}\n </button>\n );\n});\n\nexport function MenuSeparator() {\n return <div className=\"ds-menu-separator\" role=\"separator\" />;\n}\n\nexport function MenuLabel({ children }: { children: ReactNode }) {\n return <div className=\"ds-menu-label\">{children}</div>;\n}\n"],"mappings":";;;;;AAiBA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAqBA,IAAaC,IA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AA;GACrCC;GACAC,KAAY,kBAAC,QAAD;IAAM,WAAU;IAA0B,UAAAA;GAAe,CAAA;EAChE;;AAEZ,CAAC;AAED,SAAgBC,IAAgB;CAC9B,OAAO,kBAAC,OAAD;EAAK,WAAU;EAAoB,MAAK;CAAa,CAAA;AAC9D;AAEA,SAAgBC,EAAU,EAAE,eAAqC;CAC/D,OAAO,kBAAC,OAAD;EAAK,WAAU;EAAiB;CAAc,CAAA;AACvD"}
1
+ {"version":3,"file":"index.js","names":["cx","parts","Menu","forwardRef","rest","isOpen","setOpen","useState","rootRef","useRef","triggerRef","listRef","menuId","useId","close","useCallback","restoreTriggerFocus","useEffect","ref","onPointerDown","target","event","onKeyDown","onListKeyDown","items","index","trigger","open","Popover","className","onClick","MenuItem","Button","tone","icon","children","shortcut","MenuSeparator","MenuLabel"],"sources":["../../../src/components/Menu/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { Popover } from \"../Popover\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport type MenuAlign = \"start\" | \"end\";\n\nexport interface MenuProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Receives the props that open the menu — usually a `Button`. */\n trigger: (props: {\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\"?: string;\n onClick: () => void;\n }) => ReactElement;\n align?: MenuAlign;\n /** Menu items, labels and separators. */\n children: ReactNode;\n}\n\n/**\n * A short list of actions attached to a control. Closes on Escape, on outside\n * click and after any item is chosen; arrow keys walk the items.\n */\nexport const Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu(\n { trigger, align = \"start\", className, children, onClick, onKeyDown, ...rest },\n ref,\n) {\n const [isOpen, setOpen] = useState(false);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const listRef = useRef<HTMLDivElement | null>(null);\n const menuId = useId();\n\n const close = useCallback(() => setOpen(false), []);\n const restoreTriggerFocus = useCallback(() => {\n const focusTarget =\n triggerRef.current?.querySelector<HTMLElement>(\"button, [href], [tabindex]\") ??\n triggerRef.current;\n focusTarget?.focus();\n }, []);\n\n useEffect(() => {\n if (typeof ref === \"function\") ref(listRef.current);\n else if (ref) ref.current = listRef.current;\n }, [isOpen, ref]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const onPointerDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (!rootRef.current?.contains(target) && !listRef.current?.contains(target)) close();\n };\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n restoreTriggerFocus();\n }\n };\n\n document.addEventListener(\"mousedown\", onPointerDown);\n document.addEventListener(\"keydown\", onKeyDown);\n listRef.current?.querySelector<HTMLButtonElement>(\"button:not(:disabled)\")?.focus();\n\n return () => {\n document.removeEventListener(\"mousedown\", onPointerDown);\n document.removeEventListener(\"keydown\", onKeyDown);\n };\n }, [isOpen, close, restoreTriggerFocus]);\n\n const onListKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"ArrowDown\" && event.key !== \"ArrowUp\") return;\n event.preventDefault();\n const items = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>(\"button:not(:disabled)\") ?? [],\n );\n if (items.length === 0) return;\n const index = items.indexOf(document.activeElement as HTMLButtonElement);\n const next =\n event.key === \"ArrowDown\"\n ? items[(index + 1) % items.length]\n : items[(index - 1 + items.length) % items.length];\n next?.focus();\n };\n\n return (\n <div className=\"ds-menu-root\" ref={rootRef}>\n <span ref={triggerRef} className=\"ds-menu-root\">\n {trigger({\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? menuId : undefined,\n onClick: () => setOpen((open) => !open),\n })}\n </span>\n <Popover\n anchorRef={triggerRef}\n isOpen={isOpen}\n align={align}\n offset={8}\n id={menuId}\n role=\"menu\"\n className={cx(\"ds-surface-raised\", \"ds-menu\", className)}\n panelRef={listRef}\n >\n <div\n className=\"ds-menu__list\"\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!event.defaultPrevented) onListKeyDown(event);\n }}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n close();\n restoreTriggerFocus();\n }\n }}\n {...rest}\n >\n {children}\n </div>\n </Popover>\n </div>\n );\n});\n\nexport type MenuItemTone = \"neutral\" | \"danger\";\n\nexport interface MenuItemProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"disabled\"> {\n icon?: IconName;\n tone?: MenuItemTone;\n /** Rendered right-aligned and muted, e.g. \"⌘K\". */\n shortcut?: string;\n isDisabled?: boolean;\n children?: ReactNode;\n}\n\nexport const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(function MenuItem(\n { icon, tone = \"neutral\", shortcut, isDisabled = false, className, children, ...rest },\n ref,\n) {\n return (\n <Button\n ref={ref}\n variant={tone === \"danger\" ? \"danger\" : \"simple\"}\n size=\"sm\"\n iconStart={icon}\n role=\"menuitem\"\n isDisabled={isDisabled}\n data-tone={tone === \"danger\" ? \"danger\" : undefined}\n className={cx(\"ds-menu-item\", className)}\n {...rest}\n >\n {children}\n {shortcut && <span className=\"ds-menu-item__shortcut\">{shortcut}</span>}\n </Button>\n );\n});\n\nexport function MenuSeparator() {\n return <div className=\"ds-menu-separator\" role=\"separator\" />;\n}\n\nexport function MenuLabel({ children }: { children: ReactNode }) {\n return <div className=\"ds-menu-label\">{children}</div>;\n}\n"],"mappings":";;;;;AAiBA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAqBA,IAAaC,IAAOC,EAAsC,SACxD,EAAE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D;GAAM,WAAU;GAA0B,UAAAA;EAAe,CAAA,CAChE;;AAEZ,CAAC;AAED,SAAgBC,IAAgB;CAC9B,OAAO,kBAAC,OAAD;EAAK,WAAU;EAAoB,MAAK;CAAa,CAAA;AAC9D;AAEA,SAAgBC,EAAU,EAAE,eAAqC;CAC/D,OAAO,kBAAC,OAAD;EAAK,WAAU;EAAiB;CAAc,CAAA;AACvD"}
@@ -16,50 +16,12 @@
16
16
  }
17
17
 
18
18
 
19
- .ds-menu-item {
20
- display: flex;
21
- align-items: center;
22
- gap: var(--space-2);
19
+ .ds-menu-item.ds-button {
23
20
  inline-size: 100%;
21
+ height: auto;
24
22
  min-block-size: var(--field-height-sm);
25
- padding: var(--space-1) var(--space-3);
26
- border: var(--control-border-width) solid transparent;
27
- border-radius: var(--radius-sm);
28
- background: transparent;
29
- color: var(--color-text);
30
- font-family: var(--font-sans);
31
- font-size: var(--font-size-sm);
32
- font-weight: var(--font-weight-medium);
33
- line-height: var(--line-height-tight);
23
+ justify-content: flex-start;
34
24
  text-align: start;
35
- cursor: pointer;
36
- transition: background-color var(--duration-fast) var(--ease-standard);
37
- }
38
-
39
- .ds-menu-item:hover:not(:disabled) {
40
- background: var(--field-hover);
41
- }
42
-
43
- .ds-menu-item:active:not(:disabled) {
44
- background: var(--field-pressed);
45
- }
46
-
47
- .ds-menu-item:focus-visible {
48
- outline: var(--control-border-width) solid var(--color-focus);
49
- outline-offset: 2px;
50
- }
51
-
52
- .ds-menu-item[data-tone="danger"] {
53
- color: var(--color-danger-text);
54
- }
55
-
56
- .ds-menu-item[data-tone="danger"]:hover:not(:disabled) {
57
- background: var(--color-danger-soft);
58
- }
59
-
60
- .ds-menu-item:disabled {
61
- opacity: 45%;
62
- cursor: not-allowed;
63
25
  }
64
26
 
65
27
  .ds-menu-item__shortcut {
@@ -70,6 +32,10 @@
70
32
  font-weight: var(--font-weight-regular);
71
33
  }
72
34
 
35
+ .ds-menu-item[data-tone="danger"] .ds-menu-item__shortcut {
36
+ color: inherit;
37
+ }
38
+
73
39
  .ds-menu-separator {
74
40
  block-size: var(--rule-width);
75
41
  margin: var(--space-1) calc(var(--space-2) * -1);
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");let t=require("react"),n=require("react/jsx-runtime"),r=require("react-dom");var i=(0,t.forwardRef)(function({isOpen:i,onClose:a,title:o,description:s,size:c=`md`,footer:l,className:u,children:d,...f},p){let m=(0,t.useRef)(null),h=(0,t.useRef)(a),g=(0,t.useId)(),_=(0,t.useId)();return(0,t.useEffect)(()=>{h.current=a},[a]),(0,t.useEffect)(()=>{if(!i)return;let e=document.activeElement;(m.current?.querySelector(`:is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])`)??m.current)?.focus();let t=e=>{if(e.key===`Escape`){h.current();return}if(e.key!==`Tab`)return;let t=Array.from(m.current?.querySelectorAll(`:is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])`)??[]);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};document.addEventListener(`keydown`,t);let n=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,t),document.body.style.overflow=n,e?.focus()}},[i]),!i||typeof document>`u`?null:(0,r.createPortal)((0,n.jsx)(`div`,{className:`ds-scrim`,onMouseDown:e=>e.target===e.currentTarget&&h.current(),children:(0,n.jsxs)(`div`,{...f,ref:e=>{m.current=e,typeof p==`function`?p(e):p&&(p.current=e)},role:`dialog`,"aria-modal":`true`,"aria-labelledby":g,"aria-describedby":s?_:void 0,tabIndex:-1,"data-size":c,className:[`ds-modal`,u].filter(Boolean).join(` `),children:[(0,n.jsxs)(`header`,{className:`ds-modal__head`,children:[(0,n.jsxs)(`div`,{className:`ds-modal__titles`,children:[(0,n.jsx)(`h2`,{id:g,className:`ds-modal__title`,children:o}),s&&(0,n.jsx)(`p`,{id:_,className:`ds-modal__description`,children:s})]}),(0,n.jsx)(e.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`x`,"aria-label":`Close`,className:`ds-modal__close`,onClick:()=>h.current()})]}),(0,n.jsx)(`div`,{className:`ds-modal__body`,children:d}),l&&(0,n.jsx)(`footer`,{className:`ds-modal__footer`,children:l})]})}),document.body)});exports.Modal=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");let t=require("react"),n=require("react-dom"),r=require("react/jsx-runtime");var i=(0,t.forwardRef)(function({isOpen:i,onClose:a,title:o,description:s,size:c=`md`,footer:l,className:u,children:d,...f},p){let m=(0,t.useRef)(null),h=(0,t.useRef)(a),g=(0,t.useId)(),_=(0,t.useId)();return(0,t.useEffect)(()=>{h.current=a},[a]),(0,t.useEffect)(()=>{if(!i)return;let e=document.activeElement;(m.current?.querySelector(`:is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])`)??m.current)?.focus();let t=e=>{if(e.key===`Escape`){e.preventDefault(),h.current();return}if(e.key!==`Tab`)return;let t=Array.from(m.current?.querySelectorAll(`:is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])`)??[]);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};document.addEventListener(`keydown`,t);let n=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,t),document.body.style.overflow=n,e?.focus()}},[i]),!i||typeof document>`u`?null:(0,n.createPortal)((0,r.jsx)(`div`,{className:`ds-scrim`,onMouseDown:e=>e.target===e.currentTarget&&h.current(),children:(0,r.jsxs)(`div`,{...f,ref:e=>{m.current=e,typeof p==`function`?p(e):p&&(p.current=e)},role:`dialog`,"aria-modal":`true`,"aria-labelledby":g,"aria-describedby":s?_:void 0,tabIndex:-1,"data-size":c,className:[`ds-modal`,u].filter(Boolean).join(` `),children:[(0,r.jsxs)(`header`,{className:`ds-modal__head`,children:[(0,r.jsxs)(`div`,{className:`ds-modal__titles`,children:[(0,r.jsx)(`h2`,{id:g,className:`ds-modal__title`,children:o}),s&&(0,r.jsx)(`p`,{id:_,className:`ds-modal__description`,children:s})]}),(0,r.jsx)(e.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`x`,"aria-label":`Close`,className:`ds-modal__close`,onClick:()=>h.current()})]}),(0,r.jsx)(`div`,{className:`ds-modal__body`,children:d}),l&&(0,r.jsx)(`footer`,{className:`ds-modal__footer`,children:l})]})}),document.body)});exports.Modal=i;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["forwardRef","useRef","useId","createPortal","Button","require_components_Button_index","react","react_jsx_runtime","react_dom","Modal","rest","panelRef","onCloseRef","onClose","titleId","descriptionId","isOpen","previous","onKeyDown","event","focusable","first","last","overflow","node","ref","description","size","className","title","footer"],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type ModalSize = \"dialog\" | \"md\" | \"wide\";\n\nexport interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: string;\n description?: string;\n size?: ModalSize;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A focused task on top of the page. Heavy frame, hairline rules, a quiet\n * footer band — the collection frame, floated. Focus is trapped while open.\n */\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(function Modal(\n { isOpen, onClose, title, description, size = \"md\", footer, className, children, ...rest },\n ref,\n) {\n const panelRef = useRef<HTMLDivElement | null>(null);\n const onCloseRef = useRef(onClose);\n const titleId = useId();\n const descriptionId = useId();\n\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const previous = document.activeElement as HTMLElement | null;\n const initialFocus = panelRef.current?.querySelector<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n );\n (initialFocus ?? panelRef.current)?.focus();\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n onCloseRef.current();\n return;\n }\n if (event.key !== \"Tab\") return;\n const focusable = Array.from(\n panelRef.current?.querySelectorAll<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n ) ?? [],\n );\n if (focusable.length === 0) return;\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n\n return () => {\n document.removeEventListener(\"keydown\", onKeyDown);\n document.body.style.overflow = overflow;\n previous?.focus();\n };\n }, [isOpen]);\n\n if (!isOpen || typeof document === \"undefined\") return null;\n\n return createPortal(\n <div className=\"ds-scrim\" onMouseDown={(event) => event.target === event.currentTarget && onCloseRef.current()}>\n <div\n {...rest}\n ref={(node) => {\n panelRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n tabIndex={-1}\n data-size={size}\n className={[\"ds-modal\", className].filter(Boolean).join(\" \")}\n >\n <header className=\"ds-modal__head\">\n <div className=\"ds-modal__titles\">\n <h2 id={titleId} className=\"ds-modal__title\">\n {title}\n </h2>\n {description && (\n <p id={descriptionId} className=\"ds-modal__description\">\n {description}\n </p>\n )}\n </div>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Close\"\n className=\"ds-modal__close\"\n onClick={() => onCloseRef.current()}\n />\n </header>\n <div className=\"ds-modal__body\">{children}</div>\n {footer && <footer className=\"ds-modal__footer\">{footer}</footer>}\n </div>\n </div>,\n document.body,\n );\n});\n"],"mappings":"A,uLAuBA,IAAaS,GAAA,EAAQT,EAAAA,WAAAA,CAAuC,SAC1D,CAAE,SAAQ,UAAS,QAAO,cAAa,OAAO,KAAM,SAAQ,YAAW,WAAU,GAAGU,GACpF,EACA,CACA,IAAMC,GAAA,EAAWV,EAAAA,OAAAA,CAA8B,IAAI,EAC7CW,GAAA,EAAaX,EAAAA,OAAAA,CAAOY,CAAO,EAC3BC,GAAA,EAAUZ,EAAAA,MAAAA,CAAM,EAChBa,GAAA,EAAgBb,EAAAA,MAAAA,CAAM,EAmD5B,OAjDA,EAAAI,EAAA,UAAA,KAAgB,CACd,EAAW,QAAUO,CACvB,EAAG,CAACA,CAAO,CAAC,GAEZ,EAAAP,EAAA,UAAA,KAAgB,CACd,GAAI,CAACU,EAAQ,OAEb,IAAMC,EAAW,SAAS,eACLN,EAAS,SAAS,cACrC,8FACF,GACiBA,EAAS,QAAA,EAAU,MAAM,EAE1C,IAAMO,EAAa,GAAyB,CAC1C,GAAIC,EAAM,MAAQ,SAAU,CAC1BP,EAAW,QAAQ,EACnB,MACF,CACA,GAAIO,EAAM,MAAQ,MAAO,OACzB,IAAMC,EAAY,MAAM,KACtBT,EAAS,SAAS,iBAChB,8FACF,GAAK,CAAC,CACR,EACA,GAAIS,EAAU,SAAW,EAAG,OAC5B,IAAMC,EAAQD,EAAU,GAClBE,EAAOF,EAAUA,EAAU,OAAS,GACtCD,EAAM,UAAY,SAAS,gBAAkBE,GAC/CF,EAAM,eAAe,EACrBG,EAAK,MAA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,SACR,KAAK,KACL,WAAA,GACA,UAAU,IACV,aAAW,QACX,UAAU,kBACV,YAAeQ,EAAW,QAAQ,CACnC,CAAA,CACK,C,IACR,EAAAL,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,iBAAkB,UAAc,CAAA,EAC9CuB,IAAU,EAAAvB,EAAA,IAAA,CAAC,SAAD,CAAQ,UAAU,mBAAoB,SAAAuB,CAAe,CAAA,CAC7D,C,EACF,CAAA,EACL,SAAS,IACX,CACF,CAAC,E"}
1
+ {"version":3,"file":"index.cjs","names":["forwardRef","useRef","useId","createPortal","Button","require_components_Button_index","react","react_dom","react_jsx_runtime","Modal","rest","panelRef","onCloseRef","onClose","titleId","descriptionId","isOpen","previous","onKeyDown","event","focusable","first","last","overflow","node","ref","description","size","className","title","footer"],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type ModalSize = \"dialog\" | \"md\" | \"wide\";\n\nexport interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: string;\n description?: string;\n size?: ModalSize;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A focused task on top of the page. Heavy frame, hairline rules, a quiet\n * footer band — the collection frame, floated. Focus is trapped while open.\n */\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(function Modal(\n { isOpen, onClose, title, description, size = \"md\", footer, className, children, ...rest },\n ref,\n) {\n const panelRef = useRef<HTMLDivElement | null>(null);\n const onCloseRef = useRef(onClose);\n const titleId = useId();\n const descriptionId = useId();\n\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const previous = document.activeElement as HTMLElement | null;\n const initialFocus = panelRef.current?.querySelector<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n );\n (initialFocus ?? panelRef.current)?.focus();\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onCloseRef.current();\n return;\n }\n if (event.key !== \"Tab\") return;\n const focusable = Array.from(\n panelRef.current?.querySelectorAll<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n ) ?? [],\n );\n if (focusable.length === 0) return;\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n\n return () => {\n document.removeEventListener(\"keydown\", onKeyDown);\n document.body.style.overflow = overflow;\n previous?.focus();\n };\n }, [isOpen]);\n\n if (!isOpen || typeof document === \"undefined\") return null;\n\n return createPortal(\n <div className=\"ds-scrim\" onMouseDown={(event) => event.target === event.currentTarget && onCloseRef.current()}>\n <div\n {...rest}\n ref={(node) => {\n panelRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n tabIndex={-1}\n data-size={size}\n className={[\"ds-modal\", className].filter(Boolean).join(\" \")}\n >\n <header className=\"ds-modal__head\">\n <div className=\"ds-modal__titles\">\n <h2 id={titleId} className=\"ds-modal__title\">\n {title}\n </h2>\n {description && (\n <p id={descriptionId} className=\"ds-modal__description\">\n {description}\n </p>\n )}\n </div>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Close\"\n className=\"ds-modal__close\"\n onClick={() => onCloseRef.current()}\n />\n </header>\n <div className=\"ds-modal__body\">{children}</div>\n {footer && <footer className=\"ds-modal__footer\">{footer}</footer>}\n </div>\n </div>,\n document.body,\n );\n});\n"],"mappings":"A,uLAuBA,IAAaS,GAAA,EAAQT,EAAAA,WAAAA,CAAuC,SAC1D,CAAE,SAAQ,UAAS,QAAO,cAAa,OAAO,KAAM,SAAQ,YAAW,WAAU,GAAGU,GACpF,EACA,CACA,IAAMC,GAAA,EAAWV,EAAAA,OAAAA,CAA8B,IAAI,EAC7CW,GAAA,EAAaX,EAAAA,OAAAA,CAAOY,CAAO,EAC3BC,GAAA,EAAUZ,EAAAA,MAAAA,CAAM,EAChBa,GAAA,EAAgBb,EAAAA,MAAAA,CAAM,EAoD5B,OAlDA,EAAAI,EAAA,UAAA,KAAgB,CACd,EAAW,QAAUO,CACvB,EAAG,CAACA,CAAO,CAAC,GAEZ,EAAAP,EAAA,UAAA,KAAgB,CACd,GAAI,CAACU,EAAQ,OAEb,IAAMC,EAAW,SAAS,eACLN,EAAS,SAAS,cACrC,8FACF,GACiBA,EAAS,QAAA,EAAU,MAAM,EAE1C,IAAMO,EAAa,GAAyB,CAC1C,GAAIC,EAAM,MAAQ,SAAU,CAC1BA,EAAM,eAAe,EACrBP,EAAW,QAAQ,EACnB,MACF,CACA,GAAIO,EAAM,MAAQ,MAAO,OACzB,IAAMC,EAAY,MAAM,KACtBT,EAAS,SAAS,iBAChB,8FACF,GAAK,CAAC,CACR,EACA,GAAIS,EAAU,SAAW,EAAG,OAC5B,IAAMC,EAAQD,EAAU,GAClBE,EAAOF,EAAUA,EAAU,OAAS,GACtCD,EAAM,UAAY,SAAS,gBAAkBE,GAC/CF,EAAM,eAAe,EACrBG,EAAK,MAAM,GACF,CAACH,EAAM,UAAY,SAAS,gBAAkBG,IACvDH,EAAM,eAAe,EACrBE,EAAM,MAAM,EAEhB,EAEA,SAAS,iBAAiB,UAAWH,CAAS,EAC9C,IAAMK,EAAW,SAAS,KAAK,MAA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AkB,UAAc,CAAA,EAC9CsB,IAAU,EAAAtB,EAAA,IAAA,CAAC,SAAD,CAAQ,UAAU,mBAAoB,SAAAsB,CAAe,CAAA,CAC7D,C,EACF,CAAA,EACL,SAAS,IACX,CACF,CAAC,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlG,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,uGAsGhB,CAAC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlG,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,uGAuGhB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlG,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,uGAsGhB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlG,OAAO,aAAa,CAAC;AAErB,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,uGAuGhB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Button as e } from "../Button/index.js";
2
2
  import { forwardRef as t, useEffect as n, useId as r, useRef as i } from "react";
3
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
- import { createPortal as s } from "react-dom";
3
+ import { createPortal as a } from "react-dom";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
5
  //#region src/components/Modal/index.tsx
6
6
  var c = t(function({ isOpen: t, onClose: c, title: l, description: u, size: d = "md", footer: f, className: p, children: m, ...h }, g) {
7
7
  let _ = i(null), v = i(c), y = r(), b = r();
@@ -13,7 +13,7 @@ var c = t(function({ isOpen: t, onClose: c, title: l, description: u, size: d =
13
13
  (_.current?.querySelector(":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])") ?? _.current)?.focus();
14
14
  let n = (e) => {
15
15
  if (e.key === "Escape") {
16
- v.current();
16
+ e.preventDefault(), v.current();
17
17
  return;
18
18
  }
19
19
  if (e.key !== "Tab") return;
@@ -27,10 +27,10 @@ var c = t(function({ isOpen: t, onClose: c, title: l, description: u, size: d =
27
27
  return document.body.style.overflow = "hidden", () => {
28
28
  document.removeEventListener("keydown", n), document.body.style.overflow = r, e?.focus();
29
29
  };
30
- }, [t]), !t || typeof document > "u" ? null : s(/* @__PURE__ */ a("div", {
30
+ }, [t]), !t || typeof document > "u" ? null : a(/* @__PURE__ */ o("div", {
31
31
  className: "ds-scrim",
32
32
  onMouseDown: (e) => e.target === e.currentTarget && v.current(),
33
- children: /* @__PURE__ */ o("div", {
33
+ children: /* @__PURE__ */ s("div", {
34
34
  ...h,
35
35
  ref: (e) => {
36
36
  _.current = e, typeof g == "function" ? g(e) : g && (g.current = e);
@@ -43,20 +43,20 @@ var c = t(function({ isOpen: t, onClose: c, title: l, description: u, size: d =
43
43
  "data-size": d,
44
44
  className: ["ds-modal", p].filter(Boolean).join(" "),
45
45
  children: [
46
- /* @__PURE__ */ o("header", {
46
+ /* @__PURE__ */ s("header", {
47
47
  className: "ds-modal__head",
48
- children: [/* @__PURE__ */ o("div", {
48
+ children: [/* @__PURE__ */ s("div", {
49
49
  className: "ds-modal__titles",
50
- children: [/* @__PURE__ */ a("h2", {
50
+ children: [/* @__PURE__ */ o("h2", {
51
51
  id: y,
52
52
  className: "ds-modal__title",
53
53
  children: l
54
- }), u && /* @__PURE__ */ a("p", {
54
+ }), u && /* @__PURE__ */ o("p", {
55
55
  id: b,
56
56
  className: "ds-modal__description",
57
57
  children: u
58
58
  })]
59
- }), /* @__PURE__ */ a(e, {
59
+ }), /* @__PURE__ */ o(e, {
60
60
  variant: "simple",
61
61
  size: "sm",
62
62
  isIconOnly: !0,
@@ -66,11 +66,11 @@ var c = t(function({ isOpen: t, onClose: c, title: l, description: u, size: d =
66
66
  onClick: () => v.current()
67
67
  })]
68
68
  }),
69
- /* @__PURE__ */ a("div", {
69
+ /* @__PURE__ */ o("div", {
70
70
  className: "ds-modal__body",
71
71
  children: m
72
72
  }),
73
- f && /* @__PURE__ */ a("footer", {
73
+ f && /* @__PURE__ */ o("footer", {
74
74
  className: "ds-modal__footer",
75
75
  children: f
76
76
  })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Modal","forwardRef","rest","panelRef","useRef","onCloseRef","onClose","titleId","useId","descriptionId","useEffect","isOpen","previous","onKeyDown","event","focusable","first","last","overflow","createPortal","node","ref","description","size","className","title","Button","footer"],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type ModalSize = \"dialog\" | \"md\" | \"wide\";\n\nexport interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: string;\n description?: string;\n size?: ModalSize;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A focused task on top of the page. Heavy frame, hairline rules, a quiet\n * footer band — the collection frame, floated. Focus is trapped while open.\n */\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(function Modal(\n { isOpen, onClose, title, description, size = \"md\", footer, className, children, ...rest },\n ref,\n) {\n const panelRef = useRef<HTMLDivElement | null>(null);\n const onCloseRef = useRef(onClose);\n const titleId = useId();\n const descriptionId = useId();\n\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const previous = document.activeElement as HTMLElement | null;\n const initialFocus = panelRef.current?.querySelector<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n );\n (initialFocus ?? panelRef.current)?.focus();\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n onCloseRef.current();\n return;\n }\n if (event.key !== \"Tab\") return;\n const focusable = Array.from(\n panelRef.current?.querySelectorAll<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n ) ?? [],\n );\n if (focusable.length === 0) return;\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n\n return () => {\n document.removeEventListener(\"keydown\", onKeyDown);\n document.body.style.overflow = overflow;\n previous?.focus();\n };\n }, [isOpen]);\n\n if (!isOpen || typeof document === \"undefined\") return null;\n\n return createPortal(\n <div className=\"ds-scrim\" onMouseDown={(event) => event.target === event.currentTarget && onCloseRef.current()}>\n <div\n {...rest}\n ref={(node) => {\n panelRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n tabIndex={-1}\n data-size={size}\n className={[\"ds-modal\", className].filter(Boolean).join(\" \")}\n >\n <header className=\"ds-modal__head\">\n <div className=\"ds-modal__titles\">\n <h2 id={titleId} className=\"ds-modal__title\">\n {title}\n </h2>\n {description && (\n <p id={descriptionId} className=\"ds-modal__description\">\n {description}\n </p>\n )}\n </div>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Close\"\n className=\"ds-modal__close\"\n onClick={() => onCloseRef.current()}\n />\n </header>\n <div className=\"ds-modal__body\">{children}</div>\n {footer && <footer className=\"ds-modal__footer\">{footer}</footer>}\n </div>\n </div>,\n document.body,\n );\n});\n"],"mappings":";;;;;AAuBA,IAAaA,IAAQC,EAAuC,SAC1D,EAAE,WAAQ,YAAS,UAAO,gBAAa,UAAO,MAAM,WAAQ,cAAW,aAAU,GAAGC,KACpF,GACA;CACA,IAAMC,IAAWC,EAA8B,IAAI,GAC7CC,IAAaD,EAAOE,CAAO,GAC3BC,IAAUC,EAAM,GAChBC,IAAgBD,EAAM;CAmD5B,OAjDAE,QAAgB;EACd,EAAW,UAAUJ;CACvB,GAAG,CAACA,CAAO,CAAC,GAEZI,QAAgB;EACd,IAAI,CAACC,GAAQ;EAEb,IAAMC,IAAW,SAAS;EAI1B,CAHqBT,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AA;IAeE,kBAAC,UAAD;KAAQ,WAAU;KAAlB,UAAA,CACE,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,MAAD;OAAI,IAAIjB;OAAS,WAAU;OACxB,UAAAkB;MACC,CAAA,GACHH,KACC,kBAAC,KAAD;OAAG,IAAIb;OAAe,WAAU;OAC7B,UAAAa;MACA,CAAA,CAEF;KACL,CAAA,GAAA,kBAACI,GAAD;MACE,SAAQ;MACR,MAAK;MACL,YAAA;MACA,WAAU;MACV,cAAW;MACX,WAAU;MACV,eAAerB,EAAW,QAAQ;KACnC,CAAA,CACK;;IACR,kBAAC,OAAD;KAAK,WAAU;KAAkB;IAAc,CAAA;IAC9CsB,KAAU,kBAAC,UAAD;KAAQ,WAAU;KAAoB,UAAAA;IAAe,CAAA;GAC7D;;CACF,CAAA,GACL,SAAS,IACX;AACF,CAAC"}
1
+ {"version":3,"file":"index.js","names":["Modal","forwardRef","rest","panelRef","useRef","onCloseRef","onClose","titleId","useId","descriptionId","useEffect","isOpen","previous","onKeyDown","event","focusable","first","last","overflow","createPortal","node","ref","description","size","className","title","Button","footer"],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type ModalSize = \"dialog\" | \"md\" | \"wide\";\n\nexport interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n isOpen: boolean;\n /** Escape, the scrim and the close button all call this. */\n onClose: () => void;\n title: string;\n description?: string;\n size?: ModalSize;\n /** Actions, right-aligned. The confirming action goes last. */\n footer?: ReactNode;\n children?: ReactNode;\n}\n\n/**\n * A focused task on top of the page. Heavy frame, hairline rules, a quiet\n * footer band — the collection frame, floated. Focus is trapped while open.\n */\nexport const Modal = forwardRef<HTMLDivElement, ModalProps>(function Modal(\n { isOpen, onClose, title, description, size = \"md\", footer, className, children, ...rest },\n ref,\n) {\n const panelRef = useRef<HTMLDivElement | null>(null);\n const onCloseRef = useRef(onClose);\n const titleId = useId();\n const descriptionId = useId();\n\n useEffect(() => {\n onCloseRef.current = onClose;\n }, [onClose]);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const previous = document.activeElement as HTMLElement | null;\n const initialFocus = panelRef.current?.querySelector<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n );\n (initialFocus ?? panelRef.current)?.focus();\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onCloseRef.current();\n return;\n }\n if (event.key !== \"Tab\") return;\n const focusable = Array.from(\n panelRef.current?.querySelectorAll<HTMLElement>(\n \":is(button, [href], input, select, textarea, [tabindex]):not(:disabled):not([tabindex='-1'])\",\n ) ?? [],\n );\n if (focusable.length === 0) return;\n const first = focusable[0]!;\n const last = focusable[focusable.length - 1]!;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n\n return () => {\n document.removeEventListener(\"keydown\", onKeyDown);\n document.body.style.overflow = overflow;\n previous?.focus();\n };\n }, [isOpen]);\n\n if (!isOpen || typeof document === \"undefined\") return null;\n\n return createPortal(\n <div className=\"ds-scrim\" onMouseDown={(event) => event.target === event.currentTarget && onCloseRef.current()}>\n <div\n {...rest}\n ref={(node) => {\n panelRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descriptionId : undefined}\n tabIndex={-1}\n data-size={size}\n className={[\"ds-modal\", className].filter(Boolean).join(\" \")}\n >\n <header className=\"ds-modal__head\">\n <div className=\"ds-modal__titles\">\n <h2 id={titleId} className=\"ds-modal__title\">\n {title}\n </h2>\n {description && (\n <p id={descriptionId} className=\"ds-modal__description\">\n {description}\n </p>\n )}\n </div>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label=\"Close\"\n className=\"ds-modal__close\"\n onClick={() => onCloseRef.current()}\n />\n </header>\n <div className=\"ds-modal__body\">{children}</div>\n {footer && <footer className=\"ds-modal__footer\">{footer}</footer>}\n </div>\n </div>,\n document.body,\n );\n});\n"],"mappings":";;;;;AAuBA,IAAaA,IAAQC,EAAuC,SAC1D,EAAE,WAAQ,YAAS,UAAO,gBAAa,UAAO,MAAM,WAAQ,cAAW,aAAU,GAAGC,KACpF,GACA;CACA,IAAMC,IAAWC,EAA8B,IAAI,GAC7CC,IAAaD,EAAOE,CAAO,GAC3BC,IAAUC,EAAM,GAChBC,IAAgBD,EAAM;CAoD5B,OAlDAE,QAAgB;EACd,EAAW,UAAUJ;CACvB,GAAG,CAACA,CAAO,CAAC,GAEZI,QAAgB;EACd,IAAI,CAACC,GAAQ;EAEb,IAAMC,IAAW,SAAS;EAI1B,CAHqBT,EAAS,SAAS,cACrC,8FACF,KACiBA,EAAS,QAAA,EAAU,MAAM;EAE1C,IAAMU,KAAa,MAAyB;GAC1C,IAAIC,EAAM,QAAQ,UAAU;IAE1B,AADAA,EAAM,eAAe,GACrBT,EAAW,QAAQ;IACnB;GACF;GACA,IAAIS,EAAM,QAAQ,OAAO;GACzB,IAAMC,IAAY,MAAM,KACtBZ,EAAS,SAAS,iBAChB,8FACF,KAAK,CAAC,CACR;GACA,IAAIY,EAAU,WAAW,GAAG;GAC5B,IAAMC,IAAQD,EAAU,IAClBE,IAAOF,EAAUA,EAAU,SAAS;GAC1C,AAAID,EAAM,YAAY,SAAS,kBAAkBE,KAC/CF,EAAM,eAAe,GACrBG,EAAK,MAAM,KACF,CAACH,EAAM,YAAY,SAAS,kBAAkBG,MACvDH,EAAM,eAAe,GACrB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Ae,CAAA;GAC7D;;CACF,CAAA,GACL,SAAS,IACX;AACF,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CWsA1W83.cjs");;/* empty css */const t=require("../FieldAffix/index.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=(0,n.forwardRef)(function({size:a=`md`,value:o,defaultValue:s=``,onValueChange:c,min:l,max:u,step:d=1,prefix:f,suffix:p,isDisabled:m=!1,isInvalid:h=!1,hasSteppers:g=!0,className:_,disabled:v,"aria-invalid":y,...b},x){let[S,C]=(0,n.useState)(s),w=o??S,T=(0,n.useRef)(null),E=(0,n.useCallback)(e=>{o===void 0&&C(e),c?.(e)},[c,o]),D=e=>{let t=(w===``?l??0:w)+e*(d===`any`?1:d);l!==void 0&&(t=Math.max(l,t)),u!==void 0&&(t=Math.min(u,t)),t=Number(t.toFixed(10)),E(t),T.current?.focus()},O=w!==``&&(l!==void 0&&w<l||u!==void 0&&w>u);return(0,r.jsxs)(`div`,{className:i(`ds-number`,_),"data-size":a,children:[g&&(0,r.jsx)(`button`,{type:`button`,className:`ds-number__step`,"aria-label":`Decrease`,disabled:m||v||l!==void 0&&w!==``&&w<=l,onClick:()=>D(-1),children:(0,r.jsx)(e.t,{name:`minus`,size:16})}),(0,r.jsx)(t.FieldAffix,{className:`ds-number__body`,lead:f,trail:p,children:(0,r.jsx)(`input`,{ref:e=>{T.current=e,typeof x==`function`?x(e):x&&(x.current=e)},type:`number`,inputMode:`decimal`,value:w,min:l,max:u,step:d,disabled:m||v,"aria-invalid":h||O||y||void 0,"data-size":a,className:`ds-field-skin ds-number__input`,onChange:e=>{let t=e.target.value;E(t===``?``:Number(t))},...b})}),g&&(0,r.jsx)(`button`,{type:`button`,className:`ds-number__step`,"aria-label":`Increase`,disabled:m||v||u!==void 0&&w!==``&&w>=u,onClick:()=>D(1),children:(0,r.jsx)(e.t,{name:`plus`,size:16})})]})});function o({value:e,defaultValue:t={min:``,max:``},onValueChange:i,size:o=`md`,min:s,max:c,step:l=1,prefix:u,suffix:d,isDisabled:f=!1,minLabel:p=`Minimum`,maxLabel:m=`Maximum`}){let[h,g]=(0,n.useState)(t),_=e??h,v=t=>{e===void 0&&g(t),i?.(t)},y=_.min!==``&&_.max!==``&&_.min>_.max;return(0,r.jsxs)(`div`,{className:`ds-number-range`,children:[(0,r.jsx)(a,{"aria-label":p,size:o,value:_.min,min:s,max:c,step:l,prefix:u,suffix:d,isDisabled:f,isInvalid:y,onValueChange:e=>v({..._,min:e})}),(0,r.jsx)(`span`,{className:`ds-number-range__dash`,"aria-hidden":`true`,children:`–`}),(0,r.jsx)(a,{"aria-label":m,size:o,value:_.max,min:s,max:c,step:l,prefix:u,suffix:d,isDisabled:f,isInvalid:y,onValueChange:e=>v({..._,max:e})})]})}exports.NumberField=a,exports.NumberRangeField=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");;/* empty css */const t=require("../FieldAffix/index.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=(0,n.forwardRef)(function({size:a=`md`,value:o,defaultValue:s=``,onValueChange:c,min:l,max:u,step:d=1,prefix:f,suffix:p,isDisabled:m=!1,isInvalid:h=!1,hasSteppers:g=!0,className:_,disabled:v,"aria-invalid":y,...b},x){let[S,C]=(0,n.useState)(s),w=o??S,T=(0,n.useRef)(null),E=(0,n.useCallback)(e=>{o===void 0&&C(e),c?.(e)},[c,o]),D=e=>{let t=(w===``?l??0:w)+e*(d===`any`?1:d);l!==void 0&&(t=Math.max(l,t)),u!==void 0&&(t=Math.min(u,t)),t=Number(t.toFixed(10)),E(t),T.current?.focus()},O=w!==``&&(l!==void 0&&w<l||u!==void 0&&w>u);return(0,r.jsxs)(`div`,{className:i(`ds-number`,_),"data-size":a,children:[g&&(0,r.jsx)(e.Button,{size:a,isIconOnly:!0,iconStart:`minus`,className:`ds-number__step`,"aria-label":`Decrease`,isDisabled:m||v||l!==void 0&&w!==``&&w<=l,onClick:()=>D(-1)}),(0,r.jsx)(t.FieldAffix,{className:`ds-number__body`,lead:f,trail:p,children:(0,r.jsx)(`input`,{ref:e=>{T.current=e,typeof x==`function`?x(e):x&&(x.current=e)},type:`number`,inputMode:`decimal`,value:w,min:l,max:u,step:d,disabled:m||v,"aria-invalid":h||O||y||void 0,"data-size":a,className:`ds-field-skin ds-number__input`,onChange:e=>{let t=e.target.value;E(t===``?``:Number(t))},...b})}),g&&(0,r.jsx)(e.Button,{size:a,isIconOnly:!0,iconStart:`plus`,className:`ds-number__step`,"aria-label":`Increase`,isDisabled:m||v||u!==void 0&&w!==``&&w>=u,onClick:()=>D(1)})]})});function o({value:e,defaultValue:t={min:``,max:``},onValueChange:i,size:o=`md`,min:s,max:c,step:l=1,prefix:u,suffix:d,isDisabled:f=!1,minLabel:p=`Minimum`,maxLabel:m=`Maximum`}){let[h,g]=(0,n.useState)(t),_=e??h,v=t=>{e===void 0&&g(t),i?.(t)},y=_.min!==``&&_.max!==``&&_.min>_.max;return(0,r.jsxs)(`div`,{className:`ds-number-range`,children:[(0,r.jsx)(a,{"aria-label":p,size:o,value:_.min,min:s,max:c,step:l,prefix:u,suffix:d,isDisabled:f,isInvalid:y,onValueChange:e=>v({..._,min:e})}),(0,r.jsx)(`span`,{className:`ds-number-range__dash`,"aria-hidden":`true`,children:`–`}),(0,r.jsx)(a,{"aria-label":m,size:o,value:_.max,min:s,max:c,step:l,prefix:u,suffix:d,isDisabled:f,isInvalid:y,onValueChange:e=>v({..._,max:e})})]})}exports.NumberField=a,exports.NumberRangeField=o;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","useCallback","Icon","FieldAffix","require_Icon","require_components_FieldAffix_index","react","react_jsx_runtime","cx","parts","NumberField","ariaInvalid","rest","internal","setInternal","defaultValue","current","value","inputRef","commit","next","onValueChange","nudge","min","direction","step","max","outOfRange","className","size","hasSteppers","isDisabled","disabled","prefix","suffix","node","ref","isInvalid","raw","event","NumberRangeField","crossed","minLabel","maxLabel"],"sources":["../../../src/components/NumberField/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useRef,\n useState,\n type InputHTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport type { FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface NumberFieldProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\" | \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"prefix\"> {\n size?: FieldSize;\n value?: number | \"\";\n defaultValue?: number | \"\";\n onValueChange?: (value: number | \"\") => void;\n min?: number;\n max?: number;\n step?: number | \"any\";\n /** Rendered inside the field, before the number — \"£\", \"$\", a glyph. */\n prefix?: ReactNode;\n /** Rendered inside the field, after the number — \"kg\", \"%\", \"px\". */\n suffix?: ReactNode;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Hide the − / + steppers and keep typing only. */\n hasSteppers?: boolean;\n}\n\n\n/**\n * A quantity, bounded by `min` and `max`. Steppers move by `step` and stop at\n * the bounds; typing is never blocked, an out-of-range value reads invalid.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n size = \"md\",\n value,\n defaultValue = \"\",\n onValueChange,\n min,\n max,\n step = 1,\n prefix,\n suffix,\n\n isDisabled = false,\n isInvalid = false,\n hasSteppers = true,\n className,\n disabled,\n \"aria-invalid\": ariaInvalid,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<number | \"\">(defaultValue);\n const current = value ?? internal;\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = useCallback(\n (next: number | \"\") => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n },\n [onValueChange, value],\n );\n\n const nudge = (direction: 1 | -1) => {\n const base = current === \"\" ? (min ?? 0) : current;\n let next = base + direction * (step === \"any\" ? 1 : step);\n if (min !== undefined) next = Math.max(min, next);\n if (max !== undefined) next = Math.min(max, next);\n next = Number(next.toFixed(10));\n commit(next);\n inputRef.current?.focus();\n };\n\n const outOfRange =\n current !== \"\" &&\n ((min !== undefined && current < min) || (max !== undefined && current > max));\n\n return (\n <div className={cx(\"ds-number\", className)} data-size={size}>\n {hasSteppers && (\n <button\n type=\"button\"\n className=\"ds-number__step\"\n aria-label=\"Decrease\"\n disabled={isDisabled || disabled || (min !== undefined && current !== \"\" && current <= min)}\n onClick={() => nudge(-1)}\n >\n <Icon name=\"minus\" size={16} />\n </button>\n )}\n <FieldAffix className=\"ds-number__body\" lead={prefix} trail={suffix}>\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"number\"\n inputMode=\"decimal\"\n value={current}\n min={min}\n max={max}\n step={step}\n disabled={isDisabled || disabled}\n aria-invalid={isInvalid || outOfRange || ariaInvalid || undefined}\n data-size={size}\n className=\"ds-field-skin ds-number__input\"\n onChange={(event) => {\n const raw = event.target.value;\n commit(raw === \"\" ? \"\" : Number(raw));\n }}\n {...rest}\n />\n </FieldAffix>\n\n {hasSteppers && (\n <button\n type=\"button\"\n className=\"ds-number__step\"\n aria-label=\"Increase\"\n disabled={isDisabled || disabled || (max !== undefined && current !== \"\" && current >= max)}\n onClick={() => nudge(1)}\n >\n <Icon name=\"plus\" size={16} />\n </button>\n )}\n </div>\n );\n});\n\nexport interface NumberRangeValue {\n min: number | \"\";\n max: number | \"\";\n}\n\nexport interface NumberRangeFieldProps {\n value?: NumberRangeValue;\n defaultValue?: NumberRangeValue;\n onValueChange?: (value: NumberRangeValue) => void;\n size?: FieldSize;\n /** Hard bounds both ends are clamped to. */\n min?: number;\n max?: number;\n step?: number;\n /** Rendered inside both fields, before the number. */\n prefix?: ReactNode;\n suffix?: ReactNode;\n isDisabled?: boolean;\n minLabel?: string;\n maxLabel?: string;\n}\n\n/**\n * A lower and an upper bound, typed. The pair reads invalid when the minimum\n * passes the maximum — neither field is rewritten behind the user.\n */\nexport function NumberRangeField({\n value,\n defaultValue = { min: \"\", max: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n step = 1,\n prefix,\n suffix,\n isDisabled = false,\n minLabel = \"Minimum\",\n maxLabel = \"Maximum\",\n}: NumberRangeFieldProps) {\n const [internal, setInternal] = useState<NumberRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: NumberRangeValue) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const crossed = current.min !== \"\" && current.max !== \"\" && current.min > current.max;\n\n return (\n <div className=\"ds-number-range\">\n <NumberField\n aria-label={minLabel}\n size={size}\n value={current.min}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, min: next })}\n />\n <span className=\"ds-number-range__dash\" aria-hidden=\"true\">\n –\n </span>\n <NumberField\n aria-label={maxLabel}\n size={size}\n value={current.max}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, max: next })}\n />\n </div>\n );\n}\n"],"mappings":"A,iQAcA,SAASU,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CA0BA,IAAaC,GAAA,EAAcZ,EAAAA,WAAAA,CAA+C,SACxE,CACE,OAAO,KACP,QACA,eAAe,GACf,gBACA,MACA,MACA,OAAO,EACP,SACA,SAEA,aAAa,GACb,YAAY,GACZ,cAAc,GACd,YACA,WACA,eAAgBa,EAChB,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,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UAAWyB,EACX,cAAgB,GAAStB,EAAO,CAAE,GAAGH,EAAS,IAAKI,CAAK,CAAC,CAC1D,CAAA,GACD,EAAAb,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,wBAAwB,cAAY,OAAO,SAAA,GAErD,CAAA,GACN,EAAAA,EAAA,IAAA,CAACG,EAAD,CACE,aAAYiC,EACN,OACN,MAAO3B,EAAQ,IACV,MACA,MACC,OACE,SACA,SACI,aACZ,UAAWyB,EACX,cAAgB,GAAStB,EAAO,CAAE,GAAGH,EAAS,IAAKI,CAAK,CAAC,CAC1D,CAAA,CACE,C,EAET,C"}
1
+ {"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","useCallback","Button","FieldAffix","require_components_Button_index","require_components_FieldAffix_index","react","react_jsx_runtime","cx","parts","NumberField","ariaInvalid","rest","internal","setInternal","defaultValue","current","value","inputRef","commit","next","onValueChange","nudge","min","direction","step","max","outOfRange","className","size","hasSteppers","isDisabled","disabled","prefix","suffix","node","ref","isInvalid","raw","event","NumberRangeField","crossed","minLabel","maxLabel"],"sources":["../../../src/components/NumberField/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useRef,\n useState,\n type InputHTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../Button\";\nimport { FieldAffix } from \"../FieldAffix\";\nimport type { FieldSize } from \"../Field\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface NumberFieldProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\" | \"type\" | \"value\" | \"defaultValue\" | \"onChange\" | \"prefix\"> {\n size?: FieldSize;\n value?: number | \"\";\n defaultValue?: number | \"\";\n onValueChange?: (value: number | \"\") => void;\n min?: number;\n max?: number;\n step?: number | \"any\";\n /** Rendered inside the field, before the number — \"£\", \"$\", a glyph. */\n prefix?: ReactNode;\n /** Rendered inside the field, after the number — \"kg\", \"%\", \"px\". */\n suffix?: ReactNode;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Hide the − / + steppers and keep typing only. */\n hasSteppers?: boolean;\n}\n\n\n/**\n * A quantity, bounded by `min` and `max`. Steppers move by `step` and stop at\n * the bounds; typing is never blocked, an out-of-range value reads invalid.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n size = \"md\",\n value,\n defaultValue = \"\",\n onValueChange,\n min,\n max,\n step = 1,\n prefix,\n suffix,\n\n isDisabled = false,\n isInvalid = false,\n hasSteppers = true,\n className,\n disabled,\n \"aria-invalid\": ariaInvalid,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<number | \"\">(defaultValue);\n const current = value ?? internal;\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = useCallback(\n (next: number | \"\") => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n },\n [onValueChange, value],\n );\n\n const nudge = (direction: 1 | -1) => {\n const base = current === \"\" ? (min ?? 0) : current;\n let next = base + direction * (step === \"any\" ? 1 : step);\n if (min !== undefined) next = Math.max(min, next);\n if (max !== undefined) next = Math.min(max, next);\n next = Number(next.toFixed(10));\n commit(next);\n inputRef.current?.focus();\n };\n\n const outOfRange =\n current !== \"\" &&\n ((min !== undefined && current < min) || (max !== undefined && current > max));\n\n return (\n <div className={cx(\"ds-number\", className)} data-size={size}>\n {hasSteppers && (\n <Button\n size={size}\n isIconOnly\n iconStart=\"minus\"\n className=\"ds-number__step\"\n aria-label=\"Decrease\"\n isDisabled={isDisabled || disabled || (min !== undefined && current !== \"\" && current <= min)}\n onClick={() => nudge(-1)}\n />\n )}\n <FieldAffix className=\"ds-number__body\" lead={prefix} trail={suffix}>\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"number\"\n inputMode=\"decimal\"\n value={current}\n min={min}\n max={max}\n step={step}\n disabled={isDisabled || disabled}\n aria-invalid={isInvalid || outOfRange || ariaInvalid || undefined}\n data-size={size}\n className=\"ds-field-skin ds-number__input\"\n onChange={(event) => {\n const raw = event.target.value;\n commit(raw === \"\" ? \"\" : Number(raw));\n }}\n {...rest}\n />\n </FieldAffix>\n\n {hasSteppers && (\n <Button\n size={size}\n isIconOnly\n iconStart=\"plus\"\n className=\"ds-number__step\"\n aria-label=\"Increase\"\n isDisabled={isDisabled || disabled || (max !== undefined && current !== \"\" && current >= max)}\n onClick={() => nudge(1)}\n />\n )}\n </div>\n );\n});\n\nexport interface NumberRangeValue {\n min: number | \"\";\n max: number | \"\";\n}\n\nexport interface NumberRangeFieldProps {\n value?: NumberRangeValue;\n defaultValue?: NumberRangeValue;\n onValueChange?: (value: NumberRangeValue) => void;\n size?: FieldSize;\n /** Hard bounds both ends are clamped to. */\n min?: number;\n max?: number;\n step?: number;\n /** Rendered inside both fields, before the number. */\n prefix?: ReactNode;\n suffix?: ReactNode;\n isDisabled?: boolean;\n minLabel?: string;\n maxLabel?: string;\n}\n\n/**\n * A lower and an upper bound, typed. The pair reads invalid when the minimum\n * passes the maximum — neither field is rewritten behind the user.\n */\nexport function NumberRangeField({\n value,\n defaultValue = { min: \"\", max: \"\" },\n onValueChange,\n size = \"md\",\n min,\n max,\n step = 1,\n prefix,\n suffix,\n isDisabled = false,\n minLabel = \"Minimum\",\n maxLabel = \"Maximum\",\n}: NumberRangeFieldProps) {\n const [internal, setInternal] = useState<NumberRangeValue>(defaultValue);\n const current = value ?? internal;\n\n const commit = (next: NumberRangeValue) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const crossed = current.min !== \"\" && current.max !== \"\" && current.min > current.max;\n\n return (\n <div className=\"ds-number-range\">\n <NumberField\n aria-label={minLabel}\n size={size}\n value={current.min}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, min: next })}\n />\n <span className=\"ds-number-range__dash\" aria-hidden=\"true\">\n –\n </span>\n <NumberField\n aria-label={maxLabel}\n size={size}\n value={current.max}\n min={min}\n max={max}\n step={step}\n prefix={prefix}\n suffix={suffix}\n isDisabled={isDisabled}\n isInvalid={crossed}\n onValueChange={(next) => commit({ ...current, max: next })}\n />\n </div>\n );\n}\n"],"mappings":"A,sPAcA,SAASU,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CA0BA,IAAaC,GAAA,EAAcZ,EAAAA,WAAAA,CAA+C,SACxE,CACE,OAAO,KACP,QACA,eAAe,GACf,gBACA,MACA,MACA,OAAO,EACP,SACA,SAEA,aAAa,GACb,YAAY,GACZ,cAAc,GACd,YACA,WACA,eAAgBa,EAChB,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAef,EAAAA,SAAAA,CAAsBgB,CAAY,EAC5DC,EAAUC,GAASJ,EACnBK,GAAA,EAAWlB,EAAAA,OAAAA,CAAgC,IAAI,EAE/CmB,GAAA,EAASlB,EAAAA,YAAAA,CACZ,GAAsB,CACjBgB,IAAU,IAAA,IAAWH,EAAYM,CAAI,EACzCC,IAAgBD,CAAI,CACtB,EACA,CAACC,EAAeJ,CAAK,CACvB,EAEMK,EAAS,GAAsB,CAEnC,IAAIF,GADSJ,IAAY,GAAMO,GAAO,EAAKP,GACzBQ,GAAaC,IAAS,MAAQ,EAAIA,GAChDF,IAAQ,IAAA,KAAW,EAAO,KAAK,IAAIA,EAAKH,CAAI,GAC5CM,IAAQ,IAAA,KAAW,EAAO,KAAK,IAAIA,EAAKN,CAAI,GAChD,EAAO,OAAOA,EAAK,QAAQ,EAAE,CAAC,EAC9BD,EAAOC,CAAI,EACXF,EAAS,SAAS,MAAM,CAC1B,EAEMS,EACJX,IAAY,KACVO,IAAQ,IAAA,IAAaP,EAAUO,GAASG,IAAQ,IAAA,IAAaV,EAAUU,GAE3E,OACE,EAAAnB,EAAA,KAAA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