@eightshift/ui-components 5.0.0 → 5.0.2

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-BpwTmkAe.js +185 -0
  2. package/dist/Collection-n5d0zIgb.js +2398 -0
  3. package/dist/Color-lVhk8V_G.js +2452 -0
  4. package/dist/ColorSwatch-DntWEAC3.js +64 -0
  5. package/dist/ComboBox-BJpTEATT.js +1915 -0
  6. package/dist/Dialog-O9uw63D7.js +2317 -0
  7. package/dist/FieldError-DHrSdE_Q.js +42 -0
  8. package/dist/FocusScope-BEPI2m7u.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-DDPhPPTQ.js +48 -0
  11. package/dist/Heading-ba38ScjJ.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input-BmDS8Juy.js +133 -0
  14. package/dist/Label-JS_ob-kh.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-BTxlCGcc.js +664 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-5aDgmImj.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-CaTBkETC.js +332 -0
  22. package/dist/Slider-C-S1oEH9.js +853 -0
  23. package/dist/Text-BuJgePCv.js +16 -0
  24. package/dist/VisuallyHidden-BYi0pekx.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 +5908 -0
  28. package/dist/assets/style-editor.css +5908 -0
  29. package/dist/assets/style.css +5914 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +396 -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 +323 -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 +7320 -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 +284 -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 +582 -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 +1004 -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 +703 -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-BbYZoHvX.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 +30495 -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-BljRBEr_.js +44 -0
  107. package/dist/index-CFozsmNS.js +28321 -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-8DpK8fJl.js +46 -0
  120. package/dist/useButton-Bt3BffJm.js +50 -0
  121. package/dist/useEvent-ICdlokG-.js +23 -0
  122. package/dist/useFocusRing-Bv0UJQl8.js +107 -0
  123. package/dist/useFormReset-D2YaWRIA.js +22 -0
  124. package/dist/useFormValidation-Dy0PXJg5.js +224 -0
  125. package/dist/useHover-C2SkI1Fn.js +895 -0
  126. package/dist/useLabel-BPCd5c7-.js +27 -0
  127. package/dist/useLabels-B7-lUnAF.js +23 -0
  128. package/dist/useListState-DkyH7elT.js +168 -0
  129. package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
  130. package/dist/useNumberField-CU1_u8ze.js +1215 -0
  131. package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
  132. package/dist/usePress-BrJylgPR.js +688 -0
  133. package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
  134. package/dist/useToggle-CDa3YAZI.js +59 -0
  135. package/dist/useToggleState-ibcBUHnB.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-CZt7LCbO.js +403 -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 +24 -24
@@ -0,0 +1,123 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
3
+ import { icons } from "../../icons/icons.js";
4
+ /**
5
+ * A simple notice component.
6
+ *
7
+ * @component
8
+ * @param {Object} props - Component props.
9
+ * @param {JSX.Element} [props.icon] - Icon to display within the notice.
10
+ * @param {string} [props.label] - The label of the notice.
11
+ * @param {string} [props.subtitle] - The subtitle of the notice.
12
+ * @param {string} [props.className] - Classes to pass to the notice.
13
+ * @param {NoticeType} [props.type='default'] - The type of the notice.
14
+ * @param {boolean} [props.alignIconToTitle=false] - If `true`, the icon will be aligned to the first row of title, instead of vertically centered.
15
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
16
+ *
17
+ * @returns {JSX.Element} The Notice component.
18
+ *
19
+ * @typedef {'info' | 'success' | 'warning' | 'error' | 'placeholder' | 'default'} NoticeType
20
+ *
21
+ * @example
22
+ * <Notice label='This is a notice' />
23
+ *
24
+ * @preserve
25
+ */
26
+ const Notice = (props) => {
27
+ const { icon, label, subtitle, className, type = "default", alignIconToTitle = false, hidden } = props;
28
+ if (hidden) {
29
+ return null;
30
+ }
31
+ const styles = {
32
+ info: {
33
+ icon: icons.infoCircle,
34
+ className: "es:border-blue-400 es:shadow-blue-500/15 es:bg-blue-100/5",
35
+ iconColor: "es:text-blue-400",
36
+ textColor: "es:text-blue-900",
37
+ subtitleColor: "es:text-blue-950/60"
38
+ },
39
+ success: {
40
+ icon: icons.checkSquare,
41
+ className: "es:border-green-500 es:shadow-green-500/15 es:bg-green-100/5",
42
+ iconColor: "es:text-green-500",
43
+ textColor: "es:text-green-900",
44
+ subtitleColor: "es:text-green-950/60"
45
+ },
46
+ warning: {
47
+ icon: icons.warning,
48
+ className: "es:border-amber-500 es:shadow-amber-500/15 es:bg-amber-100/5",
49
+ iconColor: "es:text-amber-500",
50
+ textColor: "es:text-amber-900",
51
+ subtitleColor: "es:text-amber-950/60"
52
+ },
53
+ error: {
54
+ icon: icons.errorCircle,
55
+ className: "es:border-red-400 es:shadow-red-500/15 es:bg-red-100/5",
56
+ iconColor: "es:text-red-400",
57
+ textColor: "es:text-red-900",
58
+ subtitleColor: "es:text-red-950/60"
59
+ },
60
+ placeholder: {
61
+ icon: icons.componentGeneric,
62
+ className: "es:border-secondary-400 es:shadow-secondary-300/25 es:border-dashed es:bg-secondary-200/5",
63
+ iconColor: "es:text-secondary-400",
64
+ textColor: "es:text-secondary-900",
65
+ subtitleColor: "es:text-secondary-500"
66
+ },
67
+ default: {
68
+ className: "es:border-secondary-300 es:shadow-secondary-300/25 es:bg-secondary-200/5",
69
+ iconColor: "es:text-secondary-400",
70
+ textColor: "es:text-secondary-900",
71
+ subtitleColor: "es:text-secondary-500"
72
+ }
73
+ };
74
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
75
+ "div",
76
+ {
77
+ className: clsx(
78
+ "es:grid es:grid-cols-[auto_1fr] es:grid-rows-[auto_auto] es:rounded-md es:border es:bg-linear-to-tr es:shadow-sm",
79
+ styles[type].className,
80
+ icon || styles[type].icon ? "es:gap-x-1.5 es:p-1.5" : "es:px-2 es:py-1.5",
81
+ className
82
+ ),
83
+ children: [
84
+ (icon || styles[type].icon) && /* @__PURE__ */ jsx(
85
+ "span",
86
+ {
87
+ className: clsx(
88
+ "es:col-span-1 es:col-start-1 es:row-span-2 es:row-start-1 es:shrink-0 es:icon:size-7",
89
+ alignIconToTitle ? "es:self-baseline" : "es:self-center",
90
+ styles[type].iconColor
91
+ ),
92
+ children: icon ?? styles[type].icon
93
+ }
94
+ ),
95
+ label && /* @__PURE__ */ jsx(
96
+ "span",
97
+ {
98
+ className: clsx(
99
+ "es:col-span-2 es:col-start-2 es:text-balance es:text-sm es:leading-tight",
100
+ subtitle ? "es:self-end" : "es:row-span-2 es:self-center",
101
+ styles[type].textColor
102
+ ),
103
+ children: label
104
+ }
105
+ ),
106
+ subtitle && /* @__PURE__ */ jsx(
107
+ "span",
108
+ {
109
+ className: clsx(
110
+ "es:col-span-2 es:col-start-2 es:text-balance es:text-xs es:leading-tight",
111
+ styles[type].subtitleColor,
112
+ label ? "es:self-start" : "es:row-span-2 es:self-center"
113
+ ),
114
+ children: subtitle
115
+ }
116
+ )
117
+ ]
118
+ }
119
+ ) });
120
+ };
121
+ export {
122
+ Notice
123
+ };
@@ -0,0 +1,292 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import React__default, { forwardRef, createContext, useRef, useState, cloneElement } from "react";
3
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
4
+ import { a as $a049562f99e7db0e$export$f9c6924e160136d1, $ as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../../Group-DDPhPPTQ.js";
5
+ import { a as $3985021b0ad6602f$export$37fb8590cf2c088c, $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-BmDS8Juy.js";
6
+ import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-JS_ob-kh.js";
7
+ import { a as $d2b4bc8c273e7be6$export$24d547caef80ccd1 } from "../../Button-BpwTmkAe.js";
8
+ import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, g as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, h as $64fa3d84918910a7$export$ef03459518577ad4, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-CZt7LCbO.js";
9
+ import { $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-DHrSdE_Q.js";
10
+ import { $ as $d3e0e05bdfcf66bd$export$c24727297075ec6a } from "../../Form-Cq3fu75_.js";
11
+ import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-BuJgePCv.js";
12
+ import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
13
+ import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-BbYZoHvX.js";
14
+ import { $ as $de67e98908f0c6ee$export$7f629e9dc1ecf37c, a as $81397a9303501bda$export$23f548e970bdf099 } from "../../useNumberField-CU1_u8ze.js";
15
+ import { Button } from "../button/button.js";
16
+ import { icons } from "../../icons/icons.js";
17
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
18
+ import { BaseControl } from "../base-control/base-control.js";
19
+ const $b91743d66a0ed188$export$b414a48cf5dcbc11 = /* @__PURE__ */ createContext(null);
20
+ const $b91743d66a0ed188$export$6cc906c6cff9bec5 = /* @__PURE__ */ createContext(null);
21
+ const $b91743d66a0ed188$export$63c5fa0b2fdccd2e = /* @__PURE__ */ forwardRef(function NumberField(props, ref) {
22
+ [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $b91743d66a0ed188$export$b414a48cf5dcbc11);
23
+ let { validationBehavior: formValidationBehavior } = $64fa3d84918910a7$export$fabf2dc03a41866e($d3e0e05bdfcf66bd$export$c24727297075ec6a) || {};
24
+ var _props_validationBehavior, _ref;
25
+ let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : "native";
26
+ let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
27
+ let state = $de67e98908f0c6ee$export$7f629e9dc1ecf37c({
28
+ ...props,
29
+ locale,
30
+ validationBehavior
31
+ });
32
+ let inputRef = useRef(null);
33
+ let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(!props["aria-label"] && !props["aria-labelledby"]);
34
+ let { labelProps, groupProps, inputProps, incrementButtonProps, decrementButtonProps, descriptionProps, errorMessageProps, ...validation } = $81397a9303501bda$export$23f548e970bdf099({
35
+ ...$64fa3d84918910a7$export$ef03459518577ad4(props),
36
+ label,
37
+ validationBehavior
38
+ }, state, inputRef);
39
+ let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
40
+ ...props,
41
+ values: {
42
+ state,
43
+ isDisabled: props.isDisabled || false,
44
+ isInvalid: validation.isInvalid || false,
45
+ isRequired: props.isRequired || false
46
+ },
47
+ defaultClassName: "react-aria-NumberField"
48
+ });
49
+ let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
50
+ delete DOMProps.id;
51
+ return /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
52
+ values: [
53
+ [
54
+ $b91743d66a0ed188$export$6cc906c6cff9bec5,
55
+ state
56
+ ],
57
+ [
58
+ $a049562f99e7db0e$export$f9c6924e160136d1,
59
+ groupProps
60
+ ],
61
+ [
62
+ $3985021b0ad6602f$export$37fb8590cf2c088c,
63
+ {
64
+ ...inputProps,
65
+ ref: inputRef
66
+ }
67
+ ],
68
+ [
69
+ $01b77f81d0f07f68$export$75b6ee27786ba447,
70
+ {
71
+ ...labelProps,
72
+ ref: labelRef
73
+ }
74
+ ],
75
+ [
76
+ $d2b4bc8c273e7be6$export$24d547caef80ccd1,
77
+ {
78
+ slots: {
79
+ increment: incrementButtonProps,
80
+ decrement: decrementButtonProps
81
+ }
82
+ }
83
+ ],
84
+ [
85
+ $514c0188e459b4c0$export$9afb8bc826b033ea,
86
+ {
87
+ slots: {
88
+ description: descriptionProps,
89
+ errorMessage: errorMessageProps
90
+ }
91
+ }
92
+ ],
93
+ [
94
+ $ee014567cb39d3f0$export$ff05c3ac10437e03,
95
+ validation
96
+ ]
97
+ ]
98
+ }, /* @__PURE__ */ React__default.createElement("div", {
99
+ ...DOMProps,
100
+ ...renderProps,
101
+ ref,
102
+ slot: props.slot || void 0,
103
+ "data-disabled": props.isDisabled || void 0,
104
+ "data-required": props.isRequired || void 0,
105
+ "data-invalid": validation.isInvalid || void 0
106
+ }), props.name && /* @__PURE__ */ React__default.createElement("input", {
107
+ type: "hidden",
108
+ name: props.name,
109
+ value: isNaN(state.numberValue) ? "" : state.numberValue
110
+ }));
111
+ });
112
+ /**
113
+ * A number picker component.
114
+ *
115
+ * @component
116
+ * @param {Object} props - Component props.
117
+ * @param {number} props.value - The current value of the number picker.
118
+ * @param {Function} props.onChange - Function to run when the value changes.
119
+ * @param {number} [props.min=0] - The minimum value of the number picker.
120
+ * @param {number} [props.max] - The maximum value of the number picker.
121
+ * @param {number} [props.step=1] - The step value of the number picker.
122
+ * @param {string} [props.label] - The label of the number picker.
123
+ * @param {JSX.Element} [props.icon] - Icon to display within the number picker.
124
+ * @param {string} [props.subtitle] - The subtitle of the number picker.
125
+ * @param {string} [props.help] - The help text shown below the number picker.
126
+ * @param {boolean} [props.readOnly] - If `true`, the number picker is read-only.
127
+ * @param {boolean} [props.disabled] - If `true`, the number picker is disabled.
128
+ * @param {string} [props.placeholder] - Placeholder text to display in the number picker.
129
+ * @param {JSX.Element} [props.prefix] - Element to display to the left of the number picker.
130
+ * @param {JSX.Element} [props.suffix] - Element to display to the right of the number picker.
131
+ * @param {number} [props.fixedWidth] - If passed, sets the width of the input field to the provided number of characters. Useful if you have e.g. value from 1 to 1000, but you don't want the input field to change size when on lower values.
132
+ * @param {boolean} [props.inline] - If `true`, the number picker is displayed inline.
133
+ * @param {boolean} [props.noScrollToChange=false] - If `true`, the number picker does not change value when scrolling.
134
+ * @param {NumberPickerSize} [props.size='default'] - Determines the input field size.
135
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
136
+ *
137
+ * @returns {JSX.Element} The NumberPicker component.
138
+ *
139
+ * @typedef {'compact' | 'small' | 'default'} NumberPickerSize
140
+ *
141
+ * @example
142
+ * <NumberPicker
143
+ * value={value}
144
+ * onChange={setValue}
145
+ * />
146
+ *
147
+ * @preserve
148
+ */
149
+ const NumberPicker = ({
150
+ value,
151
+ onChange,
152
+ min = 0,
153
+ max,
154
+ step = 1,
155
+ label,
156
+ icon,
157
+ subtitle,
158
+ help,
159
+ readOnly,
160
+ disabled,
161
+ placeholder,
162
+ prefix,
163
+ fixedWidth = null,
164
+ suffix,
165
+ children,
166
+ inline,
167
+ noScrollToChange = false,
168
+ size = "default",
169
+ "aria-label": ariaLabel,
170
+ hidden,
171
+ ...props
172
+ }) => {
173
+ var _a, _b, _c, _d, _e;
174
+ const [isInputFocused, setIsInputFocused] = useState(false);
175
+ if (hidden) {
176
+ return null;
177
+ }
178
+ const sizes = {
179
+ compact: {
180
+ field: "es:min-h-5",
181
+ noPrefixPadding: "es:pl-1.5",
182
+ extraContentSeparator: "es:h-[1.875rem]"
183
+ },
184
+ small: {
185
+ field: "es:min-h-9",
186
+ noPrefixPadding: "es:pl-2",
187
+ extraContentSeparator: "es:h-[2.125rem]"
188
+ },
189
+ default: {
190
+ field: "es:min-h-10",
191
+ noPrefixPadding: "es:pl-2",
192
+ extraContentSeparator: "es:h-[2.375rem]"
193
+ }
194
+ };
195
+ return /* @__PURE__ */ jsx(
196
+ $b91743d66a0ed188$export$63c5fa0b2fdccd2e,
197
+ {
198
+ value,
199
+ onChange,
200
+ isDisabled: disabled,
201
+ isReadOnly: readOnly,
202
+ minValue: min,
203
+ maxValue: max,
204
+ step,
205
+ isWheelDisabled: noScrollToChange,
206
+ ...props,
207
+ children: /* @__PURE__ */ jsx(
208
+ BaseControl,
209
+ {
210
+ labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
211
+ icon,
212
+ label,
213
+ subtitle,
214
+ help,
215
+ inline,
216
+ className: "es:text-sm",
217
+ children: /* @__PURE__ */ jsxs(
218
+ $a049562f99e7db0e$export$eb2fcfdbd7ba97d4,
219
+ {
220
+ className: clsx(
221
+ "es:group es:flex es:w-fit es:items-center es:rounded-lg es:border es:border-secondary-300 es:pl-1 es:pr-0.5 es:shadow-xs es:transition",
222
+ "es:inset-ring es:inset-ring-secondary-100",
223
+ isInputFocused && "es:outline-hidden es:focus-visible:border-accent-500 es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
224
+ !prefix && (((_a = sizes == null ? void 0 : sizes[size]) == null ? void 0 : _a.noPrefixPadding) ?? sizes.default.noPrefixPadding),
225
+ ((_b = sizes == null ? void 0 : sizes[size]) == null ? void 0 : _b.field) ?? sizes.default.field,
226
+ "es:disabled:shadow-none es:disabled:border-secondary-200 es:disabled:bg-secondary-50 es:disabled:text-secondary-500 es:disabled:cursor-default es:readonly:bg-secondary-50"
227
+ ),
228
+ children: [
229
+ prefix && /* @__PURE__ */ jsx(
230
+ "span",
231
+ {
232
+ slot: "prefix",
233
+ className: "es:col-start-1 es:row-span-2 es:mr-0.5 es:select-none es:self-center es:text-sm es:text-secondary-400",
234
+ children: prefix
235
+ }
236
+ ),
237
+ /* @__PURE__ */ jsx(
238
+ $3985021b0ad6602f$export$f5b8910cec6cf069,
239
+ {
240
+ onFocus: () => setIsInputFocused(true),
241
+ onBlur: () => setIsInputFocused(false),
242
+ className: "es:col-start-2 es:row-span-2 es:border-none! es:bg-transparent es:px-0! es:py-1! es:text-sm es:tabular-nums es:shadow-none! es:outline-hidden! es:selection:bg-accent-500/20 es:selection:text-accent-950 es:focus:shadow-none! es:any-focus:outline-hidden",
243
+ placeholder,
244
+ style: {
245
+ width: fixedWidth ? `${fixedWidth}ch` : `calc(${min < 0 ? "0.75ch + " : ""}${(_d = (_c = max ?? 1e3) == null ? void 0 : _c.toString()) == null ? void 0 : _d.length} * 1ch)`
246
+ },
247
+ "aria-label": ariaLabel ?? __("Enter a number", "eightshift-ui-components")
248
+ }
249
+ ),
250
+ /* @__PURE__ */ jsxs("div", { className: clsx("es:opacity-0 es:group-hover:opacity-100 es:group-focus-visible:opacity-100 es:transition-opacity", disabled && "es:invisible"), children: [
251
+ /* @__PURE__ */ jsx(
252
+ Button,
253
+ {
254
+ type: "ghost",
255
+ className: "es:col-start-4 es:h-3 es:w-4 es:text-secondary-500! es:disabled:text-secondary-300! es:icon:size-[0.8rem]",
256
+ slot: "increment",
257
+ icon: icons.caretUpFill
258
+ }
259
+ ),
260
+ /* @__PURE__ */ jsx(
261
+ Button,
262
+ {
263
+ type: "ghost",
264
+ className: "es:col-start-4 es:h-3 es:w-4 es:text-secondary-500! es:disabled:text-secondary-300! es:icon:size-[0.8rem]",
265
+ slot: "decrement",
266
+ icon: icons.caretDownFill
267
+ }
268
+ )
269
+ ] }),
270
+ suffix && /* @__PURE__ */ jsx(
271
+ "span",
272
+ {
273
+ slot: "suffix",
274
+ className: "es:col-start-3 es:row-span-2 es:select-none es:self-center es:text-sm es:text-secondary-400 es:mr-0.5",
275
+ children: suffix
276
+ }
277
+ ),
278
+ children && /* @__PURE__ */ jsxs(Fragment, { children: [
279
+ /* @__PURE__ */ jsx("div", { className: clsx("es:w-px es:bg-secondary-300", ((_e = sizes == null ? void 0 : sizes[size]) == null ? void 0 : _e.extraContentSeparator) ?? sizes.default.extraContentSeparator) }),
280
+ /* @__PURE__ */ jsx("div", { className: "es:p-0.5 es:pr-0", children: Array.isArray(children) ? children.map((child) => cloneElement(child, { slot: null })) : cloneElement(children, { slot: null }) })
281
+ ] })
282
+ ]
283
+ }
284
+ )
285
+ }
286
+ )
287
+ }
288
+ );
289
+ };
290
+ export {
291
+ NumberPicker
292
+ };
@@ -0,0 +1,264 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from "react";
3
+ import { icons } from "../../icons/icons.js";
4
+ import { BaseControl } from "../base-control/base-control.js";
5
+ import { ButtonGroup } from "../button/button.js";
6
+ import { Menu, MenuSeparator, MenuItem } from "../menu/menu.js";
7
+ import { RadioButtonGroup, RadioButton } from "../radio/radio.js";
8
+ import { RichLabel } from "../rich-label/rich-label.js";
9
+ import { ToggleButton } from "../toggle-button/toggle-button.js";
10
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
11
+ /**
12
+ * A component that allows the user to select an option from a list of options.
13
+ *
14
+ * @component
15
+ * @param {Object} props - Component props.
16
+ * @param {JSX.Element} [props.icon] - Icon to display in the label.
17
+ * @param {string} props.label - Label to display.
18
+ * @param {string} [props.subtitle] - Subtitle to display below the label.
19
+ * @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to show to the right of the label.
20
+ * @param {string} [props.help] - Help text to show below the component.
21
+ * @param {boolean} [props.inline] - If `true`, the component is displayed inline - icon/label/subtitle are on the left, the passed content is on the right. **Note:** not compatible with `actions`.
22
+ * @param {string} props.value - The currently selected value.
23
+ * @param {Function} props.onChange - Function to run when the selected value changes.
24
+ * @param {{label: string, value: any, tooltip: string|JSX.Element, icon: JSX.Element|string, ariaLabel: string, subtitle:string|JSX.Element }[]} props.options - The list of options to choose from.
25
+ * @param {string} [props.disabled] - If `true`, the option select component is disabled.
26
+ * @param {boolean} [props.vertical] - If `true`, the options are displayed vertically. Not applicable to the `menu` type.
27
+ * @param {OptionSelectType} [props.type='toggleButton'] - The type of the option select component.
28
+ * @param {string} [props.className] - Classes to pass to the main element wrapper.
29
+ * @param {string} [props.itemClassName] - Classes to pass to each item.
30
+ * @param {Object} [props.wrapperProps] - Props to pass to the wrapper.
31
+ * @param {Object} [props.itemProps] - Props to pass to each item.
32
+ * @param {boolean} [props.noTriggerLabel] - Whether the trigger label should be hidden. Applies only to the `menu` type.
33
+ * @param {boolean} [props.noTriggerIcon] - Whether the trigger icon should be hidden. Applies only to the `menu` type.
34
+ * @param {string|boolean} [props.tooltip] - If provided, overrides the default tooltip text. If there is no label, the value will still be shown within the tooltip. Applies only to the `menu` type. If `true` is set and an `aria-label` is provided, the tooltip will show the same text as the `aria-label`.
35
+ * @param {boolean} [props.noItemLabel] - Whether the option label should be hidden.
36
+ * @param {boolean} [props.noItemIcon] - Whether the option icon should be hidden.
37
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
38
+ *
39
+ * @returns {JSX.Element} The OptionSelect component.
40
+ *
41
+ * @typedef {'toggleButtons' | 'toggleButtonsSplit' | 'radios' | 'radiosSegmented' | 'menu'} OptionSelectType
42
+ *
43
+ * @example
44
+ * <OptionSelect
45
+ * label='My component'
46
+ * icon={icons.myIcon}
47
+ * value={value}
48
+ * onChange={setValue}
49
+ * options={[
50
+ * { label: 'Option 1', value: 'option1' },
51
+ * { label: 'Option 2', value: 'option2' },
52
+ * ]}
53
+ * />
54
+ *
55
+ * @preserve
56
+ */
57
+ const OptionSelect = (props) => {
58
+ var _a;
59
+ const {
60
+ icon,
61
+ label,
62
+ subtitle,
63
+ actions,
64
+ help,
65
+ inline,
66
+ value,
67
+ onChange,
68
+ options,
69
+ disabled,
70
+ vertical,
71
+ type = "toggleButtons",
72
+ className,
73
+ itemClassName,
74
+ wrapperProps,
75
+ itemProps,
76
+ noTriggerLabel,
77
+ noTriggerIcon,
78
+ tooltip: rawTooltip,
79
+ noItemLabel,
80
+ noItemIcon,
81
+ children,
82
+ hidden,
83
+ "aria-label": ariaLabel,
84
+ ...rest
85
+ } = props;
86
+ if (hidden) {
87
+ return null;
88
+ }
89
+ let tooltip = rawTooltip;
90
+ if (rawTooltip === true && (ariaLabel == null ? void 0 : ariaLabel.length) > 0) {
91
+ tooltip = ariaLabel;
92
+ }
93
+ const currentItem = options == null ? void 0 : options.find(({ value: optionValue }) => optionValue === value);
94
+ const notSetLabel = /* @__PURE__ */ jsx("span", { className: "es:leading-3 es:opacity-50", children: __("Not set", "eightshift-ui-components") });
95
+ let radioDesign = "default";
96
+ if (type === "radiosSegmented") {
97
+ radioDesign = "segmented";
98
+ }
99
+ return /* @__PURE__ */ jsxs(
100
+ BaseControl,
101
+ {
102
+ icon,
103
+ label,
104
+ subtitle,
105
+ actions,
106
+ help,
107
+ inline,
108
+ className,
109
+ ...rest,
110
+ children: [
111
+ ["toggleButtons", "toggleButtonsSplit"].includes(type) && /* @__PURE__ */ jsx(
112
+ ButtonGroup,
113
+ {
114
+ vertical,
115
+ "aria-label": typeof label !== "undefined" ? null : ariaLabel,
116
+ type: type === "toggleButtonsSplit" ? "split" : "segmented",
117
+ ...wrapperProps,
118
+ children: options.map(
119
+ ({
120
+ label: optionLabel,
121
+ value: optionValue,
122
+ icon: optionIcon,
123
+ tooltip: optionTooltip,
124
+ ariaLabel: optionAriaLabel,
125
+ subtitle: optionSubtitle,
126
+ disabled: optionDisabled
127
+ }) => {
128
+ var _a2;
129
+ return /* @__PURE__ */ jsxs(
130
+ ToggleButton,
131
+ {
132
+ selected: optionValue === value,
133
+ onChange: () => onChange(optionValue),
134
+ disabled: optionDisabled || disabled,
135
+ className: itemClassName,
136
+ icon: !noItemIcon && (typeof optionIcon === "string" ? (_a2 = icons) == null ? void 0 : _a2[optionIcon] : optionIcon),
137
+ tooltip: optionTooltip ?? optionAriaLabel ?? (noItemLabel && optionLabel),
138
+ "aria-label": optionAriaLabel ?? optionLabel ?? optionTooltip,
139
+ ...itemProps,
140
+ children: [
141
+ !noItemLabel && !optionSubtitle && optionLabel,
142
+ !noItemLabel && optionSubtitle && /* @__PURE__ */ jsx(
143
+ RichLabel,
144
+ {
145
+ label: optionLabel,
146
+ subtitle: optionSubtitle,
147
+ noColor: true
148
+ }
149
+ )
150
+ ]
151
+ },
152
+ optionValue
153
+ );
154
+ }
155
+ )
156
+ }
157
+ ),
158
+ (type === "radios" || type === "radiosSegmented") && /* @__PURE__ */ jsx(
159
+ RadioButtonGroup,
160
+ {
161
+ orientation: vertical ? "vertical" : "horizontal",
162
+ onChange: (v) => onChange(v),
163
+ design: radioDesign,
164
+ "aria-label": typeof label !== "undefined" ? null : ariaLabel,
165
+ value,
166
+ ...wrapperProps,
167
+ children: options.map(({ label: optionLabel, value: optionValue, icon: optionIcon, ariaLabel: optionAriaLabel, subtitle: optionSubtitle, disabled: optionDisabled }) => {
168
+ var _a2;
169
+ return /* @__PURE__ */ jsx(
170
+ RadioButton,
171
+ {
172
+ value: optionValue,
173
+ disabled: optionDisabled || disabled,
174
+ className: itemClassName,
175
+ subtitle: !noItemLabel && optionSubtitle,
176
+ icon: !noItemIcon && (typeof optionIcon === "string" ? (_a2 = icons) == null ? void 0 : _a2[optionIcon] : optionIcon),
177
+ "aria-label": optionAriaLabel ?? optionLabel,
178
+ label: !noItemLabel && optionLabel,
179
+ ...itemProps
180
+ },
181
+ optionValue
182
+ );
183
+ })
184
+ }
185
+ ),
186
+ type === "menu" && /* @__PURE__ */ jsxs(
187
+ Menu,
188
+ {
189
+ triggerLabel: noTriggerLabel ? null : (currentItem == null ? void 0 : currentItem.label) ?? notSetLabel,
190
+ triggerIcon: !noTriggerIcon && // eslint-disable-next-line no-nested-ternary
191
+ (currentItem ? typeof (currentItem == null ? void 0 : currentItem.icon) === "string" ? (_a = icons) == null ? void 0 : _a[currentItem == null ? void 0 : currentItem.icon] : currentItem == null ? void 0 : currentItem.icon : (noTriggerLabel || noTriggerIcon) && notSetLabel),
192
+ tooltip: noTriggerLabel ? /* @__PURE__ */ jsx(
193
+ RichLabel,
194
+ {
195
+ label: tooltip ? tooltip : (currentItem == null ? void 0 : currentItem.tooltip) ?? (currentItem == null ? void 0 : currentItem.label),
196
+ subtitle: tooltip && ((currentItem == null ? void 0 : currentItem.tooltip) ?? (currentItem == null ? void 0 : currentItem.label)),
197
+ noColor: true
198
+ }
199
+ ) : tooltip,
200
+ triggerProps: {
201
+ ...wrapperProps == null ? void 0 : wrapperProps.triggerProps,
202
+ "aria-label": typeof label !== "undefined" ? null : ariaLabel ?? label ?? tooltip
203
+ },
204
+ keepOpen: true,
205
+ "aria-label": ariaLabel ?? label ?? tooltip ?? __("Menu", "eightshift-ui-components"),
206
+ ...wrapperProps,
207
+ children: [
208
+ options.map(
209
+ ({
210
+ label: optionLabel,
211
+ value: optionValue,
212
+ icon: optionIcon,
213
+ endIcon: optionEndIcon,
214
+ ariaLabel: optionAriaLabel,
215
+ subtitle: optionSubtitle,
216
+ separator: optionHasSeparator,
217
+ sectionTitle: optionSectionTitle,
218
+ shortcut: optionShortcut,
219
+ disabled: optionDisabled
220
+ }) => {
221
+ var _a2, _b;
222
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
223
+ (optionHasSeparator === true || optionHasSeparator === "above") && /* @__PURE__ */ jsx(MenuSeparator, {}),
224
+ optionSectionTitle && /* @__PURE__ */ jsx(MenuItem, { disabled: true, children: optionSectionTitle }),
225
+ /* @__PURE__ */ jsxs(
226
+ MenuItem,
227
+ {
228
+ selected: value === optionValue,
229
+ disabled: optionDisabled || disabled,
230
+ className: itemClassName,
231
+ icon: !noItemIcon && (typeof optionIcon === "string" ? (_a2 = icons) == null ? void 0 : _a2[optionIcon] : optionIcon),
232
+ endIcon: !noItemIcon && (typeof optionEndIcon === "string" ? (_b = icons) == null ? void 0 : _b[optionEndIcon] : optionEndIcon),
233
+ "aria-label": optionAriaLabel ?? optionLabel,
234
+ onClick: () => onChange(optionValue),
235
+ shortcut: optionShortcut,
236
+ ...itemProps,
237
+ children: [
238
+ !noItemLabel && !optionSubtitle && optionLabel,
239
+ !noItemLabel && optionSubtitle && /* @__PURE__ */ jsx(
240
+ RichLabel,
241
+ {
242
+ label: optionLabel,
243
+ subtitle: optionSubtitle,
244
+ noColor: true
245
+ }
246
+ )
247
+ ]
248
+ }
249
+ ),
250
+ optionHasSeparator === "below" && /* @__PURE__ */ jsx(MenuSeparator, {})
251
+ ] }, optionValue);
252
+ }
253
+ ),
254
+ children
255
+ ]
256
+ }
257
+ )
258
+ ]
259
+ }
260
+ );
261
+ };
262
+ export {
263
+ OptionSelect
264
+ };