@arc-ui/components 11.0.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/Align/Align.esm.js +4 -4
  2. package/dist/Badge/Badge.cjs.d.ts +26 -0
  3. package/dist/Badge/Badge.cjs.js +37 -0
  4. package/dist/Badge/Badge.esm.d.ts +26 -0
  5. package/dist/Badge/Badge.esm.js +29 -0
  6. package/dist/Badge/package.json +7 -0
  7. package/dist/Base/Base.cjs.d.ts +1 -16
  8. package/dist/Base/Base.cjs.js +4 -16
  9. package/dist/Base/Base.esm.d.ts +1 -16
  10. package/dist/Base/Base.esm.js +3 -15
  11. package/dist/BrandLogo/BrandLogo.esm.d.ts +1 -1
  12. package/dist/BrandLogo/BrandLogo.esm.js +2 -2
  13. package/dist/Breadcrumbs/Breadcrumbs.esm.js +27 -27
  14. package/dist/Button/Button.esm.d.ts +1 -1
  15. package/dist/Button/Button.esm.js +4 -4
  16. package/dist/Card/Card.esm.js +27 -27
  17. package/dist/Checkbox/Checkbox.cjs.js +4 -1
  18. package/dist/Checkbox/Checkbox.esm.js +18 -15
  19. package/dist/Clock/Clock.esm.js +3 -3
  20. package/dist/Columns/Columns.esm.js +5 -5
  21. package/dist/Curve/Curve.esm.d.ts +1 -1
  22. package/dist/Curve/Curve.esm.js +1 -1
  23. package/dist/Disclosure/Disclosure.esm.d.ts +1 -1
  24. package/dist/Disclosure/Disclosure.esm.js +10 -10
  25. package/dist/Elevation/Elevation.esm.js +2 -2
  26. package/dist/FormControl/FormControl.cjs.d.ts +1 -1
  27. package/dist/FormControl/FormControl.cjs.js +4 -1
  28. package/dist/FormControl/FormControl.esm.d.ts +1 -1
  29. package/dist/FormControl/FormControl.esm.js +5 -2
  30. package/dist/Group/Group.esm.js +6 -6
  31. package/dist/Heading/Heading.esm.d.ts +1 -1
  32. package/dist/Heading/Heading.esm.js +2 -2
  33. package/dist/Icon/Icon.esm.d.ts +1 -1
  34. package/dist/Icon/Icon.esm.js +2 -2
  35. package/dist/Image/Image.esm.d.ts +1 -1
  36. package/dist/Image/Image.esm.js +1 -1
  37. package/dist/Markup/Markup.esm.js +3 -3
  38. package/dist/Poster/Poster.esm.d.ts +1 -1
  39. package/dist/Poster/Poster.esm.js +9 -9
  40. package/dist/RadioGroup/RadioGroup.cjs.d.ts +1 -1
  41. package/dist/RadioGroup/RadioGroup.cjs.js +4 -1
  42. package/dist/RadioGroup/RadioGroup.esm.d.ts +1 -1
  43. package/dist/RadioGroup/RadioGroup.esm.js +15 -12
  44. package/dist/Rule/Rule.esm.js +3 -3
  45. package/dist/Section/Section.esm.d.ts +1 -1
  46. package/dist/Section/Section.esm.js +1 -1
  47. package/dist/Select/Select.cjs.d.ts +25 -0
  48. package/dist/Select/Select.cjs.js +2611 -0
  49. package/dist/Select/Select.esm.d.ts +25 -0
  50. package/dist/Select/Select.esm.js +2584 -0
  51. package/dist/Select/package.json +7 -0
  52. package/dist/SiteFooter/SiteFooter.esm.js +33 -33
  53. package/dist/SiteHeader/SiteHeader.esm.d.ts +1 -1
  54. package/dist/SiteHeader/SiteHeader.esm.js +98 -98
  55. package/dist/Surface/Surface.esm.d.ts +1 -1
  56. package/dist/Surface/Surface.esm.js +1 -1
  57. package/dist/Switch/Switch.cjs.d.ts +40 -0
  58. package/dist/Switch/Switch.cjs.js +210 -0
  59. package/dist/Switch/Switch.esm.d.ts +40 -0
  60. package/dist/Switch/Switch.esm.js +202 -0
  61. package/dist/Switch/package.json +7 -0
  62. package/dist/Text/Text.esm.d.ts +1 -1
  63. package/dist/Text/Text.esm.js +2 -2
  64. package/dist/TextInput/TextInput.cjs.d.ts +5 -1
  65. package/dist/TextInput/TextInput.cjs.js +25 -6
  66. package/dist/TextInput/TextInput.esm.d.ts +5 -1
  67. package/dist/TextInput/TextInput.esm.js +28 -9
  68. package/dist/Truncate/Truncate.cjs.d.ts +18 -0
  69. package/dist/Truncate/Truncate.cjs.js +17 -0
  70. package/dist/Truncate/Truncate.esm.d.ts +18 -0
  71. package/dist/Truncate/Truncate.esm.js +9 -0
  72. package/dist/Truncate/package.json +7 -0
  73. package/dist/UniversalHeader/UniversalHeader.esm.js +8 -8
  74. package/dist/VerticalSpace/VerticalSpace.cjs.d.ts +1 -18
  75. package/dist/VerticalSpace/VerticalSpace.cjs.js +5 -20
  76. package/dist/VerticalSpace/VerticalSpace.esm.d.ts +1 -18
  77. package/dist/VerticalSpace/VerticalSpace.esm.js +4 -19
  78. package/dist/VisuallyHidden/VisuallyHidden.cjs.d.ts +1 -12
  79. package/dist/VisuallyHidden/VisuallyHidden.cjs.js +3 -12
  80. package/dist/VisuallyHidden/VisuallyHidden.esm.d.ts +1 -12
  81. package/dist/VisuallyHidden/VisuallyHidden.esm.js +2 -11
  82. package/dist/_shared/cjs/Base-e2b846fe.d.ts +19 -0
  83. package/dist/_shared/cjs/Base-e2b846fe.js +22 -0
  84. package/dist/_shared/cjs/BtIconTickAlt2Px-b12ecc78.js +425 -0
  85. package/dist/_shared/cjs/{FormControl-a1b7421b.d.ts → FormControl-e6b7d7c5.d.ts} +51 -3
  86. package/dist/_shared/cjs/{FormControl-a1b7421b.js → FormControl-e6b7d7c5.js} +40 -8
  87. package/dist/_shared/cjs/VerticalSpace-65ad083c.d.ts +18 -0
  88. package/dist/_shared/cjs/VerticalSpace-65ad083c.js +25 -0
  89. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.d.ts +12 -0
  90. package/dist/_shared/cjs/VisuallyHidden-e2c8b291.js +17 -0
  91. package/dist/_shared/cjs/index-c81c9401.d.ts +1 -1
  92. package/dist/_shared/esm/Base-c235dc45.d.ts +19 -0
  93. package/dist/_shared/esm/Base-c235dc45.js +15 -0
  94. package/dist/_shared/esm/{BrandLogo-ea3dd0e6.js → BrandLogo-4f13fe85.js} +4 -4
  95. package/dist/_shared/esm/{BtIconChevronDown2Px-4abd079b.js → BtIconChevronDown2Px-782876e2.js} +2 -2
  96. package/dist/_shared/esm/{BtIconChevronRight2Px-a5cc1d05.js → BtIconChevronRight2Px-b8e7b4ad.js} +3 -3
  97. package/dist/_shared/esm/{BtIconChevronRightMid-386cf272.js → BtIconChevronRightMid-d9b11761.js} +2 -2
  98. package/dist/_shared/esm/BtIconTickAlt2Px-2c4ec3be.js +408 -0
  99. package/dist/_shared/esm/{Button-5ff56a7b.js → Button-69439f8f.js} +15 -15
  100. package/dist/_shared/esm/{Curve-cfdca379.js → Curve-50697f7e.js} +2 -2
  101. package/dist/_shared/esm/{FormControl-feedc495.d.ts → FormControl-84c9ace6.d.ts} +51 -3
  102. package/dist/_shared/esm/FormControl-84c9ace6.js +138 -0
  103. package/dist/_shared/esm/{Heading-183be76c.js → Heading-eb1e42db.js} +4 -4
  104. package/dist/_shared/esm/{Icon-76d0d8c0.js → Icon-61f7237a.js} +5 -5
  105. package/dist/_shared/esm/{Image-7e4948f6.js → Image-c0f3d42f.js} +7 -7
  106. package/dist/_shared/esm/{Section-f1256c87.js → Section-7bc71e26.js} +2 -2
  107. package/dist/_shared/esm/{Surface-d515d212.js → Surface-bf201530.js} +3 -3
  108. package/dist/_shared/esm/{Text-d8988620.js → Text-6b958ad8.js} +3 -3
  109. package/dist/_shared/esm/VerticalSpace-6b4f5e50.d.ts +18 -0
  110. package/dist/_shared/esm/VerticalSpace-6b4f5e50.js +19 -0
  111. package/dist/_shared/esm/VisuallyHidden-b9eebf71.d.ts +12 -0
  112. package/dist/_shared/esm/VisuallyHidden-b9eebf71.js +11 -0
  113. package/dist/_shared/esm/index-c81c9401.d.ts +1 -1
  114. package/dist/index.es.js +34623 -529
  115. package/dist/index.es.js.map +1 -1
  116. package/dist/index.js +34527 -411
  117. package/dist/index.js.map +1 -1
  118. package/dist/styles.css +1 -1
  119. package/dist/types/components/Badge/Badge.d.ts +25 -0
  120. package/dist/types/components/Badge/index.d.ts +1 -0
  121. package/dist/types/components/FormControl/FormControl.d.ts +17 -0
  122. package/dist/types/components/FormControl/FormControlDisclosure/FormControlDisclosure.d.ts +28 -0
  123. package/dist/types/components/FormControl/FormControlDisclosure/index.d.ts +1 -0
  124. package/dist/types/components/Select/Select.d.ts +2 -1
  125. package/dist/types/components/Switch/Switch.d.ts +13 -8
  126. package/dist/types/components/TextInput/TextInput.d.ts +4 -0
  127. package/dist/types/components/Truncate/Truncate.d.ts +17 -0
  128. package/dist/types/components/Truncate/index.d.ts +1 -0
  129. package/dist/types/components/index.d.ts +4 -0
  130. package/dist/types/hooks/use-aria-describedby.d.ts +5 -1
  131. package/dist/types/styles.d.ts +4 -0
  132. package/package.json +4 -4
  133. package/dist/_shared/esm/FormControl-feedc495.js +0 -106
  134. /package/dist/_shared/esm/{BrandLogo-ea3dd0e6.d.ts → BrandLogo-4f13fe85.d.ts} +0 -0
  135. /package/dist/_shared/esm/{Button-5ff56a7b.d.ts → Button-69439f8f.d.ts} +0 -0
  136. /package/dist/_shared/esm/{Curve-cfdca379.d.ts → Curve-50697f7e.d.ts} +0 -0
  137. /package/dist/_shared/esm/{Heading-183be76c.d.ts → Heading-eb1e42db.d.ts} +0 -0
  138. /package/dist/_shared/esm/{Icon-76d0d8c0.d.ts → Icon-61f7237a.d.ts} +0 -0
  139. /package/dist/_shared/esm/{Image-7e4948f6.d.ts → Image-c0f3d42f.d.ts} +0 -0
  140. /package/dist/_shared/esm/{Section-f1256c87.d.ts → Section-7bc71e26.d.ts} +0 -0
  141. /package/dist/_shared/esm/{Surface-d515d212.d.ts → Surface-bf201530.d.ts} +0 -0
  142. /package/dist/_shared/esm/{Text-d8988620.d.ts → Text-6b958ad8.d.ts} +0 -0
@@ -0,0 +1,425 @@
1
+ 'use strict';
2
+
3
+ var React$1 = require('react');
4
+ var $7SXl2$reactdom = require('react-dom');
5
+
6
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
9
+
10
+ function _extends() {
11
+ _extends = Object.assign || function (target) {
12
+ for (var i = 1; i < arguments.length; i++) {
13
+ var source = arguments[i];
14
+
15
+ for (var key in source) {
16
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
17
+ target[key] = source[key];
18
+ }
19
+ }
20
+ }
21
+
22
+ return target;
23
+ };
24
+
25
+ return _extends.apply(this, arguments);
26
+ }
27
+
28
+ function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented: checkForDefaultPrevented = true } = {}) {
29
+ return function handleEvent(event) {
30
+ originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event);
31
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
32
+ };
33
+ }
34
+
35
+ /* -------------------------------------------------------------------------------------------------
36
+ * createContextScope
37
+ * -----------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
38
+ let defaultContexts = [];
39
+ /* -----------------------------------------------------------------------------------------------
40
+ * createContext
41
+ * ---------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
42
+ const BaseContext = /*#__PURE__*/ React$1.createContext(defaultContext);
43
+ const index = defaultContexts.length;
44
+ defaultContexts = [
45
+ ...defaultContexts,
46
+ defaultContext
47
+ ];
48
+ function Provider(props) {
49
+ const { scope: scope , children: children , ...context } = props;
50
+ const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext; // Only re-memoize when prop values change
51
+ // eslint-disable-next-line react-hooks/exhaustive-deps
52
+ const value = React$1.useMemo(()=>context
53
+ , Object.values(context));
54
+ return /*#__PURE__*/ React$1.createElement(Context.Provider, {
55
+ value: value
56
+ }, children);
57
+ }
58
+ function useContext(consumerName, scope) {
59
+ const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext;
60
+ const context = React$1.useContext(Context);
61
+ if (context) return context;
62
+ if (defaultContext !== undefined) return defaultContext; // if a defaultContext wasn't specified, it's a required context.
63
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
64
+ }
65
+ Provider.displayName = rootComponentName + 'Provider';
66
+ return [
67
+ Provider,
68
+ useContext
69
+ ];
70
+ }
71
+ /* -----------------------------------------------------------------------------------------------
72
+ * createScope
73
+ * ---------------------------------------------------------------------------------------------*/ const createScope = ()=>{
74
+ const scopeContexts = defaultContexts.map((defaultContext)=>{
75
+ return /*#__PURE__*/ React$1.createContext(defaultContext);
76
+ });
77
+ return function useScope(scope) {
78
+ const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
79
+ return React$1.useMemo(()=>({
80
+ [`__scope${scopeName}`]: {
81
+ ...scope,
82
+ [scopeName]: contexts
83
+ }
84
+ })
85
+ , [
86
+ scope,
87
+ contexts
88
+ ]);
89
+ };
90
+ };
91
+ createScope.scopeName = scopeName;
92
+ return [
93
+ $c512c27ab02ef895$export$fd42f52fd3ae1109,
94
+ $c512c27ab02ef895$var$composeContextScopes(createScope, ...createContextScopeDeps)
95
+ ];
96
+ }
97
+ /* -------------------------------------------------------------------------------------------------
98
+ * composeContextScopes
99
+ * -----------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$var$composeContextScopes(...scopes) {
100
+ const baseScope = scopes[0];
101
+ if (scopes.length === 1) return baseScope;
102
+ const createScope1 = ()=>{
103
+ const scopeHooks = scopes.map((createScope)=>({
104
+ useScope: createScope(),
105
+ scopeName: createScope.scopeName
106
+ })
107
+ );
108
+ return function useComposedScopes(overrideScopes) {
109
+ const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope: useScope , scopeName: scopeName })=>{
110
+ // We are calling a hook inside a callback which React warns against to avoid inconsistent
111
+ // renders, however, scoping doesn't have render side effects so we ignore the rule.
112
+ // eslint-disable-next-line react-hooks/rules-of-hooks
113
+ const scopeProps = useScope(overrideScopes);
114
+ const currentScope = scopeProps[`__scope${scopeName}`];
115
+ return {
116
+ ...nextScopes,
117
+ ...currentScope
118
+ };
119
+ }, {});
120
+ return React$1.useMemo(()=>({
121
+ [`__scope${baseScope.scopeName}`]: nextScopes1
122
+ })
123
+ , [
124
+ nextScopes1
125
+ ]);
126
+ };
127
+ };
128
+ createScope1.scopeName = baseScope.scopeName;
129
+ return createScope1;
130
+ }
131
+
132
+ /**
133
+ * Set a given ref to a given value
134
+ * This utility takes care of different types of refs: callback refs and RefObject(s)
135
+ */ function $6ed0406888f73fc4$var$setRef(ref, value) {
136
+ if (typeof ref === 'function') ref(value);
137
+ else if (ref !== null && ref !== undefined) ref.current = value;
138
+ }
139
+ /**
140
+ * A utility to compose multiple refs together
141
+ * Accepts callback refs and RefObject(s)
142
+ */ function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) {
143
+ return (node)=>refs.forEach((ref)=>$6ed0406888f73fc4$var$setRef(ref, node)
144
+ )
145
+ ;
146
+ }
147
+ /**
148
+ * A custom hook that composes multiple refs
149
+ * Accepts callback refs and RefObject(s)
150
+ */ function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) {
151
+ // eslint-disable-next-line react-hooks/exhaustive-deps
152
+ return React$1.useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs);
153
+ }
154
+
155
+ /* -------------------------------------------------------------------------------------------------
156
+ * Slot
157
+ * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
158
+ const { children: children , ...slotProps } = props;
159
+ const childrenArray = React$1.Children.toArray(children);
160
+ const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);
161
+ if (slottable) {
162
+ // the new element to render is the one passed as a child of `Slottable`
163
+ const newElement = slottable.props.children;
164
+ const newChildren = childrenArray.map((child)=>{
165
+ if (child === slottable) {
166
+ // because the new element will be the one rendered, we are only interested
167
+ // in grabbing its children (`newElement.props.children`)
168
+ if (React$1.Children.count(newElement) > 1) return React$1.Children.only(null);
169
+ return /*#__PURE__*/ React$1.isValidElement(newElement) ? newElement.props.children : null;
170
+ } else return child;
171
+ });
172
+ return /*#__PURE__*/ React$1.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
173
+ ref: forwardedRef
174
+ }), /*#__PURE__*/ React$1.isValidElement(newElement) ? /*#__PURE__*/ React$1.cloneElement(newElement, undefined, newChildren) : null);
175
+ }
176
+ return /*#__PURE__*/ React$1.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
177
+ ref: forwardedRef
178
+ }), children);
179
+ });
180
+ $5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = 'Slot';
181
+ /* -------------------------------------------------------------------------------------------------
182
+ * SlotClone
183
+ * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$var$SlotClone = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
184
+ const { children: children , ...slotProps } = props;
185
+ if (/*#__PURE__*/ React$1.isValidElement(children)) return /*#__PURE__*/ React$1.cloneElement(children, {
186
+ ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
187
+ ref: $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref)
188
+ });
189
+ return React$1.Children.count(children) > 1 ? React$1.Children.only(null) : null;
190
+ });
191
+ $5e63c961fc1ce211$var$SlotClone.displayName = 'SlotClone';
192
+ /* -------------------------------------------------------------------------------------------------
193
+ * Slottable
194
+ * -----------------------------------------------------------------------------------------------*/ const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children: children })=>{
195
+ return /*#__PURE__*/ React$1.createElement(React$1.Fragment, null, children);
196
+ };
197
+ /* ---------------------------------------------------------------------------------------------- */ function $5e63c961fc1ce211$var$isSlottable(child) {
198
+ return /*#__PURE__*/ React$1.isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
199
+ }
200
+ function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
201
+ // all child props should override
202
+ const overrideProps = {
203
+ ...childProps
204
+ };
205
+ for(const propName in childProps){
206
+ const slotPropValue = slotProps[propName];
207
+ const childPropValue = childProps[propName];
208
+ const isHandler = /^on[A-Z]/.test(propName);
209
+ if (isHandler) {
210
+ // if the handler exists on both, we compose them
211
+ if (slotPropValue && childPropValue) overrideProps[propName] = (...args)=>{
212
+ childPropValue(...args);
213
+ slotPropValue(...args);
214
+ };
215
+ else if (slotPropValue) overrideProps[propName] = slotPropValue;
216
+ } else if (propName === 'style') overrideProps[propName] = {
217
+ ...slotPropValue,
218
+ ...childPropValue
219
+ };
220
+ else if (propName === 'className') overrideProps[propName] = [
221
+ slotPropValue,
222
+ childPropValue
223
+ ].filter(Boolean).join(' ');
224
+ }
225
+ return {
226
+ ...slotProps,
227
+ ...overrideProps
228
+ };
229
+ }
230
+
231
+ const $8927f6f2acc4f386$var$NODES = [
232
+ 'a',
233
+ 'button',
234
+ 'div',
235
+ 'h2',
236
+ 'h3',
237
+ 'img',
238
+ 'label',
239
+ 'li',
240
+ 'nav',
241
+ 'ol',
242
+ 'p',
243
+ 'span',
244
+ 'svg',
245
+ 'ul'
246
+ ]; // Temporary while we await merge of this fix:
247
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55396
248
+ // prettier-ignore
249
+ /* -------------------------------------------------------------------------------------------------
250
+ * Primitive
251
+ * -----------------------------------------------------------------------------------------------*/ const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node)=>{
252
+ const Node = /*#__PURE__*/ React$1.forwardRef((props, forwardedRef)=>{
253
+ const { asChild: asChild , ...primitiveProps } = props;
254
+ const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node;
255
+ React$1.useEffect(()=>{
256
+ window[Symbol.for('radix-ui')] = true;
257
+ }, []);
258
+ return /*#__PURE__*/ React$1.createElement(Comp, _extends({}, primitiveProps, {
259
+ ref: forwardedRef
260
+ }));
261
+ });
262
+ Node.displayName = `Primitive.${node}`;
263
+ return {
264
+ ...primitive,
265
+ [node]: Node
266
+ };
267
+ }, {});
268
+ /* -------------------------------------------------------------------------------------------------
269
+ * Utils
270
+ * -----------------------------------------------------------------------------------------------*/ /**
271
+ * Flush custom event dispatch
272
+ * https://github.com/radix-ui/primitives/pull/1378
273
+ *
274
+ * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
275
+ *
276
+ * Internally, React prioritises events in the following order:
277
+ * - discrete
278
+ * - continuous
279
+ * - default
280
+ *
281
+ * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L294-L350
282
+ *
283
+ * `discrete` is an important distinction as updates within these events are applied immediately.
284
+ * React however, is not able to infer the priority of custom event types due to how they are detected internally.
285
+ * Because of this, it's possible for updates from custom events to be unexpectedly batched when
286
+ * dispatched by another `discrete` event.
287
+ *
288
+ * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
289
+ * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
290
+ * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
291
+ * For example:
292
+ *
293
+ * dispatching a known click 👎
294
+ * target.dispatchEvent(new Event(‘click’))
295
+ *
296
+ * dispatching a custom type within a non-discrete event 👎
297
+ * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
298
+ *
299
+ * dispatching a custom type within a `discrete` event 👍
300
+ * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
301
+ *
302
+ * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
303
+ * this utility with them. This is because it's possible for those handlers to be called implicitly during render
304
+ * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
305
+ */ function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) {
306
+ if (target) $7SXl2$reactdom.flushSync(()=>target.dispatchEvent(event)
307
+ );
308
+ }
309
+
310
+ /**
311
+ * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
312
+ * prop or avoid re-executing effects when passed as a dependency
313
+ */ function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) {
314
+ const callbackRef = React$1.useRef(callback);
315
+ React$1.useEffect(()=>{
316
+ callbackRef.current = callback;
317
+ }); // https://github.com/facebook/react/issues/19240
318
+ return React$1.useMemo(()=>(...args)=>{
319
+ var _callbackRef$current;
320
+ return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args);
321
+ }
322
+ , []);
323
+ }
324
+
325
+ /**
326
+ * On the server, React emits a warning when calling `useLayoutEffect`.
327
+ * This is because neither `useLayoutEffect` nor `useEffect` run on the server.
328
+ * We use this safe version which suppresses the warning by replacing it with a noop on the server.
329
+ *
330
+ * See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
331
+ */ const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? React$1.useLayoutEffect : ()=>{};
332
+
333
+ function $71cd76cc60e0454e$export$6f32135080cb4c3({ prop: prop , defaultProp: defaultProp , onChange: onChange = ()=>{} }) {
334
+ const [uncontrolledProp, setUncontrolledProp] = $71cd76cc60e0454e$var$useUncontrolledState({
335
+ defaultProp: defaultProp,
336
+ onChange: onChange
337
+ });
338
+ const isControlled = prop !== undefined;
339
+ const value1 = isControlled ? prop : uncontrolledProp;
340
+ const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
341
+ const setValue = React$1.useCallback((nextValue)=>{
342
+ if (isControlled) {
343
+ const setter = nextValue;
344
+ const value = typeof nextValue === 'function' ? setter(prop) : nextValue;
345
+ if (value !== prop) handleChange(value);
346
+ } else setUncontrolledProp(nextValue);
347
+ }, [
348
+ isControlled,
349
+ prop,
350
+ setUncontrolledProp,
351
+ handleChange
352
+ ]);
353
+ return [
354
+ value1,
355
+ setValue
356
+ ];
357
+ }
358
+ function $71cd76cc60e0454e$var$useUncontrolledState({ defaultProp: defaultProp , onChange: onChange }) {
359
+ const uncontrolledState = React$1.useState(defaultProp);
360
+ const [value] = uncontrolledState;
361
+ const prevValueRef = React$1.useRef(value);
362
+ const handleChange = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onChange);
363
+ React$1.useEffect(()=>{
364
+ if (prevValueRef.current !== value) {
365
+ handleChange(value);
366
+ prevValueRef.current = value;
367
+ }
368
+ }, [
369
+ value,
370
+ prevValueRef,
371
+ handleChange
372
+ ]);
373
+ return uncontrolledState;
374
+ }
375
+
376
+ function $010c2913dbd2fe3d$export$5cae361ad82dce8b(value) {
377
+ const ref = React$1.useRef({
378
+ value: value,
379
+ previous: value
380
+ }); // We compare values before making an update to ensure that
381
+ // a change has been made. This ensures the previous value is
382
+ // persisted correctly between renders.
383
+ return React$1.useMemo(()=>{
384
+ if (ref.current.value !== value) {
385
+ ref.current.previous = ref.current.value;
386
+ ref.current.value = value;
387
+ }
388
+ return ref.current.previous;
389
+ }, [
390
+ value
391
+ ]);
392
+ }
393
+
394
+ const React = React__default["default"];
395
+ const BtIconTickAlt2Px = props =>
396
+ /*#__PURE__*/ React.createElement(
397
+ "svg",
398
+ Object.assign(
399
+ {
400
+ xmlns: "http://www.w3.org/2000/svg",
401
+ viewBox: "0 0 32 32"
402
+ },
403
+ props
404
+ ),
405
+ /*#__PURE__*/ React.createElement("defs", null),
406
+ /*#__PURE__*/ React.createElement("path", {
407
+ d:
408
+ "M13.49963,21.91418l-4.707-4.707a1.0014,1.0014,0,0,1,0-1.41406,1.02353,1.02353,0,0,1,1.41406,0l3.293,3.293,8.293-8.293a.99989.99989,0,1,1,1.41406,1.41406Z",
409
+ fill: "currentColor"
410
+ })
411
+ );
412
+ var BtIconTickAlt2Px_2 = BtIconTickAlt2Px;
413
+
414
+ exports.$010c2913dbd2fe3d$export$5cae361ad82dce8b = $010c2913dbd2fe3d$export$5cae361ad82dce8b;
415
+ exports.$5e63c961fc1ce211$export$8c6ed5c666ac1360 = $5e63c961fc1ce211$export$8c6ed5c666ac1360;
416
+ exports.$6ed0406888f73fc4$export$c7b2cbe3552a0d05 = $6ed0406888f73fc4$export$c7b2cbe3552a0d05;
417
+ exports.$71cd76cc60e0454e$export$6f32135080cb4c3 = $71cd76cc60e0454e$export$6f32135080cb4c3;
418
+ exports.$8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$export$250ffa63cdc0d034;
419
+ exports.$8927f6f2acc4f386$export$6d1a0317bde7de7f = $8927f6f2acc4f386$export$6d1a0317bde7de7f;
420
+ exports.$9f79659886946c16$export$e5c5a5f917a5871c = $9f79659886946c16$export$e5c5a5f917a5871c;
421
+ exports.$b1b2314f5f9a1d84$export$25bec8c6f54ee79a = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a;
422
+ exports.$c512c27ab02ef895$export$50c7b4e9d9f19c1 = $c512c27ab02ef895$export$50c7b4e9d9f19c1;
423
+ exports.$e42e1063c40fb3ef$export$b9ecd428b558ff10 = $e42e1063c40fb3ef$export$b9ecd428b558ff10;
424
+ exports.BtIconTickAlt2Px_2 = BtIconTickAlt2Px_2;
425
+ exports._extends = _extends;
@@ -1,23 +1,54 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
- import { FC } from "react";
3
+ import { FC, ReactNode } from "react";
4
+ /**
5
+ * Use `FormControlDisclosure` to display content that is only visible when toggled into
6
+ * an "open" state.
7
+ */
8
+ declare const FormControlDisclosure: FC<FormControlDisclosureProps>;
9
+ interface FormControlDisclosureProps {
10
+ /**
11
+ * Content to display in the FormControlDisclosure.
12
+ */
13
+ children: ReactNode;
14
+ /**
15
+ * FormControlDisclosure ID.
16
+ */
17
+ id?: string;
18
+ /**
19
+ * The FormControlDisclosure summary text.
20
+ */
21
+ summary: string;
22
+ /**
23
+ * On Click handler for FormControlDisclosure summary disclosure.
24
+ */
25
+ onClick?: () => void;
26
+ /**
27
+ * Disclosure size.
28
+ */
29
+ size?: "s" | "l";
30
+ }
4
31
  /**
5
32
  * Optionally define ariaDescribedBy if errorMessage or helper exist.
6
33
  */
7
- declare const useAriaDescribedby: ({ id, idError, idHelper, errorMessage, helper }: {
34
+ declare const useAriaDescribedby: ({ id, idError, idHelper, idDisclosure, errorMessage, helper, disclosureText }: {
8
35
  id?: string | undefined;
9
36
  idError?: string | undefined;
37
+ idDisclosure?: string | undefined;
10
38
  idHelper?: string | undefined;
11
39
  errorMessage?: any;
12
40
  helper?: any;
41
+ disclosureText?: string | undefined;
13
42
  }) => {
14
43
  ariaDescribedby: undefined;
15
44
  idHelper: undefined;
16
45
  idError: undefined;
46
+ idDisclosure: undefined;
17
47
  } | {
18
48
  ariaDescribedby: string | undefined;
19
49
  idError: string;
20
50
  idHelper: string;
51
+ idDisclosure: string;
21
52
  };
22
53
  type RequirementStatus = "required" | "optional" | "not-applicable";
23
54
  declare const Context: React.Context<{
@@ -62,9 +93,26 @@ interface FormControlProps {
62
93
  * Label for the FormControl.
63
94
  */
64
95
  label: string;
96
+ /**
97
+ * Determins if the Label should be in a disabled state
98
+ */
99
+ isDisabled?: boolean;
65
100
  /**
66
101
  * Label size.
67
102
  */
68
103
  labelSize?: "s" | "l";
104
+ /**
105
+ * Use `DisclosureTitle` to display content that is only visible when toggled into
106
+ * an "open" state. This overrides helper text.
107
+ */
108
+ disclosureTitle?: string;
109
+ /**
110
+ * Text to display within the disclosure
111
+ */
112
+ disclosureText?: string;
113
+ /**
114
+ * onClick handler for FormControlDisclosure
115
+ */
116
+ onClickDisclosure?: () => void;
69
117
  }
70
- export { useAriaDescribedby, FormControl, FormControlProps, Context as FormControlContext };
118
+ export { FormControlDisclosure, FormControlDisclosureProps, useAriaDescribedby, FormControl, FormControlProps, Context as FormControlContext };
@@ -4,6 +4,8 @@ var index = require('./index-78b35bc1.js');
4
4
  var index$1 = require('./index-45bfb67b.js');
5
5
  var React$1 = require('react');
6
6
  var Surface = require('./Surface-d6b8010e.js');
7
+ var Text = require('./Text-1d3844be.js');
8
+ var BtIconChevronRightMid = require('./BtIconChevronRightMid-5a38d855.js');
7
9
 
8
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
11
 
@@ -13,12 +15,13 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
13
15
  * Optionally define ariaDescribedBy if errorMessage or helper exist.
14
16
  */
15
17
  var useAriaDescribedby = function (_a) {
16
- var id = _a.id, _b = _a.idError, idError = _b === void 0 ? "".concat(id, "-error") : _b, _c = _a.idHelper, idHelper = _c === void 0 ? "".concat(id, "-helper") : _c, errorMessage = _a.errorMessage, helper = _a.helper;
18
+ var id = _a.id, _b = _a.idError, idError = _b === void 0 ? "".concat(id, "-error") : _b, _c = _a.idHelper, idHelper = _c === void 0 ? "".concat(id, "-helper") : _c, _d = _a.idDisclosure, idDisclosure = _d === void 0 ? "".concat(id, "-disclosure") : _d, errorMessage = _a.errorMessage, helper = _a.helper, disclosureText = _a.disclosureText;
17
19
  if (!id) {
18
20
  return {
19
21
  ariaDescribedby: undefined,
20
22
  idHelper: undefined,
21
- idError: undefined
23
+ idError: undefined,
24
+ idDisclosure: undefined
22
25
  };
23
26
  }
24
27
  var ariaDescribedbyArr = [];
@@ -28,8 +31,11 @@ var useAriaDescribedby = function (_a) {
28
31
  if (helper) {
29
32
  ariaDescribedbyArr.push(idHelper);
30
33
  }
34
+ if (disclosureText) {
35
+ ariaDescribedbyArr.push(idDisclosure);
36
+ }
31
37
  var ariaDescribedby = ariaDescribedbyArr.length > 0 ? ariaDescribedbyArr.join(" ") : undefined;
32
- return { ariaDescribedby: ariaDescribedby, idError: idError, idHelper: idHelper };
38
+ return { ariaDescribedby: ariaDescribedby, idError: idError, idHelper: idHelper, idDisclosure: idDisclosure };
33
39
  };
34
40
 
35
41
  const React = React__default["default"];
@@ -61,6 +67,31 @@ const BtIconAlert = props =>
61
67
  );
62
68
  var BtIconAlert_2 = BtIconAlert;
63
69
 
70
+ /**
71
+ * Use `FormControlDisclosure` to display content that is only visible when toggled into
72
+ * an "open" state.
73
+ */
74
+ var FormControlDisclosure = function (_a) {
75
+ var children = _a.children, summary = _a.summary, onClick = _a.onClick, _b = _a.size, size = _b === void 0 ? "l" : _b, id = _a.id, props = index.__rest(_a, ["children", "summary", "onClick", "size", "id"]);
76
+ var surface = React$1.useContext(Surface.Context).surface;
77
+ var _c = React$1.useState(false), disclousreState = _c[0], setDisclosureState = _c[1];
78
+ var handleOnClick = function () {
79
+ onClick && onClick();
80
+ setDisclosureState(function (prevState) { return !prevState; });
81
+ };
82
+ return (React__default["default"].createElement("details", index.__assign({ className: index$1.classNames({
83
+ "arc-FormControlDisclosure": true,
84
+ "arc-FormControlDisclosure--onDarkSurface": surface === "dark"
85
+ }) }, index.filterDataAttrs(props), { "data-testid": "FormControlDisclosure" }),
86
+ React__default["default"].createElement("summary", { className: "arc-FormControlDisclosure-summary", onClick: handleOnClick, "aria-expanded": disclousreState },
87
+ React__default["default"].createElement("span", { className: "arc-FormControlDisclosure-summary-icon" },
88
+ React__default["default"].createElement(BtIconChevronRightMid.BtIconChevronRightMid_2, null)),
89
+ React__default["default"].createElement(Text.Text, { size: size === "l" ? "m" : "s" }, summary)),
90
+ React__default["default"].createElement("div", { className: "arc-FormControlDisclosure-details" },
91
+ React__default["default"].createElement(Text.Text, { size: size === "l" ? "m" : "s" },
92
+ React__default["default"].createElement("span", { id: id }, children)))));
93
+ };
94
+
64
95
  var defaultContext = {
65
96
  requirementStatus: null
66
97
  };
@@ -70,13 +101,14 @@ var Provider = Context.Provider;
70
101
  * Use `FormControl` to provide inputs with labels, helper text and error messages
71
102
  */
72
103
  var FormControl = function (_a) {
73
- var children = _a.children, _b = _a.elementType, ElementType = _b === void 0 ? "div" : _b, errorMessage = _a.errorMessage, helper = _a.helper, htmlFor = _a.htmlFor, id = _a.id, label = _a.label, _c = _a.labelSize, labelSize = _c === void 0 ? "l" : _c, _d = _a.requirementStatus, requirementStatus = _d === void 0 ? "optional" : _d, props = index.__rest(_a, ["children", "elementType", "errorMessage", "helper", "htmlFor", "id", "label", "labelSize", "requirementStatus"]);
104
+ var children = _a.children, _b = _a.elementType, ElementType = _b === void 0 ? "div" : _b, errorMessage = _a.errorMessage, helper = _a.helper, htmlFor = _a.htmlFor, id = _a.id, label = _a.label, _c = _a.labelSize, labelSize = _c === void 0 ? "l" : _c, _d = _a.requirementStatus, requirementStatus = _d === void 0 ? "optional" : _d, isDisabled = _a.isDisabled, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, props = index.__rest(_a, ["children", "elementType", "errorMessage", "helper", "htmlFor", "id", "label", "labelSize", "requirementStatus", "isDisabled", "disclosureTitle", "disclosureText", "onClickDisclosure"]);
74
105
  var surface = React$1.useContext(Surface.Context).surface;
75
106
  var _e = useAriaDescribedby({
107
+ disclosureText: disclosureText,
76
108
  errorMessage: errorMessage,
77
109
  helper: helper,
78
110
  id: htmlFor || id // `htmlFor` is preference to keep this deterministic with TextInput
79
- }), ariaDescribedby = _e.ariaDescribedby, idError = _e.idError, idHelper = _e.idHelper;
111
+ }), ariaDescribedby = _e.ariaDescribedby, idError = _e.idError, idHelper = _e.idHelper, idDisclosure = _e.idDisclosure;
80
112
  var LabelType = ElementType === "div" ? "label" : "legend";
81
113
  var elementProps = {};
82
114
  var labelProps = {};
@@ -95,18 +127,18 @@ var FormControl = function (_a) {
95
127
  return (React__default["default"].createElement(Provider, { value: { requirementStatus: requirementStatus } },
96
128
  React__default["default"].createElement(ElementType, index.__assign({ className: index$1.classNames({
97
129
  "arc-FormControl": true,
130
+ "arc-FormControl--isDisabled": isDisabled,
98
131
  "arc-FormControl--smallLabel": labelSize === "s",
99
132
  "arc-FormControl--onDarkSurface": surface === "dark"
100
133
  }), id: id }, elementProps, index.filterDataAttrs(props)),
101
134
  React__default["default"].createElement(LabelType, index.__assign({ className: "arc-FormControl-label" }, labelProps),
102
135
  label,
103
136
  requirementStatus === "optional" && (React__default["default"].createElement("span", { className: "arc-FormControl-labelOptional" }, "(optional)"))),
104
- helper && (React__default["default"].createElement("div", { className: "arc-FormControl-helper", id: idHelper }, helper)),
105
137
  children,
106
- errorMessage && (React__default["default"].createElement("div", { className: "arc-FormControl-error", id: idError },
138
+ errorMessage ? (React__default["default"].createElement("div", { className: "arc-FormControl-error", id: idError },
107
139
  React__default["default"].createElement("span", { className: "arc-FormControl-error--icon" },
108
140
  React__default["default"].createElement(BtIconAlert_2, null)),
109
- errorMessage)))));
141
+ errorMessage)) : disclosureTitle ? (React__default["default"].createElement(FormControlDisclosure, { onClick: onClickDisclosure, summary: disclosureTitle, size: labelSize, id: idDisclosure }, disclosureText)) : (helper && (React__default["default"].createElement("div", { className: "arc-FormControl-helper", id: idHelper }, helper))))));
110
142
  };
111
143
 
112
144
  exports.BtIconAlert_2 = BtIconAlert_2;
@@ -0,0 +1,18 @@
1
+ import { FC } from "react";
2
+ /**
3
+ * Use `VerticalSpace` to create vertical space between components.
4
+ */
5
+ declare const VerticalSpace: FC<VerticalSpaceProps>;
6
+ type VerticalSpaceSize = "4" | "8" | "12" | "16" | "24" | "32" | "48" | "64" | "96" | "128";
7
+ interface VerticalSpaceProps {
8
+ /**
9
+ * Should the VerticalSpace be visible for debugging and documentation
10
+ * purposes?
11
+ */
12
+ isDebugVisible?: boolean;
13
+ /**
14
+ * Size of the VerticalSpace.
15
+ */
16
+ size?: VerticalSpaceSize;
17
+ }
18
+ export { VerticalSpace, VerticalSpaceSize, VerticalSpaceProps };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-78b35bc1.js');
4
+ var index$1 = require('./index-45bfb67b.js');
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ /**
12
+ * Use `VerticalSpace` to create vertical space between components.
13
+ */
14
+ var VerticalSpace = function (_a) {
15
+ var _b;
16
+ var _c = _a.isDebugVisible, isDebugVisible = _c === void 0 ? false : _c, _d = _a.size, size = _d === void 0 ? "24" : _d, props = index.__rest(_a, ["isDebugVisible", "size"]);
17
+ return (React__default["default"].createElement("div", index.__assign({ className: index$1.classNames((_b = {
18
+ "arc-VerticalSpace": true
19
+ },
20
+ _b["arc-VerticalSpace--size".concat(size)] = size && size !== "24",
21
+ _b["arc-VerticalSpace--debugVisible"] = isDebugVisible,
22
+ _b)) }, index.filterDataAttrs(props))));
23
+ };
24
+
25
+ exports.VerticalSpace = VerticalSpace;
@@ -0,0 +1,12 @@
1
+ import { FC, ReactNode } from "react";
2
+ /**
3
+ * Provides text for screen readers that is visually hidden.
4
+ */
5
+ declare const VisuallyHidden: FC<VisuallyHiddenProps>;
6
+ interface VisuallyHiddenProps {
7
+ /**
8
+ * Content to be Visually Hidden.
9
+ */
10
+ children?: ReactNode;
11
+ }
12
+ export { VisuallyHidden, VisuallyHiddenProps };