@arc-ui/components 11.1.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.
@@ -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;
@@ -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;