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