@eightshift/ui-components 5.0.0 → 5.0.1

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 (144) hide show
  1. package/dist/Button-wERNNG0T.js +185 -0
  2. package/dist/Collection-CKsHTyhc.js +2363 -0
  3. package/dist/Color-BhgbJF5x.js +2452 -0
  4. package/dist/ColorSwatch-Bcn6oRSg.js +64 -0
  5. package/dist/ComboBox-D1LPUwWP.js +1906 -0
  6. package/dist/Dialog-D190gMbE.js +2298 -0
  7. package/dist/FieldError-DeUh5Wkw.js +42 -0
  8. package/dist/FocusScope-C-plSxbS.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-C5iZpSAM.js +48 -0
  11. package/dist/Heading-D-Pboe4p.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input--mF4XVE1.js +133 -0
  14. package/dist/Label-Fp6AwSRn.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-4oW9kh3R.js +582 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-BpB9uB_I.js +637 -0
  19. package/dist/RSPContexts-2lR5GG9p.js +14 -0
  20. package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
  21. package/dist/Separator-B88tj5YD.js +323 -0
  22. package/dist/Slider-CyJzC1bp.js +853 -0
  23. package/dist/Text-DRpwWot2.js +16 -0
  24. package/dist/VisuallyHidden-DsKYcRQ_.js +48 -0
  25. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  26. package/dist/assets/index.css +57 -0
  27. package/dist/assets/style-admin.css +5864 -0
  28. package/dist/assets/style-editor.css +5864 -0
  29. package/dist/assets/style.css +5870 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +377 -0
  32. package/dist/components/animated-visibility/animated-visibility.js +105 -0
  33. package/dist/components/base-control/base-control.js +86 -0
  34. package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
  35. package/dist/components/button/button.js +387 -0
  36. package/dist/components/checkbox/checkbox.js +320 -0
  37. package/dist/components/color-pickers/color-picker.js +272 -0
  38. package/dist/components/color-pickers/color-swatch.js +59 -0
  39. package/dist/components/color-pickers/gradient-editor.js +534 -0
  40. package/dist/components/color-pickers/solid-color-picker.js +1567 -0
  41. package/dist/components/component-toggle/component-toggle.js +161 -0
  42. package/dist/components/container-panel/container-panel.js +131 -0
  43. package/dist/components/draggable/draggable-context.js +5 -0
  44. package/dist/components/draggable/draggable-handle.js +46 -0
  45. package/dist/components/draggable/draggable.js +6979 -0
  46. package/dist/components/draggable-list/draggable-list-context.js +5 -0
  47. package/dist/components/draggable-list/draggable-list-item.js +77 -0
  48. package/dist/components/draggable-list/draggable-list.js +151 -0
  49. package/dist/components/expandable/expandable.js +342 -0
  50. package/dist/components/index.js +137 -0
  51. package/dist/components/input-field/input-field.js +231 -0
  52. package/dist/components/item-collection/item-collection.js +59 -0
  53. package/dist/components/layout/hstack.js +30 -0
  54. package/dist/components/layout/vstack.js +30 -0
  55. package/dist/components/link-input/link-input.js +291 -0
  56. package/dist/components/matrix-align/matrix-align.js +134 -0
  57. package/dist/components/menu/menu.js +285 -0
  58. package/dist/components/modal/modal.js +305 -0
  59. package/dist/components/notice/notice.js +123 -0
  60. package/dist/components/number-picker/number-picker.js +292 -0
  61. package/dist/components/option-select/option-select.js +264 -0
  62. package/dist/components/options-panel/options-panel.js +158 -0
  63. package/dist/components/placeholders/file-placeholder.js +42 -0
  64. package/dist/components/placeholders/image-placeholder.js +88 -0
  65. package/dist/components/placeholders/media-placeholder.js +63 -0
  66. package/dist/components/popover/popover.js +207 -0
  67. package/dist/components/radio/radio.js +579 -0
  68. package/dist/components/repeater/repeater-context.js +5 -0
  69. package/dist/components/repeater/repeater-item.js +119 -0
  70. package/dist/components/repeater/repeater.js +280 -0
  71. package/dist/components/responsive/mini-responsive.js +498 -0
  72. package/dist/components/responsive/responsive-legacy.js +343 -0
  73. package/dist/components/responsive/responsive.js +583 -0
  74. package/dist/components/responsive-preview/responsive-preview.js +123 -0
  75. package/dist/components/rich-label/rich-label.js +66 -0
  76. package/dist/components/select/async-multi-select.js +157 -0
  77. package/dist/components/select/async-single-select.js +137 -0
  78. package/dist/components/select/custom-select-default-components.js +38 -0
  79. package/dist/components/select/multi-select-components.js +8 -0
  80. package/dist/components/select/multi-select.js +151 -0
  81. package/dist/components/select/react-select-component-wrappers.js +90 -0
  82. package/dist/components/select/shared.js +26 -0
  83. package/dist/components/select/single-select.js +131 -0
  84. package/dist/components/select/styles.js +49 -0
  85. package/dist/components/select/v2/async-select.js +297 -0
  86. package/dist/components/select/v2/shared.js +24 -0
  87. package/dist/components/select/v2/single-select.js +991 -0
  88. package/dist/components/slider/column-config-slider.js +210 -0
  89. package/dist/components/slider/slider.js +345 -0
  90. package/dist/components/slider/utils.js +94 -0
  91. package/dist/components/spacer/spacer.js +97 -0
  92. package/dist/components/tabs/tabs.js +704 -0
  93. package/dist/components/toggle/switch.js +156 -0
  94. package/dist/components/toggle/toggle.js +64 -0
  95. package/dist/components/toggle-button/toggle-button.js +343 -0
  96. package/dist/components/tooltip/tooltip.js +527 -0
  97. package/dist/context-BYWrbm1z.js +92 -0
  98. package/dist/default-i18n-CT_oS1Fy.js +922 -0
  99. package/dist/filterDOMProps-EDDcM64A.js +28 -0
  100. package/dist/icons/block-icon.js +42 -0
  101. package/dist/icons/generic-color-swatch.js +113 -0
  102. package/dist/icons/icons.js +30371 -0
  103. package/dist/icons/index.js +11 -0
  104. package/dist/icons/jsx-svg.js +50 -0
  105. package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
  106. package/dist/index-CFozsmNS.js +28321 -0
  107. package/dist/index-wl5606BX.js +44 -0
  108. package/dist/index.js +139 -0
  109. package/dist/lite-DVmmD_-j.js +7 -0
  110. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  111. package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
  112. package/dist/number-GajL10e1.js +36 -0
  113. package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
  114. package/dist/react-select-async.esm-D937XTWW.js +107 -0
  115. package/dist/react-select.esm-Ciai3aKf.js +15 -0
  116. package/dist/style-admin.js +1 -0
  117. package/dist/style-editor.js +1 -0
  118. package/dist/style.js +1 -0
  119. package/dist/textSelection-CCcyjiRP.js +46 -0
  120. package/dist/useButton-BOHxkGQF.js +50 -0
  121. package/dist/useEvent-D5o_CqDH.js +23 -0
  122. package/dist/useFocusRing-nMG2uzxS.js +107 -0
  123. package/dist/useFormReset-DlmRL87g.js +22 -0
  124. package/dist/useFormValidation-D0_aaK-e.js +224 -0
  125. package/dist/useHover-VO5tcIli.js +890 -0
  126. package/dist/useLabel-BKH4fVA4.js +27 -0
  127. package/dist/useLabels-ntF3rFY0.js +23 -0
  128. package/dist/useListState-Cq2Nvr-v.js +161 -0
  129. package/dist/useLocalizedStringFormatter-CGzwx1a0.js +121 -0
  130. package/dist/useNumberField-C9dmERhP.js +1207 -0
  131. package/dist/useNumberFormatter-MrRLgvhj.js +13 -0
  132. package/dist/usePress-DjNo5790.js +677 -0
  133. package/dist/useSingleSelectListState--r3AAhRj.js +38 -0
  134. package/dist/useToggle-CQaXLe-O.js +59 -0
  135. package/dist/useToggleState-C3DLdez5.js +19 -0
  136. package/dist/utilities/array-helpers.js +56 -0
  137. package/dist/utilities/debounce-throttle.js +123 -0
  138. package/dist/utilities/es-dash.js +382 -0
  139. package/dist/utilities/index.js +27 -0
  140. package/dist/utilities/text-helpers.js +136 -0
  141. package/dist/utils-B94NDG0v.js +370 -0
  142. package/dist/wp/wp-font-enhancements.js +1 -0
  143. package/dist/wp/wp-ui-enhancements.js +1 -0
  144. package/package.json +8 -8
@@ -0,0 +1,107 @@
1
+ import { a as _objectWithoutProperties, b as _slicedToArray, h as handleInputChange, d as _objectSpread2, e as _defineProperty, _ as _extends } from "./index-641ee5b8.esm-BPU8rMZr.js";
2
+ import * as React from "react";
3
+ import { useRef, useState, useEffect, useCallback, forwardRef } from "react";
4
+ import { u as useStateManager, S as Select } from "./Select-aab027f3.esm-BKIJGje-.js";
5
+ import "./index-CFozsmNS.js";
6
+ var _excluded = ["defaultOptions", "cacheOptions", "loadOptions", "options", "isLoading", "onInputChange", "filterOption"];
7
+ function useAsync(_ref) {
8
+ var _ref$defaultOptions = _ref.defaultOptions, propsDefaultOptions = _ref$defaultOptions === void 0 ? false : _ref$defaultOptions, _ref$cacheOptions = _ref.cacheOptions, cacheOptions = _ref$cacheOptions === void 0 ? false : _ref$cacheOptions, propsLoadOptions = _ref.loadOptions;
9
+ _ref.options;
10
+ var _ref$isLoading = _ref.isLoading, propsIsLoading = _ref$isLoading === void 0 ? false : _ref$isLoading, propsOnInputChange = _ref.onInputChange, _ref$filterOption = _ref.filterOption, filterOption = _ref$filterOption === void 0 ? null : _ref$filterOption, restSelectProps = _objectWithoutProperties(_ref, _excluded);
11
+ var propsInputValue = restSelectProps.inputValue;
12
+ var lastRequest = useRef(void 0);
13
+ var mounted = useRef(false);
14
+ var _useState = useState(Array.isArray(propsDefaultOptions) ? propsDefaultOptions : void 0), _useState2 = _slicedToArray(_useState, 2), defaultOptions = _useState2[0], setDefaultOptions = _useState2[1];
15
+ var _useState3 = useState(typeof propsInputValue !== "undefined" ? propsInputValue : ""), _useState4 = _slicedToArray(_useState3, 2), stateInputValue = _useState4[0], setStateInputValue = _useState4[1];
16
+ var _useState5 = useState(propsDefaultOptions === true), _useState6 = _slicedToArray(_useState5, 2), isLoading = _useState6[0], setIsLoading = _useState6[1];
17
+ var _useState7 = useState(void 0), _useState8 = _slicedToArray(_useState7, 2), loadedInputValue = _useState8[0], setLoadedInputValue = _useState8[1];
18
+ var _useState9 = useState([]), _useState10 = _slicedToArray(_useState9, 2), loadedOptions = _useState10[0], setLoadedOptions = _useState10[1];
19
+ var _useState11 = useState(false), _useState12 = _slicedToArray(_useState11, 2), passEmptyOptions = _useState12[0], setPassEmptyOptions = _useState12[1];
20
+ var _useState13 = useState({}), _useState14 = _slicedToArray(_useState13, 2), optionsCache = _useState14[0], setOptionsCache = _useState14[1];
21
+ var _useState15 = useState(void 0), _useState16 = _slicedToArray(_useState15, 2), prevDefaultOptions = _useState16[0], setPrevDefaultOptions = _useState16[1];
22
+ var _useState17 = useState(void 0), _useState18 = _slicedToArray(_useState17, 2), prevCacheOptions = _useState18[0], setPrevCacheOptions = _useState18[1];
23
+ if (cacheOptions !== prevCacheOptions) {
24
+ setOptionsCache({});
25
+ setPrevCacheOptions(cacheOptions);
26
+ }
27
+ if (propsDefaultOptions !== prevDefaultOptions) {
28
+ setDefaultOptions(Array.isArray(propsDefaultOptions) ? propsDefaultOptions : void 0);
29
+ setPrevDefaultOptions(propsDefaultOptions);
30
+ }
31
+ useEffect(function() {
32
+ mounted.current = true;
33
+ return function() {
34
+ mounted.current = false;
35
+ };
36
+ }, []);
37
+ var loadOptions = useCallback(function(inputValue, callback) {
38
+ if (!propsLoadOptions) return callback();
39
+ var loader = propsLoadOptions(inputValue, callback);
40
+ if (loader && typeof loader.then === "function") {
41
+ loader.then(callback, function() {
42
+ return callback();
43
+ });
44
+ }
45
+ }, [propsLoadOptions]);
46
+ useEffect(function() {
47
+ if (propsDefaultOptions === true) {
48
+ loadOptions(stateInputValue, function(options2) {
49
+ if (!mounted.current) return;
50
+ setDefaultOptions(options2 || []);
51
+ setIsLoading(!!lastRequest.current);
52
+ });
53
+ }
54
+ }, []);
55
+ var onInputChange = useCallback(function(newValue, actionMeta) {
56
+ var inputValue = handleInputChange(newValue, actionMeta, propsOnInputChange);
57
+ if (!inputValue) {
58
+ lastRequest.current = void 0;
59
+ setStateInputValue("");
60
+ setLoadedInputValue("");
61
+ setLoadedOptions([]);
62
+ setIsLoading(false);
63
+ setPassEmptyOptions(false);
64
+ return;
65
+ }
66
+ if (cacheOptions && optionsCache[inputValue]) {
67
+ setStateInputValue(inputValue);
68
+ setLoadedInputValue(inputValue);
69
+ setLoadedOptions(optionsCache[inputValue]);
70
+ setIsLoading(false);
71
+ setPassEmptyOptions(false);
72
+ } else {
73
+ var request = lastRequest.current = {};
74
+ setStateInputValue(inputValue);
75
+ setIsLoading(true);
76
+ setPassEmptyOptions(!loadedInputValue);
77
+ loadOptions(inputValue, function(options2) {
78
+ if (!mounted) return;
79
+ if (request !== lastRequest.current) return;
80
+ lastRequest.current = void 0;
81
+ setIsLoading(false);
82
+ setLoadedInputValue(inputValue);
83
+ setLoadedOptions(options2 || []);
84
+ setPassEmptyOptions(false);
85
+ setOptionsCache(options2 ? _objectSpread2(_objectSpread2({}, optionsCache), {}, _defineProperty({}, inputValue, options2)) : optionsCache);
86
+ });
87
+ }
88
+ }, [cacheOptions, loadOptions, loadedInputValue, optionsCache, propsOnInputChange]);
89
+ var options = passEmptyOptions ? [] : stateInputValue && loadedInputValue ? loadedOptions : defaultOptions || [];
90
+ return _objectSpread2(_objectSpread2({}, restSelectProps), {}, {
91
+ options,
92
+ isLoading: isLoading || propsIsLoading,
93
+ onInputChange,
94
+ filterOption
95
+ });
96
+ }
97
+ var AsyncSelect = /* @__PURE__ */ forwardRef(function(props, ref) {
98
+ var stateManagedProps = useAsync(props);
99
+ var selectProps = useStateManager(stateManagedProps);
100
+ return /* @__PURE__ */ React.createElement(Select, _extends({
101
+ ref
102
+ }, selectProps));
103
+ });
104
+ var AsyncSelect$1 = AsyncSelect;
105
+ export {
106
+ AsyncSelect$1 as A
107
+ };
@@ -0,0 +1,15 @@
1
+ import { u as useStateManager, S as Select } from "./Select-aab027f3.esm-BKIJGje-.js";
2
+ import { _ as _extends } from "./index-641ee5b8.esm-BPU8rMZr.js";
3
+ import * as React from "react";
4
+ import { forwardRef } from "react";
5
+ import "./index-CFozsmNS.js";
6
+ var StateManagedSelect = /* @__PURE__ */ forwardRef(function(props, ref) {
7
+ var baseSelectProps = useStateManager(props);
8
+ return /* @__PURE__ */ React.createElement(Select, _extends({
9
+ ref
10
+ }, baseSelectProps));
11
+ });
12
+ var StateManagedSelect$1 = StateManagedSelect;
13
+ export {
14
+ StateManagedSelect$1 as S
15
+ };
@@ -0,0 +1 @@
1
+ import './assets/style-admin.css';
@@ -0,0 +1 @@
1
+ import './assets/index.css';import './assets/style-editor.css';/* empty css */
package/dist/style.js ADDED
@@ -0,0 +1 @@
1
+ import './assets/index.css';import './assets/style.css';/* empty css */
@@ -0,0 +1,46 @@
1
+ import { c as $c87311424ea30a05$export$fedb369cb70207f1, d as $431fbd86ca7dc216$export$b204af158042fbac, e as $bbed8b41f857bcc0$export$24490316f764c430 } from "./useHover-VO5tcIli.js";
2
+ let $14c0b72509d70225$var$state = "default";
3
+ let $14c0b72509d70225$var$savedUserSelect = "";
4
+ let $14c0b72509d70225$var$modifiedElementMap = /* @__PURE__ */ new WeakMap();
5
+ function $14c0b72509d70225$export$16a4697467175487(target) {
6
+ if ($c87311424ea30a05$export$fedb369cb70207f1()) {
7
+ if ($14c0b72509d70225$var$state === "default") {
8
+ const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
9
+ $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
10
+ documentObject.documentElement.style.webkitUserSelect = "none";
11
+ }
12
+ $14c0b72509d70225$var$state = "disabled";
13
+ } else if (target instanceof HTMLElement || target instanceof SVGElement) {
14
+ let property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
15
+ $14c0b72509d70225$var$modifiedElementMap.set(target, target.style[property]);
16
+ target.style[property] = "none";
17
+ }
18
+ }
19
+ function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
20
+ if ($c87311424ea30a05$export$fedb369cb70207f1()) {
21
+ if ($14c0b72509d70225$var$state !== "disabled") return;
22
+ $14c0b72509d70225$var$state = "restoring";
23
+ setTimeout(() => {
24
+ $bbed8b41f857bcc0$export$24490316f764c430(() => {
25
+ if ($14c0b72509d70225$var$state === "restoring") {
26
+ const documentObject = $431fbd86ca7dc216$export$b204af158042fbac(target);
27
+ if (documentObject.documentElement.style.webkitUserSelect === "none") documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || "";
28
+ $14c0b72509d70225$var$savedUserSelect = "";
29
+ $14c0b72509d70225$var$state = "default";
30
+ }
31
+ });
32
+ }, 300);
33
+ } else if (target instanceof HTMLElement || target instanceof SVGElement) {
34
+ if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
35
+ let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
36
+ let property = "userSelect" in target.style ? "userSelect" : "webkitUserSelect";
37
+ if (target.style[property] === "none") target.style[property] = targetOldUserSelect;
38
+ if (target.getAttribute("style") === "") target.removeAttribute("style");
39
+ $14c0b72509d70225$var$modifiedElementMap.delete(target);
40
+ }
41
+ }
42
+ }
43
+ export {
44
+ $14c0b72509d70225$export$b0d6fa1ab32e3295 as $,
45
+ $14c0b72509d70225$export$16a4697467175487 as a
46
+ };
@@ -0,0 +1,50 @@
1
+ import { d as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "./utils-B94NDG0v.js";
2
+ import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps-EDDcM64A.js";
3
+ import { $ as $f6c31cce2adf654f$export$45712eceda6fad21 } from "./usePress-DjNo5790.js";
4
+ import { a as $f645667febf57a63$export$4c014de7c8940b4c } from "./useHover-VO5tcIli.js";
5
+ function $701a24aa0da5b062$export$ea18c227d4417cc3(props, ref) {
6
+ let { elementType = "button", isDisabled, onPress, onPressStart, onPressEnd, onPressUp, onPressChange, preventFocusOnPress, allowFocusWhenDisabled, onClick, href, target, rel, type = "button" } = props;
7
+ let additionalProps;
8
+ if (elementType === "button") additionalProps = {
9
+ type,
10
+ disabled: isDisabled
11
+ };
12
+ else additionalProps = {
13
+ role: "button",
14
+ href: elementType === "a" && !isDisabled ? href : void 0,
15
+ target: elementType === "a" ? target : void 0,
16
+ type: elementType === "input" ? type : void 0,
17
+ disabled: elementType === "input" ? isDisabled : void 0,
18
+ "aria-disabled": !isDisabled || elementType === "input" ? void 0 : isDisabled,
19
+ rel: elementType === "a" ? rel : void 0
20
+ };
21
+ let { pressProps, isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21({
22
+ onPressStart,
23
+ onPressEnd,
24
+ onPressChange,
25
+ onPress,
26
+ onPressUp,
27
+ onClick,
28
+ isDisabled,
29
+ preventFocusOnPress,
30
+ ref
31
+ });
32
+ let { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c(props, ref);
33
+ if (allowFocusWhenDisabled) focusableProps.tabIndex = isDisabled ? -1 : focusableProps.tabIndex;
34
+ let buttonProps = $3ef42575df84b30b$export$9d1611c77c2fe928(focusableProps, pressProps, $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
35
+ labelable: true
36
+ }));
37
+ return {
38
+ isPressed,
39
+ buttonProps: $3ef42575df84b30b$export$9d1611c77c2fe928(additionalProps, buttonProps, {
40
+ "aria-haspopup": props["aria-haspopup"],
41
+ "aria-expanded": props["aria-expanded"],
42
+ "aria-controls": props["aria-controls"],
43
+ "aria-pressed": props["aria-pressed"],
44
+ "aria-current": props["aria-current"]
45
+ })
46
+ };
47
+ }
48
+ export {
49
+ $701a24aa0da5b062$export$ea18c227d4417cc3 as $
50
+ };
@@ -0,0 +1,23 @@
1
+ import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52 } from "./utils-B94NDG0v.js";
2
+ import { useEffect } from "react";
3
+ function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
4
+ let handleEvent = $8ae05eaa5c114e9c$export$7f54fc3180508a52(handler);
5
+ let isDisabled = handler == null;
6
+ useEffect(() => {
7
+ if (isDisabled || !ref.current) return;
8
+ let element = ref.current;
9
+ element.addEventListener(event, handleEvent, options);
10
+ return () => {
11
+ element.removeEventListener(event, handleEvent, options);
12
+ };
13
+ }, [
14
+ ref,
15
+ event,
16
+ options,
17
+ isDisabled,
18
+ handleEvent
19
+ ]);
20
+ }
21
+ export {
22
+ $e9faafb641e167db$export$90fc3a17d93f704c as $
23
+ };
@@ -0,0 +1,107 @@
1
+ import { g as $03deb23ff14920c4$export$4eaf04e54aa8eed6, h as $8a9cb279dc87e130$export$715c682d09d639cc, d as $431fbd86ca7dc216$export$b204af158042fbac, i as $d4ee10de306f2510$export$cd4e5573fbe2b576, j as $d4ee10de306f2510$export$e58f029f0fbfdb29, k as $d4ee10de306f2510$export$4282f70798064fe0, l as $8a9cb279dc87e130$export$c2b7abe5d61ec696, m as $8a9cb279dc87e130$export$525bc4921d56d4a, n as $507fabe10e71c6fb$export$b9b3dfddab17db27, o as $507fabe10e71c6fb$export$ec71b4b83ac08ec3, p as $a1ea59d68270f0dd$export$f8168d8dd8fd66e6 } from "./useHover-VO5tcIli.js";
2
+ import { useRef, useCallback, useState } from "react";
3
+ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
4
+ let { isDisabled, onBlurWithin, onFocusWithin, onFocusWithinChange } = props;
5
+ let state = useRef({
6
+ isFocusWithin: false
7
+ });
8
+ let { addGlobalListener, removeAllGlobalListeners } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
9
+ let onBlur = useCallback((e) => {
10
+ if (!e.currentTarget.contains(e.target)) return;
11
+ if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
12
+ state.current.isFocusWithin = false;
13
+ removeAllGlobalListeners();
14
+ if (onBlurWithin) onBlurWithin(e);
15
+ if (onFocusWithinChange) onFocusWithinChange(false);
16
+ }
17
+ }, [
18
+ onBlurWithin,
19
+ onFocusWithinChange,
20
+ state,
21
+ removeAllGlobalListeners
22
+ ]);
23
+ let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
24
+ let onFocus = useCallback((e) => {
25
+ if (!e.currentTarget.contains(e.target)) return;
26
+ const ownerDocument = $431fbd86ca7dc216$export$b204af158042fbac(e.target);
27
+ const activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(ownerDocument);
28
+ if (!state.current.isFocusWithin && activeElement === $d4ee10de306f2510$export$e58f029f0fbfdb29(e.nativeEvent)) {
29
+ if (onFocusWithin) onFocusWithin(e);
30
+ if (onFocusWithinChange) onFocusWithinChange(true);
31
+ state.current.isFocusWithin = true;
32
+ onSyntheticFocus(e);
33
+ let currentTarget = e.currentTarget;
34
+ addGlobalListener(ownerDocument, "focus", (e2) => {
35
+ if (state.current.isFocusWithin && !$d4ee10de306f2510$export$4282f70798064fe0(currentTarget, e2.target)) {
36
+ let nativeEvent = new ownerDocument.defaultView.FocusEvent("blur", {
37
+ relatedTarget: e2.target
38
+ });
39
+ $8a9cb279dc87e130$export$c2b7abe5d61ec696(nativeEvent, currentTarget);
40
+ let event = $8a9cb279dc87e130$export$525bc4921d56d4a(nativeEvent);
41
+ onBlur(event);
42
+ }
43
+ }, {
44
+ capture: true
45
+ });
46
+ }
47
+ }, [
48
+ onFocusWithin,
49
+ onFocusWithinChange,
50
+ onSyntheticFocus,
51
+ addGlobalListener,
52
+ onBlur
53
+ ]);
54
+ if (isDisabled) return {
55
+ focusWithinProps: {
56
+ // These cannot be null, that would conflict in mergeProps
57
+ onFocus: void 0,
58
+ onBlur: void 0
59
+ }
60
+ };
61
+ return {
62
+ focusWithinProps: {
63
+ onFocus,
64
+ onBlur
65
+ }
66
+ };
67
+ }
68
+ function $f7dceffc5ad7768b$export$4e328f61c538687f(props = {}) {
69
+ let { autoFocus = false, isTextInput, within } = props;
70
+ let state = useRef({
71
+ isFocused: false,
72
+ isFocusVisible: autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27()
73
+ });
74
+ let [isFocused, setFocused] = useState(false);
75
+ let [isFocusVisibleState, setFocusVisible] = useState(() => state.current.isFocused && state.current.isFocusVisible);
76
+ let updateState = useCallback(() => setFocusVisible(state.current.isFocused && state.current.isFocusVisible), []);
77
+ let onFocusChange = useCallback((isFocused2) => {
78
+ state.current.isFocused = isFocused2;
79
+ setFocused(isFocused2);
80
+ updateState();
81
+ }, [
82
+ updateState
83
+ ]);
84
+ $507fabe10e71c6fb$export$ec71b4b83ac08ec3((isFocusVisible) => {
85
+ state.current.isFocusVisible = isFocusVisible;
86
+ updateState();
87
+ }, [], {
88
+ isTextInput
89
+ });
90
+ let { focusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6({
91
+ isDisabled: within,
92
+ onFocusChange
93
+ });
94
+ let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
95
+ isDisabled: !within,
96
+ onFocusWithinChange: onFocusChange
97
+ });
98
+ return {
99
+ isFocused,
100
+ isFocusVisible: isFocusVisibleState,
101
+ focusProps: within ? focusWithinProps : focusProps
102
+ };
103
+ }
104
+ export {
105
+ $f7dceffc5ad7768b$export$4e328f61c538687f as $,
106
+ $9ab94262bd0047c7$export$420e68273165f4ec as a
107
+ };
@@ -0,0 +1,22 @@
1
+ import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52 } from "./utils-B94NDG0v.js";
2
+ import { useRef, useEffect } from "react";
3
+ function $99facab73266f662$export$5add1d006293d136(ref, initialValue, onReset) {
4
+ let resetValue = useRef(initialValue);
5
+ let handleReset = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
6
+ if (onReset) onReset(resetValue.current);
7
+ });
8
+ useEffect(() => {
9
+ var _ref_current;
10
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
11
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
12
+ return () => {
13
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
14
+ };
15
+ }, [
16
+ ref,
17
+ handleReset
18
+ ]);
19
+ }
20
+ export {
21
+ $99facab73266f662$export$5add1d006293d136 as $
22
+ };
@@ -0,0 +1,224 @@
1
+ import { useMemo, useContext, createContext, useState, useRef, useEffect } from "react";
2
+ import { q as $507fabe10e71c6fb$export$8397ddfc504fdb9a } from "./useHover-VO5tcIli.js";
3
+ import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, f as $8ae05eaa5c114e9c$export$7f54fc3180508a52 } from "./utils-B94NDG0v.js";
4
+ const $e5be200c675c3b3a$export$aca958c65c314e6c = {
5
+ badInput: false,
6
+ customError: false,
7
+ patternMismatch: false,
8
+ rangeOverflow: false,
9
+ rangeUnderflow: false,
10
+ stepMismatch: false,
11
+ tooLong: false,
12
+ tooShort: false,
13
+ typeMismatch: false,
14
+ valueMissing: false,
15
+ valid: true
16
+ };
17
+ const $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE = {
18
+ ...$e5be200c675c3b3a$export$aca958c65c314e6c,
19
+ customError: true,
20
+ valid: false
21
+ };
22
+ const $e5be200c675c3b3a$export$dad6ae84456c676a = {
23
+ isInvalid: false,
24
+ validationDetails: $e5be200c675c3b3a$export$aca958c65c314e6c,
25
+ validationErrors: []
26
+ };
27
+ const $e5be200c675c3b3a$export$571b5131b7e65c11 = createContext({});
28
+ const $e5be200c675c3b3a$export$a763b9476acd3eb = "__formValidationState" + Date.now();
29
+ function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
30
+ if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
31
+ let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$e5be200c675c3b3a$export$a763b9476acd3eb];
32
+ return {
33
+ realtimeValidation,
34
+ displayValidation,
35
+ updateValidation,
36
+ resetValidation,
37
+ commitValidation
38
+ };
39
+ }
40
+ return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
41
+ }
42
+ function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
43
+ let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
44
+ if (validationState) isInvalid || (isInvalid = validationState === "invalid");
45
+ let controlledError = isInvalid !== void 0 ? {
46
+ isInvalid,
47
+ validationErrors: [],
48
+ validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
49
+ } : null;
50
+ let clientError = useMemo(() => {
51
+ if (!validate || value == null) return null;
52
+ let validateErrors = $e5be200c675c3b3a$var$runValidate(validate, value);
53
+ return $e5be200c675c3b3a$var$getValidationResult(validateErrors);
54
+ }, [
55
+ validate,
56
+ value
57
+ ]);
58
+ if (builtinValidation === null || builtinValidation === void 0 ? void 0 : builtinValidation.validationDetails.valid) builtinValidation = void 0;
59
+ let serverErrors = useContext($e5be200c675c3b3a$export$571b5131b7e65c11);
60
+ let serverErrorMessages = useMemo(() => {
61
+ if (name) return Array.isArray(name) ? name.flatMap((name2) => $e5be200c675c3b3a$var$asArray(serverErrors[name2])) : $e5be200c675c3b3a$var$asArray(serverErrors[name]);
62
+ return [];
63
+ }, [
64
+ serverErrors,
65
+ name
66
+ ]);
67
+ let [lastServerErrors, setLastServerErrors] = useState(serverErrors);
68
+ let [isServerErrorCleared, setServerErrorCleared] = useState(false);
69
+ if (serverErrors !== lastServerErrors) {
70
+ setLastServerErrors(serverErrors);
71
+ setServerErrorCleared(false);
72
+ }
73
+ let serverError = useMemo(() => $e5be200c675c3b3a$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
74
+ isServerErrorCleared,
75
+ serverErrorMessages
76
+ ]);
77
+ let nextValidation = useRef($e5be200c675c3b3a$export$dad6ae84456c676a);
78
+ let [currentValidity, setCurrentValidity] = useState($e5be200c675c3b3a$export$dad6ae84456c676a);
79
+ let lastError = useRef($e5be200c675c3b3a$export$dad6ae84456c676a);
80
+ let commitValidation = () => {
81
+ if (!commitQueued) return;
82
+ setCommitQueued(false);
83
+ let error = clientError || builtinValidation || nextValidation.current;
84
+ if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
85
+ lastError.current = error;
86
+ setCurrentValidity(error);
87
+ }
88
+ };
89
+ let [commitQueued, setCommitQueued] = useState(false);
90
+ useEffect(commitValidation);
91
+ let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
92
+ let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
93
+ return {
94
+ realtimeValidation,
95
+ displayValidation,
96
+ updateValidation(value2) {
97
+ if (validationBehavior === "aria" && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value2)) setCurrentValidity(value2);
98
+ else nextValidation.current = value2;
99
+ },
100
+ resetValidation() {
101
+ let error = $e5be200c675c3b3a$export$dad6ae84456c676a;
102
+ if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
103
+ lastError.current = error;
104
+ setCurrentValidity(error);
105
+ }
106
+ if (validationBehavior === "native") setCommitQueued(false);
107
+ setServerErrorCleared(true);
108
+ },
109
+ commitValidation() {
110
+ if (validationBehavior === "native") setCommitQueued(true);
111
+ setServerErrorCleared(true);
112
+ }
113
+ };
114
+ }
115
+ function $e5be200c675c3b3a$var$asArray(v) {
116
+ if (!v) return [];
117
+ return Array.isArray(v) ? v : [
118
+ v
119
+ ];
120
+ }
121
+ function $e5be200c675c3b3a$var$runValidate(validate, value) {
122
+ if (typeof validate === "function") {
123
+ let e = validate(value);
124
+ if (e && typeof e !== "boolean") return $e5be200c675c3b3a$var$asArray(e);
125
+ }
126
+ return [];
127
+ }
128
+ function $e5be200c675c3b3a$var$getValidationResult(errors) {
129
+ return errors.length ? {
130
+ isInvalid: true,
131
+ validationErrors: errors,
132
+ validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
133
+ } : null;
134
+ }
135
+ function $e5be200c675c3b3a$var$isEqualValidation(a, b) {
136
+ if (a === b) return true;
137
+ return !!a && !!b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
138
+ }
139
+ function $e93e671b31057976$export$b8473d3665f3a75a(props, state, ref) {
140
+ let { validationBehavior, focus } = props;
141
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
142
+ if (validationBehavior === "native" && (ref === null || ref === void 0 ? void 0 : ref.current) && !ref.current.disabled) {
143
+ let errorMessage = state.realtimeValidation.isInvalid ? state.realtimeValidation.validationErrors.join(" ") || "Invalid value." : "";
144
+ ref.current.setCustomValidity(errorMessage);
145
+ if (!ref.current.hasAttribute("title")) ref.current.title = "";
146
+ if (!state.realtimeValidation.isInvalid) state.updateValidation($e93e671b31057976$var$getNativeValidity(ref.current));
147
+ }
148
+ });
149
+ let onReset = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
150
+ state.resetValidation();
151
+ });
152
+ let onInvalid = $8ae05eaa5c114e9c$export$7f54fc3180508a52((e) => {
153
+ var _ref_current;
154
+ if (!state.displayValidation.isInvalid) state.commitValidation();
155
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
156
+ if (!e.defaultPrevented && ref && form && $e93e671b31057976$var$getFirstInvalidInput(form) === ref.current) {
157
+ var _ref_current1;
158
+ if (focus) focus();
159
+ else (_ref_current1 = ref.current) === null || _ref_current1 === void 0 ? void 0 : _ref_current1.focus();
160
+ $507fabe10e71c6fb$export$8397ddfc504fdb9a("keyboard");
161
+ }
162
+ e.preventDefault();
163
+ });
164
+ let onChange = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
165
+ state.commitValidation();
166
+ });
167
+ useEffect(() => {
168
+ let input = ref === null || ref === void 0 ? void 0 : ref.current;
169
+ if (!input) return;
170
+ let form = input.form;
171
+ input.addEventListener("invalid", onInvalid);
172
+ input.addEventListener("change", onChange);
173
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", onReset);
174
+ return () => {
175
+ input.removeEventListener("invalid", onInvalid);
176
+ input.removeEventListener("change", onChange);
177
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", onReset);
178
+ };
179
+ }, [
180
+ ref,
181
+ onInvalid,
182
+ onChange,
183
+ onReset,
184
+ validationBehavior
185
+ ]);
186
+ }
187
+ function $e93e671b31057976$var$getValidity(input) {
188
+ let validity = input.validity;
189
+ return {
190
+ badInput: validity.badInput,
191
+ customError: validity.customError,
192
+ patternMismatch: validity.patternMismatch,
193
+ rangeOverflow: validity.rangeOverflow,
194
+ rangeUnderflow: validity.rangeUnderflow,
195
+ stepMismatch: validity.stepMismatch,
196
+ tooLong: validity.tooLong,
197
+ tooShort: validity.tooShort,
198
+ typeMismatch: validity.typeMismatch,
199
+ valueMissing: validity.valueMissing,
200
+ valid: validity.valid
201
+ };
202
+ }
203
+ function $e93e671b31057976$var$getNativeValidity(input) {
204
+ return {
205
+ isInvalid: !input.validity.valid,
206
+ validationDetails: $e93e671b31057976$var$getValidity(input),
207
+ validationErrors: input.validationMessage ? [
208
+ input.validationMessage
209
+ ] : []
210
+ };
211
+ }
212
+ function $e93e671b31057976$var$getFirstInvalidInput(form) {
213
+ for (let i = 0; i < form.elements.length; i++) {
214
+ let element = form.elements[i];
215
+ if (!element.validity.valid) return element;
216
+ }
217
+ return null;
218
+ }
219
+ export {
220
+ $e5be200c675c3b3a$export$fc1a364ae1f3ff10 as $,
221
+ $e93e671b31057976$export$b8473d3665f3a75a as a,
222
+ $e5be200c675c3b3a$export$a763b9476acd3eb as b,
223
+ $e5be200c675c3b3a$export$dad6ae84456c676a as c
224
+ };