@eightshift/ui-components 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as clsx } from "../../lite-pbIeT7tm.js";
3
+ import { RichLabel } from "../rich-label/rich-label.js";
4
+ /**
5
+ * Component that provides a container panel for options, with an optional title.
6
+ * Best used within the Gutenberg sidebar, instead of the default `PanelBody` component.
7
+ * Ensures that the content is spaced nicely.
8
+ *
9
+ * @component
10
+ * @param {Object} props - Component props.
11
+ * @param {string} [props.className] - Classes to pass to the container.
12
+ * @param {string} [props.title] - Title to display on the top of the panel.
13
+ * @param {JSX.Element} [props.icon] - Icon to display on the top of the panel.
14
+ * @param {string} [props.subtitle] - Subtitle to display on the top of the panel.
15
+ * @param {string} [props.help] - Help text to show below the panel.
16
+ *
17
+ * @returns {JSX.Element} The OptionsPanel component.
18
+ *
19
+ * @example
20
+ * <OptionsPanel title='Paragraph'>
21
+ * ...
22
+ * </OptionsPanel>
23
+ *
24
+ * @preserve
25
+ */
26
+ const OptionsPanel = (props) => {
27
+ const { children, className, title, icon, subtitle, help } = props;
28
+ return /* @__PURE__ */ jsxs("div", { className: clsx("es-uic-max-w-96", className), children: [
29
+ title && /* @__PURE__ */ jsx(
30
+ RichLabel,
31
+ {
32
+ icon,
33
+ label: title,
34
+ subtitle,
35
+ className: "es-uic-mb-1 es-uic-text-[0.875rem] es-uic-tracking-[-0.01em] !es-uic-text-gray-500"
36
+ }
37
+ ),
38
+ /* @__PURE__ */ jsx("div", { className: "es-uic-bg-white es-uic-divide-y es-uic-rounded-lg es-uic-divide-gray-200 es-uic-shadow es-uic-border es-uic-border-gray-200", children }),
39
+ help && /* @__PURE__ */ jsx("span", { className: "text-sm es-uic-mt-1.5 es-uic-block es-uic-text-gray-400", children: help })
40
+ ] });
41
+ };
42
+ const OptionsPanelSection = ({ children, className }) => {
43
+ return /* @__PURE__ */ jsx(
44
+ "div",
45
+ {
46
+ className: clsx(
47
+ "es-uic-space-y-2.5 first:es-uic-rounded-t-lg last:rounded-b-lg only:es-uic-rounded-lg es-uic-px-3 es-uic-py-4 first:es-uic-pt-3.5 last:es-uic-pb-3.5",
48
+ className
49
+ ),
50
+ children
51
+ }
52
+ );
53
+ };
54
+ export {
55
+ OptionsPanel,
56
+ OptionsPanelSection
57
+ };
@@ -4,7 +4,7 @@ import { D as DecorativeTooltip } from "../../tooltip-T6H9uF-Z.js";
4
4
  import { c as clsx } from "../../lite-pbIeT7tm.js";
5
5
  import { _ as __, s as sprintf } from "../../default-i18n-Bk1GxDHz.js";
6
6
  import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
7
- import { upperFirst } from "../../utilities/text-helpers.js";
7
+ import { upperFirst } from "../../utilities/es-dash.js";
8
8
  import { icons } from "../../icons/icons.js";
9
9
  import { B as Button } from "../../button-idVI4jmd.js";
10
10
  import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
@@ -4,7 +4,7 @@ import { D as DecorativeTooltip } from "../../tooltip-T6H9uF-Z.js";
4
4
  import { c as clsx } from "../../lite-pbIeT7tm.js";
5
5
  import { _ as __, s as sprintf } from "../../default-i18n-Bk1GxDHz.js";
6
6
  import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
7
- import { upperFirst } from "../../utilities/text-helpers.js";
7
+ import { upperFirst } from "../../utilities/es-dash.js";
8
8
  import { icons } from "../../icons/icons.js";
9
9
  import { Menu, MenuItem, MenuSeparator, SubMenuItem } from "../menu/menu.js";
10
10
  import { ResponsivePreview } from "../responsive-preview/responsive-preview.js";
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
3
- import { upperFirst } from "../../utilities/text-helpers.js";
3
+ import { upperFirst } from "../../utilities/es-dash.js";
4
4
  import { BreakpointPreview } from "../breakpoint-preview/breakpoint-preview.js";
5
5
  import { icons } from "../../icons/icons.js";
6
6
  import { RichLabel } from "../rich-label/rich-label.js";
@@ -1,4 +1,4 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { f as $880e95eb8b93ba9a$export$ecf600387e221c37, c as $ae20dd8cbca75726$export$d6daf82dcd84e87c, g as $7135fc7d473fd974$export$7cd71aa5ddd6dc4e, h as $7135fc7d473fd974$export$8c25dea96356a8b6, i as $7135fc7d473fd974$export$813b5978dd974d8, j as $7135fc7d473fd974$export$e7c29ae2353b16ea } from "../../SelectionManager-sedvcM-1.js";
3
3
  import { d as $3ef42575df84b30b$export$9d1611c77c2fe928, e as $bdb11010cef70236$export$f680877a34711e37, b as $64fa3d84918910a7$export$86427a43e3e48ebb, a as $64fa3d84918910a7$export$29f1550f4b0d4415, p as $64fa3d84918910a7$export$8dc98ba7eadeaa56, c as $64fa3d84918910a7$export$4d86445c2cf5e3, j as $64fa3d84918910a7$export$2881499e37b75b9a, $ as $64fa3d84918910a7$export$fabf2dc03a41866e, l as $df56164dff5785e2$export$4338b53315abf666 } from "../../utils-DIBzm1e4.js";
4
4
  import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-DG2RfOUr.js";
@@ -13,6 +13,7 @@ import { $ as $83013635b024ae3d$export$eac1895992b9f3d6 } from "../../useHasTabb
13
13
  import { _ as __, s as sprintf } from "../../default-i18n-Bk1GxDHz.js";
14
14
  import { c as clsx } from "../../lite-pbIeT7tm.js";
15
15
  import { Notice } from "../notice/notice.js";
16
+ import { RichLabel } from "../rich-label/rich-label.js";
16
17
  const $99b62ae3ff97ec45$export$c5f62239608282b6 = /* @__PURE__ */ new WeakMap();
17
18
  function $99b62ae3ff97ec45$export$567fc7097e064344(state, key, role) {
18
19
  if (typeof key === "string")
@@ -540,9 +541,9 @@ const TabList = (props) => {
540
541
  {
541
542
  "aria-label": ariaLabel ?? __("tabs", "eightshift-ui-components"),
542
543
  className: ({ orientation }) => clsx(
543
- "es-uic-flex es-uic-gap-1",
544
- orientation === "vertical" && "es-uic-h-full es-uic-flex-col es-uic-pr-1.5",
545
- orientation === "horizontal" && "es-uic-w-full es-uic-items-end es-uic-border-b es-uic-border-b-gray-300",
544
+ "es-uic-flex",
545
+ orientation === "vertical" && "es-uic-gap-px es-uic-h-full es-uic-flex-col es-uic-pr-1.5",
546
+ orientation === "horizontal" && "es-uic-gap-1 es-uic-w-full es-uic-items-end es-uic-border-b es-uic-border-b-gray-300",
546
547
  className
547
548
  ),
548
549
  ...other,
@@ -558,6 +559,9 @@ TabList.displayName = "TabList";
558
559
  * @param {Object} props - Component props.
559
560
  * @param {boolean} [props.disabled] - Whether the tab is disabled.
560
561
  * @param {string} [props.className] - Classes to pass to the tab.
562
+ * @param {JSX.Element} [props.icon] - Icon to show on the tab.
563
+ * @param {string} [props.label] - Tab label. **Note**: overrides inner items!
564
+ * @param {string} [props.subtitle] - Tab subtitle. **Note**: overrides inner items!
561
565
  *
562
566
  * @returns {JSX.Element} The Tab component.
563
567
  *
@@ -566,8 +570,8 @@ TabList.displayName = "TabList";
566
570
  * @preserve
567
571
  */
568
572
  const Tab = (props) => {
569
- const { children, disabled, isParentVertical, className, ...other } = props;
570
- return /* @__PURE__ */ jsx(
573
+ const { children, disabled, isParentVertical, className, icon, label, subtitle, ...other } = props;
574
+ return /* @__PURE__ */ jsxs(
571
575
  $5e8ad37a45e1c704$export$3e41faf802a29e71,
572
576
  {
573
577
  ...other,
@@ -585,11 +589,21 @@ const Tab = (props) => {
585
589
  !isSelected && !isDisabled && isParentVertical && "after:es-uic-scale-y-75",
586
590
  !isSelected && !isDisabled && !isParentVertical && "after:es-uic-scale-x-75",
587
591
  isDisabled && "es-uic-text-gray-300 after:es-uic-hidden",
588
- isParentVertical && "es-uic-pl-3 after:es-uic-inset-y-0 after:es-uic-left-px after:es-uic-right-auto after:es-uic-my-auto after:es-uic-h-7 after:es-uic-w-[0.1875rem]",
592
+ isParentVertical && "es-uic-min-h-9 es-uic-pl-3 after:es-uic-inset-y-0 after:es-uic-left-px after:es-uic-right-auto after:es-uic-my-auto after:es-uic-h-7 after:es-uic-w-[0.1875rem]",
589
593
  className
590
594
  );
591
595
  },
592
- children
596
+ children: [
597
+ (icon || subtitle) && /* @__PURE__ */ jsx(
598
+ RichLabel,
599
+ {
600
+ icon,
601
+ label: label ?? children,
602
+ subtitle
603
+ }
604
+ ),
605
+ !(icon || subtitle) && (label ?? children)
606
+ ]
593
607
  }
594
608
  );
595
609
  };
@@ -3197,6 +3197,14 @@ const icons = {
3197
3197
  slider: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: "20", height: "20", fill: "none", children: [
3198
3198
  /* @__PURE__ */ jsx("path", { d: "M1 10h5m13 0h-9", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", fill: "none" }),
3199
3199
  /* @__PURE__ */ jsx("rect", { x: "6.5", y: "7.5", width: "3", height: "5", rx: "1", fill: "currentColor", fillOpacity: "0.12", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round" })
3200
+ ] }),
3201
+ header: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: "20", height: "20", fill: "none", children: [
3202
+ /* @__PURE__ */ jsx("path", { d: "M19 17V4.5A1.5 1.5 0 0 0 17.5 3h-15A1.5 1.5 0 0 0 1 4.5V17", stroke: "currentColor", strokeLinecap: "round", fill: "none" }),
3203
+ /* @__PURE__ */ jsx("path", { d: "M2 4.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-.5.5h-15a.5.5 0 0 1-.5-.5v-3Z", fill: "currentColor", fillOpacity: "0.5" })
3204
+ ] }),
3205
+ footer: /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", width: "20", height: "20", fill: "none", children: [
3206
+ /* @__PURE__ */ jsx("path", { d: "M1 3v12.5A1.5 1.5 0 0 0 2.5 17h15a1.5 1.5 0 0 0 1.5-1.5V3", stroke: "currentColor", strokeLinecap: "round", fill: "none" }),
3207
+ /* @__PURE__ */ jsx("path", { d: "M2 10.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-.5.5h-15a.5.5 0 0 1-.5-.5v-5Z", fill: "currentColor", fillOpacity: "0.5" })
3200
3208
  ] })
3201
3209
  };
3202
3210
  const illustrations = {
@@ -0,0 +1,12 @@
1
+ import { blockIcons, icons, illustrations } from "./icons.js";
2
+ import { BlockIcon } from "./block-icon.js";
3
+ import { GenericColorSwatch } from "./generic-color-swatch.js";
4
+ import { JsxSvg } from "./jsx-svg.js";
5
+ export {
6
+ BlockIcon,
7
+ GenericColorSwatch,
8
+ JsxSvg,
9
+ blockIcons,
10
+ icons,
11
+ illustrations
12
+ };
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ import { AsyncSelect } from "./components/select/async-single-select.js";
36
36
  import { MultiSelect } from "./components/select/multi-select.js";
37
37
  import { RSClearIndicator, RSDropdownIndicator, RSMultiValue, RSMultiValueContainer, RSMultiValueLabel, RSMultiValueRemove, RSOption, RSSingleValue } from "./components/select/react-select-component-wrappers.js";
38
38
  import { OptionSelect } from "./components/option-select/option-select.js";
39
+ import { OptionsPanel, OptionsPanelSection } from "./components/options-panel/options-panel.js";
39
40
  import { Select } from "./components/select/single-select.js";
40
41
  import { Slider } from "./components/slider/slider.js";
41
42
  import { SolidColorPicker } from "./components/color-pickers/solid-color-picker.js";
@@ -47,18 +48,11 @@ import { ToggleButton } from "./components/toggle-button/toggle-button.js";
47
48
  import { D, T as T2 } from "./tooltip-T6H9uF-Z.js";
48
49
  import { VStack } from "./components/layout/vstack.js";
49
50
  import { getColumnConfigOutputText } from "./components/slider/utils.js";
50
- import { blockIcons, icons, illustrations } from "./icons/icons.js";
51
- import { BlockIcon } from "./icons/block-icon.js";
52
- import { GenericColorSwatch } from "./icons/generic-color-swatch.js";
53
- import { JsxSvg } from "./icons/jsx-svg.js";
54
- import { arrayMoveMultiple } from "./utilities/array-helpers.js";
55
- import { camelCase, lowerFirst, upperFirst } from "./utilities/text-helpers.js";
56
51
  export {
57
52
  AnimatedVisibility,
58
53
  AsyncMultiSelect,
59
54
  AsyncSelect,
60
55
  BaseControl,
61
- BlockIcon,
62
56
  BreakpointPreview,
63
57
  B as Button,
64
58
  a as ButtonGroup,
@@ -74,12 +68,10 @@ export {
74
68
  DraggableListItem,
75
69
  Expandable,
76
70
  FilePlaceholder,
77
- GenericColorSwatch,
78
71
  GradientEditor,
79
72
  HStack,
80
73
  ImagePlaceholder,
81
74
  InputField,
82
- JsxSvg,
83
75
  LinkInput,
84
76
  ListBox,
85
77
  MatrixAlign,
@@ -92,6 +84,8 @@ export {
92
84
  Notice,
93
85
  NumberPicker,
94
86
  OptionSelect,
87
+ OptionsPanel,
88
+ OptionsPanelSection,
95
89
  P as Popover,
96
90
  RSClearIndicator,
97
91
  RSDropdownIndicator,
@@ -124,12 +118,5 @@ export {
124
118
  T2 as Tooltip,
125
119
  T as TriggeredPopover,
126
120
  VStack,
127
- arrayMoveMultiple,
128
- blockIcons,
129
- camelCase,
130
- getColumnConfigOutputText,
131
- icons,
132
- illustrations,
133
- lowerFirst,
134
- upperFirst
121
+ getColumnConfigOutputText
135
122
  };
@@ -0,0 +1,123 @@
1
+ var functionDebounce = debounce$1;
2
+ function debounce$1(fn, wait, callFirst) {
3
+ var timeout = null;
4
+ var debouncedFn = null;
5
+ var clear = function() {
6
+ if (timeout) {
7
+ clearTimeout(timeout);
8
+ debouncedFn = null;
9
+ timeout = null;
10
+ }
11
+ };
12
+ var flush = function() {
13
+ var call = debouncedFn;
14
+ clear();
15
+ if (call) {
16
+ call();
17
+ }
18
+ };
19
+ var debounceWrapper = function() {
20
+ if (!wait) {
21
+ return fn.apply(this, arguments);
22
+ }
23
+ var context = this;
24
+ var args = arguments;
25
+ var callNow = callFirst && !timeout;
26
+ clear();
27
+ debouncedFn = function() {
28
+ fn.apply(context, args);
29
+ };
30
+ timeout = setTimeout(function() {
31
+ timeout = null;
32
+ if (!callNow) {
33
+ var call = debouncedFn;
34
+ debouncedFn = null;
35
+ return call();
36
+ }
37
+ }, wait);
38
+ if (callNow) {
39
+ return debouncedFn();
40
+ }
41
+ };
42
+ debounceWrapper.cancel = clear;
43
+ debounceWrapper.flush = flush;
44
+ return debounceWrapper;
45
+ }
46
+ var functionThrottle = throttle$1;
47
+ function throttle$1(fn, interval, options) {
48
+ var timeoutId = null;
49
+ var throttledFn = null;
50
+ var leading = options && options.leading;
51
+ var trailing = options && options.trailing;
52
+ if (leading == null) {
53
+ leading = true;
54
+ }
55
+ if (trailing == null) {
56
+ trailing = !leading;
57
+ }
58
+ if (leading == true) {
59
+ trailing = false;
60
+ }
61
+ var cancel = function() {
62
+ if (timeoutId) {
63
+ clearTimeout(timeoutId);
64
+ timeoutId = null;
65
+ }
66
+ };
67
+ var flush = function() {
68
+ var call = throttledFn;
69
+ cancel();
70
+ if (call) {
71
+ call();
72
+ }
73
+ };
74
+ var throttleWrapper = function() {
75
+ var callNow = leading && !timeoutId;
76
+ var context = this;
77
+ var args = arguments;
78
+ throttledFn = function() {
79
+ return fn.apply(context, args);
80
+ };
81
+ if (!timeoutId) {
82
+ timeoutId = setTimeout(function() {
83
+ timeoutId = null;
84
+ if (trailing) {
85
+ return throttledFn();
86
+ }
87
+ }, interval);
88
+ }
89
+ if (callNow) {
90
+ callNow = false;
91
+ return throttledFn();
92
+ }
93
+ };
94
+ throttleWrapper.cancel = cancel;
95
+ throttleWrapper.flush = flush;
96
+ return throttleWrapper;
97
+ }
98
+ /**
99
+ * Debounces the provided function.
100
+ * For more information, check [this blog post](https://davidwalsh.name/javascript-debounce-function).
101
+ *
102
+ * @param {function} func - Callback to apply.
103
+ * @param {number} wait - Number of milliseconds for the delay of the callback function. Default is 200ms.
104
+ *
105
+ * @access public
106
+ *
107
+ * @return {function} Debounced callback.
108
+ *
109
+ * Usage:
110
+ * ```js
111
+ * debounce(() => {
112
+ * // callback function.
113
+ * }, 250);
114
+ * ```
115
+ *
116
+ * @preserve
117
+ */
118
+ const debounce = (func, wait = 250) => functionDebounce(func, wait);
119
+ const throttle = (func, wait = 250, after = false) => functionThrottle(func, wait, { leading: !after, trailing: after });
120
+ export {
121
+ debounce,
122
+ throttle
123
+ };