@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
@@ -0,0 +1,40 @@
1
+ import { FC } from "react";
2
+ import { SwitchProps as RadixSwitchProps } from "@radix-ui/react-switch";
3
+ import { FormControlProps } from "../_shared/cjs/FormControl-d4d9c665";
4
+ /** Use `Switch` to toggle between checked and not checked. */
5
+ declare const Switch: FC<SwitchProps>;
6
+ interface SwitchProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus" | "disclosureText" | "disclosureTitle" | "onClickDisclosure" | "helper"> {
7
+ /**
8
+ * Hide Label above toggle?
9
+ */
10
+ hideLabel?: boolean;
11
+ /**
12
+ * Text to display next to `Switch`
13
+ */
14
+ statusText?: string;
15
+ /**
16
+ * Should the `Switch` be disabled?
17
+ */
18
+ isDisabled?: FormControlProps["isDisabled"];
19
+ /**
20
+ * handler for blur
21
+ */
22
+ onBlur?: RadixSwitchProps["onBlur"];
23
+ /**
24
+ * set the switch to be checked by default
25
+ */
26
+ defaultChecked?: RadixSwitchProps["defaultChecked"];
27
+ /**
28
+ * value for the switch, is applied to a hidden checkbox if within a form
29
+ */
30
+ value?: RadixSwitchProps["value"];
31
+ /**
32
+ * name for the hidden checkbox if within a form
33
+ */
34
+ name?: RadixSwitchProps["name"];
35
+ /**
36
+ * callback for when the switch is toggled
37
+ */
38
+ onCheckedChange?: RadixSwitchProps["onCheckedChange"];
39
+ }
40
+ export { Switch };
@@ -0,0 +1,211 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var index = require('../_shared/cjs/index-45bfb67b.js');
7
+ var index_module = require('../_shared/cjs/index.module-af7c85f2.js');
8
+ var Icon = require('../_shared/cjs/Icon-719d13d4.js');
9
+ var BtIconTickAlt2Px = require('../_shared/cjs/BtIconTickAlt2Px-bdf06f8c.js');
10
+ var Surface = require('../_shared/cjs/Surface-d6b8010e.js');
11
+ var FormControl = require('../_shared/cjs/FormControl-d4d9c665.js');
12
+ var VerticalSpace = require('../_shared/cjs/VerticalSpace-65ad083c.js');
13
+ var Text = require('../_shared/cjs/Text-1d3844be.js');
14
+ require('react-dom');
15
+ require('../_shared/cjs/index-78b35bc1.js');
16
+ require('../_shared/cjs/suffix-modifier-edf7851e.js');
17
+ require('../_shared/cjs/BtIconChevronRightMid-5a38d855.js');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
+
23
+ function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
24
+ const [size, setSize] = React.useState(undefined);
25
+ index_module.$9f79659886946c16$export$e5c5a5f917a5871c(()=>{
26
+ if (element) {
27
+ // provide size as early as possible
28
+ setSize({
29
+ width: element.offsetWidth,
30
+ height: element.offsetHeight
31
+ });
32
+ const resizeObserver = new ResizeObserver((entries)=>{
33
+ if (!Array.isArray(entries)) return;
34
+ // Since we only observe the one element, we don't need to loop over the
35
+ // array
36
+ if (!entries.length) return;
37
+ const entry = entries[0];
38
+ let width;
39
+ let height;
40
+ if ('borderBoxSize' in entry) {
41
+ const borderSizeEntry = entry['borderBoxSize']; // iron out differences between browsers
42
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
43
+ width = borderSize['inlineSize'];
44
+ height = borderSize['blockSize'];
45
+ } else {
46
+ // for browsers that don't support `borderBoxSize`
47
+ // we calculate it ourselves to get the correct border box.
48
+ width = element.offsetWidth;
49
+ height = element.offsetHeight;
50
+ }
51
+ setSize({
52
+ width: width,
53
+ height: height
54
+ });
55
+ });
56
+ resizeObserver.observe(element, {
57
+ box: 'border-box'
58
+ });
59
+ return ()=>resizeObserver.unobserve(element)
60
+ ;
61
+ } else // We only want to reset to `undefined` when the element becomes `null`,
62
+ // not if it changes to another element.
63
+ setSize(undefined);
64
+ }, [
65
+ element
66
+ ]);
67
+ return size;
68
+ }
69
+
70
+ /* -------------------------------------------------------------------------------------------------
71
+ * Switch
72
+ * -----------------------------------------------------------------------------------------------*/ const $6be4966fd9bbc698$var$SWITCH_NAME = 'Switch';
73
+ const [$6be4966fd9bbc698$var$createSwitchContext, $6be4966fd9bbc698$export$cf7f5f17f69cbd43] = index_module.$c512c27ab02ef895$export$50c7b4e9d9f19c1($6be4966fd9bbc698$var$SWITCH_NAME);
74
+ const [$6be4966fd9bbc698$var$SwitchProvider, $6be4966fd9bbc698$var$useSwitchContext] = $6be4966fd9bbc698$var$createSwitchContext($6be4966fd9bbc698$var$SWITCH_NAME);
75
+ const $6be4966fd9bbc698$export$b5d5cf8927ab7262 = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
76
+ const { __scopeSwitch: __scopeSwitch , name: name , checked: checkedProp , defaultChecked: defaultChecked , required: required , disabled: disabled , value: value = 'on' , onCheckedChange: onCheckedChange , ...switchProps } = props;
77
+ const [button, setButton] = React.useState(null);
78
+ const composedRefs = index_module.$6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setButton(node)
79
+ );
80
+ const hasConsumerStoppedPropagationRef = React.useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
81
+ const isFormControl = button ? Boolean(button.closest('form')) : true;
82
+ const [checked = false, setChecked] = index_module.$71cd76cc60e0454e$export$6f32135080cb4c3({
83
+ prop: checkedProp,
84
+ defaultProp: defaultChecked,
85
+ onChange: onCheckedChange
86
+ });
87
+ return /*#__PURE__*/ React.createElement($6be4966fd9bbc698$var$SwitchProvider, {
88
+ scope: __scopeSwitch,
89
+ checked: checked,
90
+ disabled: disabled
91
+ }, /*#__PURE__*/ React.createElement(index_module.$8927f6f2acc4f386$export$250ffa63cdc0d034.button, index_module._extends({
92
+ type: "button",
93
+ role: "switch",
94
+ "aria-checked": checked,
95
+ "aria-required": required,
96
+ "data-state": $6be4966fd9bbc698$var$getState(checked),
97
+ "data-disabled": disabled ? '' : undefined,
98
+ disabled: disabled,
99
+ value: value
100
+ }, switchProps, {
101
+ ref: composedRefs,
102
+ onClick: index_module.$e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, (event)=>{
103
+ setChecked((prevChecked)=>!prevChecked
104
+ );
105
+ if (isFormControl) {
106
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if switch is in a form, stop propagation from the button so that we only propagate
107
+ // one click event (from the input). We propagate changes from an input so that native
108
+ // form validation works and form events reflect switch updates.
109
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
110
+ }
111
+ })
112
+ })), isFormControl && /*#__PURE__*/ React.createElement($6be4966fd9bbc698$var$BubbleInput, {
113
+ control: button,
114
+ bubbles: !hasConsumerStoppedPropagationRef.current,
115
+ name: name,
116
+ value: value,
117
+ checked: checked,
118
+ required: required,
119
+ disabled: disabled // We transform because the input is absolutely positioned but we have
120
+ ,
121
+ style: {
122
+ transform: 'translateX(-100%)'
123
+ }
124
+ }));
125
+ });
126
+ /* -------------------------------------------------------------------------------------------------
127
+ * SwitchThumb
128
+ * -----------------------------------------------------------------------------------------------*/ const $6be4966fd9bbc698$var$THUMB_NAME = 'SwitchThumb';
129
+ const $6be4966fd9bbc698$export$4d07bf653ea69106 = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
130
+ const { __scopeSwitch: __scopeSwitch , ...thumbProps } = props;
131
+ const context = $6be4966fd9bbc698$var$useSwitchContext($6be4966fd9bbc698$var$THUMB_NAME, __scopeSwitch);
132
+ return /*#__PURE__*/ React.createElement(index_module.$8927f6f2acc4f386$export$250ffa63cdc0d034.span, index_module._extends({
133
+ "data-state": $6be4966fd9bbc698$var$getState(context.checked),
134
+ "data-disabled": context.disabled ? '' : undefined
135
+ }, thumbProps, {
136
+ ref: forwardedRef
137
+ }));
138
+ });
139
+ /* ---------------------------------------------------------------------------------------------- */ const $6be4966fd9bbc698$var$BubbleInput = (props)=>{
140
+ const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
141
+ const ref = React.useRef(null);
142
+ const prevChecked = index_module.$010c2913dbd2fe3d$export$5cae361ad82dce8b(checked);
143
+ const controlSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(control); // Bubble checked change to parents (e.g form change event)
144
+ React.useEffect(()=>{
145
+ const input = ref.current;
146
+ const inputProto = window.HTMLInputElement.prototype;
147
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
148
+ const setChecked = descriptor.set;
149
+ if (prevChecked !== checked && setChecked) {
150
+ const event = new Event('click', {
151
+ bubbles: bubbles
152
+ });
153
+ setChecked.call(input, checked);
154
+ input.dispatchEvent(event);
155
+ }
156
+ }, [
157
+ prevChecked,
158
+ checked,
159
+ bubbles
160
+ ]);
161
+ return /*#__PURE__*/ React.createElement("input", index_module._extends({
162
+ type: "checkbox",
163
+ "aria-hidden": true,
164
+ defaultChecked: checked
165
+ }, inputProps, {
166
+ tabIndex: -1,
167
+ ref: ref,
168
+ style: {
169
+ ...props.style,
170
+ ...controlSize,
171
+ position: 'absolute',
172
+ pointerEvents: 'none',
173
+ opacity: 0,
174
+ margin: 0
175
+ }
176
+ }));
177
+ };
178
+ function $6be4966fd9bbc698$var$getState(checked) {
179
+ return checked ? 'checked' : 'unchecked';
180
+ }
181
+ const $6be4966fd9bbc698$export$be92b6f5f03c0fe9 = $6be4966fd9bbc698$export$b5d5cf8927ab7262;
182
+ const $6be4966fd9bbc698$export$6521433ed15a34db = $6be4966fd9bbc698$export$4d07bf653ea69106;
183
+
184
+ /** Use `Switch` to toggle between checked and not checked. */
185
+ var Switch = function (_a) {
186
+ var defaultChecked = _a.defaultChecked, onCheckedChange = _a.onCheckedChange, label = _a.label, name = _a.name, onBlur = _a.onBlur, value = _a.value, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, errorMessage = _a.errorMessage, id = _a.id, _c = _a.labelSize, labelSize = _c === void 0 ? "s" : _c, statusText = _a.statusText, _d = _a.hideLabel, hideLabel = _d === void 0 ? false : _d;
187
+ var surface = React.useContext(Surface.Context).surface;
188
+ return (React__default["default"].createElement(FormControl.FormControl, { errorMessage: errorMessage, htmlFor: id, isDisabled: isDisabled, label: hideLabel ? "" : label, labelSize: labelSize, requirementStatus: "not-applicable" },
189
+ !hideLabel && React__default["default"].createElement(VerticalSpace.VerticalSpace, { size: "8" }),
190
+ React__default["default"].createElement("div", { className: "arc-Switch-container" },
191
+ React__default["default"].createElement($6be4966fd9bbc698$export$be92b6f5f03c0fe9, { id: id, "aria-label": label, defaultChecked: defaultChecked, name: name, value: value, onBlur: onBlur, onCheckedChange: onCheckedChange, disabled: isDisabled, className: index.classNames("arc-Switch", {
192
+ "arc-Switch--large": labelSize === "l",
193
+ "arc-Switch--isDisabled": isDisabled,
194
+ "arc-Switch--onDarkSurface": surface === "dark"
195
+ }) },
196
+ React__default["default"].createElement("div", { className: "arc-Switch-wrapper" },
197
+ React__default["default"].createElement($6be4966fd9bbc698$export$6521433ed15a34db, { className: "arc-Switch-thumb" },
198
+ React__default["default"].createElement("div", { className: "arc-Switch-thumbIcon" },
199
+ React__default["default"].createElement("div", { className: "arc-Switch-icon", "data-testid": "arc-switch-thumb-icon" },
200
+ React__default["default"].createElement(Icon.Icon, { icon: BtIconTickAlt2Px.BtIconTickAlt2Px_2, color: surface === "dark" ? "brand" : "brand", size: labelSize === "l" ? 24 : 16 })))))),
201
+ React__default["default"].createElement("div", { className: index.classNames("arc-Switch-statusText", {
202
+ "arc-Switch-statusText--isDisabled": isDisabled,
203
+ "arc-Switch-statusText--onDarkSurface": surface === "dark"
204
+ }) },
205
+ React__default["default"].createElement(Text.Text, { size: labelSize },
206
+ " ",
207
+ statusText,
208
+ " ")))));
209
+ };
210
+
211
+ exports.Switch = Switch;
@@ -0,0 +1,40 @@
1
+ import { FC } from "react";
2
+ import { SwitchProps as RadixSwitchProps } from "@radix-ui/react-switch";
3
+ import { FormControlProps } from "../_shared/esm/FormControl-2cb96de7";
4
+ /** Use `Switch` to toggle between checked and not checked. */
5
+ declare const Switch: FC<SwitchProps>;
6
+ interface SwitchProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus" | "disclosureText" | "disclosureTitle" | "onClickDisclosure" | "helper"> {
7
+ /**
8
+ * Hide Label above toggle?
9
+ */
10
+ hideLabel?: boolean;
11
+ /**
12
+ * Text to display next to `Switch`
13
+ */
14
+ statusText?: string;
15
+ /**
16
+ * Should the `Switch` be disabled?
17
+ */
18
+ isDisabled?: FormControlProps["isDisabled"];
19
+ /**
20
+ * handler for blur
21
+ */
22
+ onBlur?: RadixSwitchProps["onBlur"];
23
+ /**
24
+ * set the switch to be checked by default
25
+ */
26
+ defaultChecked?: RadixSwitchProps["defaultChecked"];
27
+ /**
28
+ * value for the switch, is applied to a hidden checkbox if within a form
29
+ */
30
+ value?: RadixSwitchProps["value"];
31
+ /**
32
+ * name for the hidden checkbox if within a form
33
+ */
34
+ name?: RadixSwitchProps["name"];
35
+ /**
36
+ * callback for when the switch is toggled
37
+ */
38
+ onCheckedChange?: RadixSwitchProps["onCheckedChange"];
39
+ }
40
+ export { Switch };
@@ -0,0 +1,203 @@
1
+ import React__default, { useState, forwardRef, useRef, createElement, useEffect, useContext } from 'react';
2
+ import { c as classNames } from '../_shared/esm/index-2ae58626.js';
3
+ import { g as $9f79659886946c16$export$e5c5a5f917a5871c, $ as $c512c27ab02ef895$export$50c7b4e9d9f19c1, a as $6ed0406888f73fc4$export$c7b2cbe3552a0d05, h as $71cd76cc60e0454e$export$6f32135080cb4c3, d as $8927f6f2acc4f386$export$250ffa63cdc0d034, _ as _extends, e as $e42e1063c40fb3ef$export$b9ecd428b558ff10, i as $010c2913dbd2fe3d$export$5cae361ad82dce8b } from '../_shared/esm/index.module-599b86dd.js';
4
+ import { I as Icon } from '../_shared/esm/Icon-61f7237a.js';
5
+ import { B as BtIconTickAlt2Px_2 } from '../_shared/esm/BtIconTickAlt2Px-da97e9ae.js';
6
+ import { C as Context } from '../_shared/esm/Surface-bf201530.js';
7
+ import { F as FormControl } from '../_shared/esm/FormControl-2cb96de7.js';
8
+ import { V as VerticalSpace } from '../_shared/esm/VerticalSpace-6b4f5e50.js';
9
+ import { T as Text } from '../_shared/esm/Text-6b958ad8.js';
10
+ import 'react-dom';
11
+ import '../_shared/esm/index-229fc864.js';
12
+ import '../_shared/esm/suffix-modifier-f5e28822.js';
13
+ import '../_shared/esm/BtIconChevronRightMid-d9b11761.js';
14
+
15
+ function $db6c3485150b8e66$export$1ab7ae714698c4b8(element) {
16
+ const [size, setSize] = useState(undefined);
17
+ $9f79659886946c16$export$e5c5a5f917a5871c(()=>{
18
+ if (element) {
19
+ // provide size as early as possible
20
+ setSize({
21
+ width: element.offsetWidth,
22
+ height: element.offsetHeight
23
+ });
24
+ const resizeObserver = new ResizeObserver((entries)=>{
25
+ if (!Array.isArray(entries)) return;
26
+ // Since we only observe the one element, we don't need to loop over the
27
+ // array
28
+ if (!entries.length) return;
29
+ const entry = entries[0];
30
+ let width;
31
+ let height;
32
+ if ('borderBoxSize' in entry) {
33
+ const borderSizeEntry = entry['borderBoxSize']; // iron out differences between browsers
34
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
35
+ width = borderSize['inlineSize'];
36
+ height = borderSize['blockSize'];
37
+ } else {
38
+ // for browsers that don't support `borderBoxSize`
39
+ // we calculate it ourselves to get the correct border box.
40
+ width = element.offsetWidth;
41
+ height = element.offsetHeight;
42
+ }
43
+ setSize({
44
+ width: width,
45
+ height: height
46
+ });
47
+ });
48
+ resizeObserver.observe(element, {
49
+ box: 'border-box'
50
+ });
51
+ return ()=>resizeObserver.unobserve(element)
52
+ ;
53
+ } else // We only want to reset to `undefined` when the element becomes `null`,
54
+ // not if it changes to another element.
55
+ setSize(undefined);
56
+ }, [
57
+ element
58
+ ]);
59
+ return size;
60
+ }
61
+
62
+ /* -------------------------------------------------------------------------------------------------
63
+ * Switch
64
+ * -----------------------------------------------------------------------------------------------*/ const $6be4966fd9bbc698$var$SWITCH_NAME = 'Switch';
65
+ const [$6be4966fd9bbc698$var$createSwitchContext, $6be4966fd9bbc698$export$cf7f5f17f69cbd43] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($6be4966fd9bbc698$var$SWITCH_NAME);
66
+ const [$6be4966fd9bbc698$var$SwitchProvider, $6be4966fd9bbc698$var$useSwitchContext] = $6be4966fd9bbc698$var$createSwitchContext($6be4966fd9bbc698$var$SWITCH_NAME);
67
+ const $6be4966fd9bbc698$export$b5d5cf8927ab7262 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
68
+ const { __scopeSwitch: __scopeSwitch , name: name , checked: checkedProp , defaultChecked: defaultChecked , required: required , disabled: disabled , value: value = 'on' , onCheckedChange: onCheckedChange , ...switchProps } = props;
69
+ const [button, setButton] = useState(null);
70
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, (node)=>setButton(node)
71
+ );
72
+ const hasConsumerStoppedPropagationRef = useRef(false); // We set this to true by default so that events bubble to forms without JS (SSR)
73
+ const isFormControl = button ? Boolean(button.closest('form')) : true;
74
+ const [checked = false, setChecked] = $71cd76cc60e0454e$export$6f32135080cb4c3({
75
+ prop: checkedProp,
76
+ defaultProp: defaultChecked,
77
+ onChange: onCheckedChange
78
+ });
79
+ return /*#__PURE__*/ createElement($6be4966fd9bbc698$var$SwitchProvider, {
80
+ scope: __scopeSwitch,
81
+ checked: checked,
82
+ disabled: disabled
83
+ }, /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
84
+ type: "button",
85
+ role: "switch",
86
+ "aria-checked": checked,
87
+ "aria-required": required,
88
+ "data-state": $6be4966fd9bbc698$var$getState(checked),
89
+ "data-disabled": disabled ? '' : undefined,
90
+ disabled: disabled,
91
+ value: value
92
+ }, switchProps, {
93
+ ref: composedRefs,
94
+ onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, (event)=>{
95
+ setChecked((prevChecked)=>!prevChecked
96
+ );
97
+ if (isFormControl) {
98
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); // if switch is in a form, stop propagation from the button so that we only propagate
99
+ // one click event (from the input). We propagate changes from an input so that native
100
+ // form validation works and form events reflect switch updates.
101
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
102
+ }
103
+ })
104
+ })), isFormControl && /*#__PURE__*/ createElement($6be4966fd9bbc698$var$BubbleInput, {
105
+ control: button,
106
+ bubbles: !hasConsumerStoppedPropagationRef.current,
107
+ name: name,
108
+ value: value,
109
+ checked: checked,
110
+ required: required,
111
+ disabled: disabled // We transform because the input is absolutely positioned but we have
112
+ ,
113
+ style: {
114
+ transform: 'translateX(-100%)'
115
+ }
116
+ }));
117
+ });
118
+ /* -------------------------------------------------------------------------------------------------
119
+ * SwitchThumb
120
+ * -----------------------------------------------------------------------------------------------*/ const $6be4966fd9bbc698$var$THUMB_NAME = 'SwitchThumb';
121
+ const $6be4966fd9bbc698$export$4d07bf653ea69106 = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
122
+ const { __scopeSwitch: __scopeSwitch , ...thumbProps } = props;
123
+ const context = $6be4966fd9bbc698$var$useSwitchContext($6be4966fd9bbc698$var$THUMB_NAME, __scopeSwitch);
124
+ return /*#__PURE__*/ createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
125
+ "data-state": $6be4966fd9bbc698$var$getState(context.checked),
126
+ "data-disabled": context.disabled ? '' : undefined
127
+ }, thumbProps, {
128
+ ref: forwardedRef
129
+ }));
130
+ });
131
+ /* ---------------------------------------------------------------------------------------------- */ const $6be4966fd9bbc698$var$BubbleInput = (props)=>{
132
+ const { control: control , checked: checked , bubbles: bubbles = true , ...inputProps } = props;
133
+ const ref = useRef(null);
134
+ const prevChecked = $010c2913dbd2fe3d$export$5cae361ad82dce8b(checked);
135
+ const controlSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(control); // Bubble checked change to parents (e.g form change event)
136
+ useEffect(()=>{
137
+ const input = ref.current;
138
+ const inputProto = window.HTMLInputElement.prototype;
139
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, 'checked');
140
+ const setChecked = descriptor.set;
141
+ if (prevChecked !== checked && setChecked) {
142
+ const event = new Event('click', {
143
+ bubbles: bubbles
144
+ });
145
+ setChecked.call(input, checked);
146
+ input.dispatchEvent(event);
147
+ }
148
+ }, [
149
+ prevChecked,
150
+ checked,
151
+ bubbles
152
+ ]);
153
+ return /*#__PURE__*/ createElement("input", _extends({
154
+ type: "checkbox",
155
+ "aria-hidden": true,
156
+ defaultChecked: checked
157
+ }, inputProps, {
158
+ tabIndex: -1,
159
+ ref: ref,
160
+ style: {
161
+ ...props.style,
162
+ ...controlSize,
163
+ position: 'absolute',
164
+ pointerEvents: 'none',
165
+ opacity: 0,
166
+ margin: 0
167
+ }
168
+ }));
169
+ };
170
+ function $6be4966fd9bbc698$var$getState(checked) {
171
+ return checked ? 'checked' : 'unchecked';
172
+ }
173
+ const $6be4966fd9bbc698$export$be92b6f5f03c0fe9 = $6be4966fd9bbc698$export$b5d5cf8927ab7262;
174
+ const $6be4966fd9bbc698$export$6521433ed15a34db = $6be4966fd9bbc698$export$4d07bf653ea69106;
175
+
176
+ /** Use `Switch` to toggle between checked and not checked. */
177
+ var Switch = function (_a) {
178
+ var defaultChecked = _a.defaultChecked, onCheckedChange = _a.onCheckedChange, label = _a.label, name = _a.name, onBlur = _a.onBlur, value = _a.value, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, errorMessage = _a.errorMessage, id = _a.id, _c = _a.labelSize, labelSize = _c === void 0 ? "s" : _c, statusText = _a.statusText, _d = _a.hideLabel, hideLabel = _d === void 0 ? false : _d;
179
+ var surface = useContext(Context).surface;
180
+ return (React__default.createElement(FormControl, { errorMessage: errorMessage, htmlFor: id, isDisabled: isDisabled, label: hideLabel ? "" : label, labelSize: labelSize, requirementStatus: "not-applicable" },
181
+ !hideLabel && React__default.createElement(VerticalSpace, { size: "8" }),
182
+ React__default.createElement("div", { className: "arc-Switch-container" },
183
+ React__default.createElement($6be4966fd9bbc698$export$be92b6f5f03c0fe9, { id: id, "aria-label": label, defaultChecked: defaultChecked, name: name, value: value, onBlur: onBlur, onCheckedChange: onCheckedChange, disabled: isDisabled, className: classNames("arc-Switch", {
184
+ "arc-Switch--large": labelSize === "l",
185
+ "arc-Switch--isDisabled": isDisabled,
186
+ "arc-Switch--onDarkSurface": surface === "dark"
187
+ }) },
188
+ React__default.createElement("div", { className: "arc-Switch-wrapper" },
189
+ React__default.createElement($6be4966fd9bbc698$export$6521433ed15a34db, { className: "arc-Switch-thumb" },
190
+ React__default.createElement("div", { className: "arc-Switch-thumbIcon" },
191
+ React__default.createElement("div", { className: "arc-Switch-icon", "data-testid": "arc-switch-thumb-icon" },
192
+ React__default.createElement(Icon, { icon: BtIconTickAlt2Px_2, color: surface === "dark" ? "brand" : "brand", size: labelSize === "l" ? 24 : 16 })))))),
193
+ React__default.createElement("div", { className: classNames("arc-Switch-statusText", {
194
+ "arc-Switch-statusText--isDisabled": isDisabled,
195
+ "arc-Switch-statusText--onDarkSurface": surface === "dark"
196
+ }) },
197
+ React__default.createElement(Text, { size: labelSize },
198
+ " ",
199
+ statusText,
200
+ " ")))));
201
+ };
202
+
203
+ export { Switch };
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@arc-ui/switch",
3
+ "types": "./Switch.esm.d.ts",
4
+ "main": "./Switch.cjs.js",
5
+ "module": "./Switch.esm.js",
6
+ "private": true
7
+ }
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
3
  import { FC } from "react";
4
- import { FormControlProps } from "../_shared/cjs/FormControl-e6b7d7c5";
4
+ import { FormControlProps } from "../_shared/cjs/FormControl-d4d9c665";
5
5
  type EventType = React.ChangeEvent<HTMLInputElement>;
6
6
  /**
7
7
  * Use `TextInput` to allow custom user text entry with a keyboard.
8
8
  */
9
9
  declare const TextInput: FC<TextInputProps>;
10
- interface TextInputProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus"> {
10
+ interface TextInputProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus" | "helperUnderLabel"> {
11
11
  /**
12
12
  * Uncontrolled default value of the TextInput. If the TextInput is controlled
13
13
  * via `value`/`onChange`, `defaultValue` will be ignored.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var index = require('../_shared/cjs/index-78b35bc1.js');
6
6
  var index$1 = require('../_shared/cjs/index-45bfb67b.js');
7
7
  var React = require('react');
8
- var FormControl = require('../_shared/cjs/FormControl-e6b7d7c5.js');
8
+ var FormControl = require('../_shared/cjs/FormControl-d4d9c665.js');
9
9
  var Surface = require('../_shared/cjs/Surface-d6b8010e.js');
10
10
  var VisuallyHidden = require('../_shared/cjs/VisuallyHidden-e2c8b291.js');
11
11
  require('../_shared/cjs/Text-1d3844be.js');
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
3
  import { FC } from "react";
4
- import { FormControlProps } from "../_shared/esm/FormControl-84c9ace6";
4
+ import { FormControlProps } from "../_shared/esm/FormControl-2cb96de7";
5
5
  type EventType = React.ChangeEvent<HTMLInputElement>;
6
6
  /**
7
7
  * Use `TextInput` to allow custom user text entry with a keyboard.
8
8
  */
9
9
  declare const TextInput: FC<TextInputProps>;
10
- interface TextInputProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus"> {
10
+ interface TextInputProps extends Omit<FormControlProps, "children" | "elementType" | "htmlFor" | "requirementStatus" | "helperUnderLabel"> {
11
11
  /**
12
12
  * Uncontrolled default value of the TextInput. If the TextInput is controlled
13
13
  * via `value`/`onChange`, `defaultValue` will be ignored.
@@ -1,7 +1,7 @@
1
1
  import { _ as __rest, a as __assign, f as filterDataAttrs } from '../_shared/esm/index-229fc864.js';
2
2
  import { c as classNames } from '../_shared/esm/index-2ae58626.js';
3
3
  import React__default, { forwardRef, useContext, useState } from 'react';
4
- import { u as useAriaDescribedby, F as FormControl } from '../_shared/esm/FormControl-84c9ace6.js';
4
+ import { u as useAriaDescribedby, F as FormControl } from '../_shared/esm/FormControl-2cb96de7.js';
5
5
  import { C as Context } from '../_shared/esm/Surface-bf201530.js';
6
6
  import { V as VisuallyHidden } from '../_shared/esm/VisuallyHidden-b9eebf71.js';
7
7
  import '../_shared/esm/Text-6b958ad8.js';
@@ -1,18 +1 @@
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 };
1
+ export { VerticalSpace } from "../_shared/cjs/VerticalSpace-65ad083c";
@@ -2,26 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../_shared/cjs/index-78b35bc1.js');
6
- var index$1 = require('../_shared/cjs/index-45bfb67b.js');
7
- var React = require('react');
5
+ var VerticalSpace = require('../_shared/cjs/VerticalSpace-65ad083c.js');
6
+ require('../_shared/cjs/index-78b35bc1.js');
7
+ require('../_shared/cjs/index-45bfb67b.js');
8
+ require('react');
8
9
 
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
11
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
11
 
13
- /**
14
- * Use `VerticalSpace` to create vertical space between components.
15
- */
16
- var VerticalSpace = function (_a) {
17
- var _b;
18
- 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"]);
19
- return (React__default["default"].createElement("div", index.__assign({ className: index$1.classNames((_b = {
20
- "arc-VerticalSpace": true
21
- },
22
- _b["arc-VerticalSpace--size".concat(size)] = size && size !== "24",
23
- _b["arc-VerticalSpace--debugVisible"] = isDebugVisible,
24
- _b)) }, index.filterDataAttrs(props))));
25
- };
26
-
27
- exports.VerticalSpace = VerticalSpace;
12
+ exports.VerticalSpace = VerticalSpace.VerticalSpace;
@@ -1,18 +1 @@
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 };
1
+ export { VerticalSpace } from "../_shared/esm/VerticalSpace-6b4f5e50";