@eightshift/ui-components 0.0.2 → 0.0.4
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.
- package/dist/components/breakpoint-preview/breakpoint-preview.js +1 -1
- package/dist/components/index.js +117 -0
- package/dist/components/matrix-align/matrix-align.js +1 -1
- package/dist/components/repeater/repeater.js +0 -1
- package/dist/components/responsive/responsive-legacy.js +1 -1
- package/dist/components/responsive/responsive.js +1 -1
- package/dist/components/responsive-preview/responsive-preview.js +1 -1
- package/dist/components/tabs/tabs.js +27 -4
- package/dist/icons/icons.js +8 -0
- package/dist/icons/index.js +12 -0
- package/dist/index.js +1 -17
- package/dist/utilities/debounce-throttle.js +123 -0
- package/dist/utilities/es-dash.js +376 -0
- package/dist/utilities/index.js +18 -1
- package/dist/utilities/text-helpers.js +68 -81
- package/package.json +14 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment as Fragment$1 } from "react";
|
|
3
3
|
import { c as clsx } from "../../lite-pbIeT7tm.js";
|
|
4
|
-
import { upperFirst } from "../../utilities/
|
|
4
|
+
import { upperFirst } from "../../utilities/es-dash.js";
|
|
5
5
|
/**
|
|
6
6
|
* Component that renders a preview of the breakpoints to help users visualize the options they set.
|
|
7
7
|
*
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { AnimatedVisibility } from "./animated-visibility/animated-visibility.js";
|
|
2
|
+
import { BaseControl } from "./base-control/base-control.js";
|
|
3
|
+
import { BreakpointPreview } from "./breakpoint-preview/breakpoint-preview.js";
|
|
4
|
+
import { B, a } from "../button-idVI4jmd.js";
|
|
5
|
+
import { Checkbox } from "./checkbox/checkbox.js";
|
|
6
|
+
import { ComponentToggle } from "./component-toggle/component-toggle.js";
|
|
7
|
+
import { ContainerPanel } from "./container-panel/container-panel.js";
|
|
8
|
+
import { ColorSwatch } from "./color-pickers/color-swatch.js";
|
|
9
|
+
import { ColorPicker } from "./color-pickers/color-picker.js";
|
|
10
|
+
import { ColumnConfigSlider, ColumnConfigSliderOutput } from "./slider/column-config-slider.js";
|
|
11
|
+
import { DraggableList } from "./draggable-list/draggable-list.js";
|
|
12
|
+
import { DraggableListItem } from "./draggable-list/draggable-list-item.js";
|
|
13
|
+
import { Expandable } from "./expandable/expandable.js";
|
|
14
|
+
import { FilePlaceholder } from "./placeholders/file-placeholder.js";
|
|
15
|
+
import { GradientEditor } from "./color-pickers/gradient-editor.js";
|
|
16
|
+
import { HStack } from "./layout/hstack.js";
|
|
17
|
+
import { RichLabel } from "./rich-label/rich-label.js";
|
|
18
|
+
import { InputField } from "./input-field/input-field.js";
|
|
19
|
+
import { ImagePlaceholder } from "./placeholders/image-placeholder.js";
|
|
20
|
+
import { LinkInput } from "./link-input/link-input.js";
|
|
21
|
+
import { ListBox } from "./list-box/list-box.js";
|
|
22
|
+
import { MatrixAlign } from "./matrix-align/matrix-align.js";
|
|
23
|
+
import { MediaPlaceholder } from "./placeholders/media-placeholder.js";
|
|
24
|
+
import { Menu, MenuItem, MenuSection, MenuSeparator, SubMenuItem } from "./menu/menu.js";
|
|
25
|
+
import { Notice } from "./notice/notice.js";
|
|
26
|
+
import { NumberPicker } from "./number-picker/number-picker.js";
|
|
27
|
+
import { P, T } from "../popover-o2Q28Ljn.js";
|
|
28
|
+
import { RadioButton, RadioButtonGroup } from "./radio/radio.js";
|
|
29
|
+
import { Repeater } from "./repeater/repeater.js";
|
|
30
|
+
import { RepeaterItem } from "./repeater/repeater-item.js";
|
|
31
|
+
import { Responsive } from "./responsive/responsive.js";
|
|
32
|
+
import { ResponsiveLegacy } from "./responsive/responsive-legacy.js";
|
|
33
|
+
import { ResponsivePreview } from "./responsive-preview/responsive-preview.js";
|
|
34
|
+
import { AsyncMultiSelect } from "./select/async-multi-select.js";
|
|
35
|
+
import { AsyncSelect } from "./select/async-single-select.js";
|
|
36
|
+
import { MultiSelect } from "./select/multi-select.js";
|
|
37
|
+
import { RSClearIndicator, RSDropdownIndicator, RSMultiValue, RSMultiValueContainer, RSMultiValueLabel, RSMultiValueRemove, RSOption, RSSingleValue } from "./select/react-select-component-wrappers.js";
|
|
38
|
+
import { OptionSelect } from "./option-select/option-select.js";
|
|
39
|
+
import { Select } from "./select/single-select.js";
|
|
40
|
+
import { Slider } from "./slider/slider.js";
|
|
41
|
+
import { SolidColorPicker } from "./color-pickers/solid-color-picker.js";
|
|
42
|
+
import { Spacer } from "./spacer/spacer.js";
|
|
43
|
+
import { Tab, TabList, TabPanel, Tabs } from "./tabs/tabs.js";
|
|
44
|
+
import { Toggle } from "./toggle/toggle.js";
|
|
45
|
+
import { Switch } from "./toggle/switch.js";
|
|
46
|
+
import { ToggleButton } from "./toggle-button/toggle-button.js";
|
|
47
|
+
import { D, T as T2 } from "../tooltip-T6H9uF-Z.js";
|
|
48
|
+
import { VStack } from "./layout/vstack.js";
|
|
49
|
+
export {
|
|
50
|
+
AnimatedVisibility,
|
|
51
|
+
AsyncMultiSelect,
|
|
52
|
+
AsyncSelect,
|
|
53
|
+
BaseControl,
|
|
54
|
+
BreakpointPreview,
|
|
55
|
+
B as Button,
|
|
56
|
+
a as ButtonGroup,
|
|
57
|
+
Checkbox,
|
|
58
|
+
ColorPicker,
|
|
59
|
+
ColorSwatch,
|
|
60
|
+
ColumnConfigSlider,
|
|
61
|
+
ColumnConfigSliderOutput,
|
|
62
|
+
ComponentToggle,
|
|
63
|
+
ContainerPanel,
|
|
64
|
+
D as DecorativeTooltip,
|
|
65
|
+
DraggableList,
|
|
66
|
+
DraggableListItem,
|
|
67
|
+
Expandable,
|
|
68
|
+
FilePlaceholder,
|
|
69
|
+
GradientEditor,
|
|
70
|
+
HStack,
|
|
71
|
+
ImagePlaceholder,
|
|
72
|
+
InputField,
|
|
73
|
+
LinkInput,
|
|
74
|
+
ListBox,
|
|
75
|
+
MatrixAlign,
|
|
76
|
+
MediaPlaceholder,
|
|
77
|
+
Menu,
|
|
78
|
+
MenuItem,
|
|
79
|
+
MenuSection,
|
|
80
|
+
MenuSeparator,
|
|
81
|
+
MultiSelect,
|
|
82
|
+
Notice,
|
|
83
|
+
NumberPicker,
|
|
84
|
+
OptionSelect,
|
|
85
|
+
P as Popover,
|
|
86
|
+
RSClearIndicator,
|
|
87
|
+
RSDropdownIndicator,
|
|
88
|
+
RSMultiValue,
|
|
89
|
+
RSMultiValueContainer,
|
|
90
|
+
RSMultiValueLabel,
|
|
91
|
+
RSMultiValueRemove,
|
|
92
|
+
RSOption,
|
|
93
|
+
RSSingleValue,
|
|
94
|
+
RadioButton,
|
|
95
|
+
RadioButtonGroup,
|
|
96
|
+
Repeater,
|
|
97
|
+
RepeaterItem,
|
|
98
|
+
Responsive,
|
|
99
|
+
ResponsiveLegacy,
|
|
100
|
+
ResponsivePreview,
|
|
101
|
+
RichLabel,
|
|
102
|
+
Select,
|
|
103
|
+
Slider,
|
|
104
|
+
SolidColorPicker,
|
|
105
|
+
Spacer,
|
|
106
|
+
SubMenuItem,
|
|
107
|
+
Switch,
|
|
108
|
+
Tab,
|
|
109
|
+
TabList,
|
|
110
|
+
TabPanel,
|
|
111
|
+
Tabs,
|
|
112
|
+
Toggle,
|
|
113
|
+
ToggleButton,
|
|
114
|
+
T2 as Tooltip,
|
|
115
|
+
T as TriggeredPopover,
|
|
116
|
+
VStack
|
|
117
|
+
};
|
|
@@ -4,7 +4,7 @@ import { _ as __ } from "../../default-i18n-Bk1GxDHz.js";
|
|
|
4
4
|
import { P as Popover } from "../../popover-o2Q28Ljn.js";
|
|
5
5
|
import { B as Button } from "../../button-idVI4jmd.js";
|
|
6
6
|
import { icons } from "../../icons/icons.js";
|
|
7
|
-
import { upperFirst, camelCase } from "../../utilities/
|
|
7
|
+
import { upperFirst, camelCase } from "../../utilities/es-dash.js";
|
|
8
8
|
import { c as clsx } from "../../lite-pbIeT7tm.js";
|
|
9
9
|
import { T as Tooltip } from "../../tooltip-T6H9uF-Z.js";
|
|
10
10
|
import { BaseControl } from "../base-control/base-control.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/
|
|
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/
|
|
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/
|
|
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")
|
|
@@ -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__ */
|
|
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,
|
|
@@ -589,7 +593,26 @@ const Tab = (props) => {
|
|
|
589
593
|
className
|
|
590
594
|
);
|
|
591
595
|
},
|
|
592
|
-
children
|
|
596
|
+
children: [
|
|
597
|
+
!label && children,
|
|
598
|
+
!label && !icon && children,
|
|
599
|
+
!label && icon && children && /* @__PURE__ */ jsx(
|
|
600
|
+
RichLabel,
|
|
601
|
+
{
|
|
602
|
+
icon,
|
|
603
|
+
label: children
|
|
604
|
+
}
|
|
605
|
+
),
|
|
606
|
+
!icon && !subtitle && label,
|
|
607
|
+
(icon || subtitle) && label && /* @__PURE__ */ jsx(
|
|
608
|
+
RichLabel,
|
|
609
|
+
{
|
|
610
|
+
icon,
|
|
611
|
+
label,
|
|
612
|
+
subtitle
|
|
613
|
+
}
|
|
614
|
+
)
|
|
615
|
+
]
|
|
593
616
|
}
|
|
594
617
|
);
|
|
595
618
|
};
|
package/dist/icons/icons.js
CHANGED
|
@@ -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
|
@@ -47,18 +47,11 @@ import { ToggleButton } from "./components/toggle-button/toggle-button.js";
|
|
|
47
47
|
import { D, T as T2 } from "./tooltip-T6H9uF-Z.js";
|
|
48
48
|
import { VStack } from "./components/layout/vstack.js";
|
|
49
49
|
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
50
|
export {
|
|
57
51
|
AnimatedVisibility,
|
|
58
52
|
AsyncMultiSelect,
|
|
59
53
|
AsyncSelect,
|
|
60
54
|
BaseControl,
|
|
61
|
-
BlockIcon,
|
|
62
55
|
BreakpointPreview,
|
|
63
56
|
B as Button,
|
|
64
57
|
a as ButtonGroup,
|
|
@@ -74,12 +67,10 @@ export {
|
|
|
74
67
|
DraggableListItem,
|
|
75
68
|
Expandable,
|
|
76
69
|
FilePlaceholder,
|
|
77
|
-
GenericColorSwatch,
|
|
78
70
|
GradientEditor,
|
|
79
71
|
HStack,
|
|
80
72
|
ImagePlaceholder,
|
|
81
73
|
InputField,
|
|
82
|
-
JsxSvg,
|
|
83
74
|
LinkInput,
|
|
84
75
|
ListBox,
|
|
85
76
|
MatrixAlign,
|
|
@@ -124,12 +115,5 @@ export {
|
|
|
124
115
|
T2 as Tooltip,
|
|
125
116
|
T as TriggeredPopover,
|
|
126
117
|
VStack,
|
|
127
|
-
|
|
128
|
-
blockIcons,
|
|
129
|
-
camelCase,
|
|
130
|
-
getColumnConfigOutputText,
|
|
131
|
-
icons,
|
|
132
|
-
illustrations,
|
|
133
|
-
lowerFirst,
|
|
134
|
-
upperFirst
|
|
118
|
+
getColumnConfigOutputText
|
|
135
119
|
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
var stringKebabCase = kebabCase$1;
|
|
2
|
+
var wordSeparators = /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/;
|
|
3
|
+
var capital_plus_lower = /[A-ZÀ-Ý\u00C0-\u00D6\u00D9-\u00DD][a-zà-ÿ]/g;
|
|
4
|
+
var capitals = /[A-ZÀ-Ý\u00C0-\u00D6\u00D9-\u00DD]+/g;
|
|
5
|
+
function kebabCase$1(str) {
|
|
6
|
+
str = str.replace(capital_plus_lower, function(match) {
|
|
7
|
+
return " " + (match[0].toLowerCase() || match[0]) + match[1];
|
|
8
|
+
});
|
|
9
|
+
str = str.replace(capitals, function(match) {
|
|
10
|
+
return " " + match.toLowerCase();
|
|
11
|
+
});
|
|
12
|
+
return str.trim().split(wordSeparators).join("-").replace(/^-/, "").replace(/-\s*$/, "");
|
|
13
|
+
}
|
|
14
|
+
var stringCamelCase = camelCase$1;
|
|
15
|
+
var wordSeparatorsRegEx = /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/;
|
|
16
|
+
var basicCamelRegEx = /^[a-z\u00E0-\u00FCA-Z\u00C0-\u00DC][\d|a-z\u00E0-\u00FCA-Z\u00C0-\u00DC]*$/;
|
|
17
|
+
var fourOrMoreConsecutiveCapsRegEx = /([A-Z\u00C0-\u00DC]{4,})/g;
|
|
18
|
+
var allCapsRegEx = /^[A-Z\u00C0-\u00DC]+$/;
|
|
19
|
+
function camelCase$1(str) {
|
|
20
|
+
var words = str.split(wordSeparatorsRegEx);
|
|
21
|
+
var len = words.length;
|
|
22
|
+
var mappedWords = new Array(len);
|
|
23
|
+
for (var i = 0; i < len; i++) {
|
|
24
|
+
var word = words[i];
|
|
25
|
+
if (word === "") {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
var isCamelCase = basicCamelRegEx.test(word) && !allCapsRegEx.test(word);
|
|
29
|
+
if (isCamelCase) {
|
|
30
|
+
word = word.replace(fourOrMoreConsecutiveCapsRegEx, function(match, p1, offset) {
|
|
31
|
+
return deCap(match, word.length - offset - match.length == 0);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
var firstLetter = word[0];
|
|
35
|
+
firstLetter = i > 0 ? firstLetter.toUpperCase() : firstLetter.toLowerCase();
|
|
36
|
+
mappedWords[i] = firstLetter + (!isCamelCase ? word.slice(1).toLowerCase() : word.slice(1));
|
|
37
|
+
}
|
|
38
|
+
return mappedWords.join("");
|
|
39
|
+
}
|
|
40
|
+
function deCap(match, endOfWord) {
|
|
41
|
+
var arr = match.split("");
|
|
42
|
+
var first = arr.shift().toUpperCase();
|
|
43
|
+
var last = endOfWord ? arr.pop().toLowerCase() : arr.pop();
|
|
44
|
+
return first + arr.join("").toLowerCase() + last;
|
|
45
|
+
}
|
|
46
|
+
var objectIsEmpty = isEmpty$1;
|
|
47
|
+
function isEmpty$1(obj) {
|
|
48
|
+
if (obj == null) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(obj)) {
|
|
52
|
+
return !obj.length;
|
|
53
|
+
}
|
|
54
|
+
if (typeof obj == "string") {
|
|
55
|
+
return !obj.length;
|
|
56
|
+
}
|
|
57
|
+
var type = {}.toString.call(obj);
|
|
58
|
+
if (type == "[object Object]") {
|
|
59
|
+
return !Object.keys(obj).length && !Object.getOwnPropertySymbols(obj).length;
|
|
60
|
+
}
|
|
61
|
+
if (type == "[object Map]" || type == "[object Set]") {
|
|
62
|
+
return !obj.size;
|
|
63
|
+
}
|
|
64
|
+
return Object(obj) !== obj || !Object.keys(obj).length;
|
|
65
|
+
}
|
|
66
|
+
var objectHas = has$1;
|
|
67
|
+
function has$1(obj, propsArg) {
|
|
68
|
+
if (!obj) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
var props, prop;
|
|
72
|
+
if (Array.isArray(propsArg)) {
|
|
73
|
+
props = propsArg.slice(0);
|
|
74
|
+
}
|
|
75
|
+
if (typeof propsArg == "string") {
|
|
76
|
+
props = propsArg.split(".");
|
|
77
|
+
}
|
|
78
|
+
if (typeof propsArg == "symbol") {
|
|
79
|
+
props = [propsArg];
|
|
80
|
+
}
|
|
81
|
+
if (!Array.isArray(props)) {
|
|
82
|
+
throw new Error("props arg must be an array, a string or a symbol");
|
|
83
|
+
}
|
|
84
|
+
while (props.length) {
|
|
85
|
+
prop = props.shift();
|
|
86
|
+
if (obj == null) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (props.length === 0) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
obj = obj[prop];
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns a camelCase-formatted string.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} input - String to convert.
|
|
103
|
+
*
|
|
104
|
+
* @access public
|
|
105
|
+
*
|
|
106
|
+
* @return {string} *camelCase*-formatted string.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* camelCase('New super Test-title') // => 'newSuperTestTitle'
|
|
110
|
+
* camelCase(null) // => ''
|
|
111
|
+
*
|
|
112
|
+
* @preserve
|
|
113
|
+
*/
|
|
114
|
+
const camelCase = (input) => lowerFirst(stringCamelCase(input ?? ""));
|
|
115
|
+
/**
|
|
116
|
+
* Returns a PascalCase-formatted string.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} input - String to convert.
|
|
119
|
+
*
|
|
120
|
+
* @access public
|
|
121
|
+
*
|
|
122
|
+
* @return {string} *PascalCase*-formatted string.
|
|
123
|
+
*
|
|
124
|
+
* Usage:
|
|
125
|
+
* ```js
|
|
126
|
+
* pascalCase('New super Test-title') // => 'NewSuperTestTitle'
|
|
127
|
+
* pascalCase(null) // => ''
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @preserve
|
|
131
|
+
*/
|
|
132
|
+
const pascalCase = (input) => upperFirst(stringCamelCase(input ?? ""));
|
|
133
|
+
/**
|
|
134
|
+
* Returns a snake_case-formatted string.
|
|
135
|
+
*
|
|
136
|
+
* @param {string} input - String to convert.
|
|
137
|
+
*
|
|
138
|
+
* @access public
|
|
139
|
+
*
|
|
140
|
+
* @return {string} *snake_case*-formatted string.
|
|
141
|
+
*
|
|
142
|
+
* Usage:
|
|
143
|
+
* ```js
|
|
144
|
+
* snakeCase('New super Test-title') // => 'new_super_test_title'
|
|
145
|
+
* snakeCase(null) // => ''
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @preserve
|
|
149
|
+
*/
|
|
150
|
+
const snakeCase = (input) => kebabCase(input ?? "").replaceAll("-", "_");
|
|
151
|
+
const kebabCase = (input) => stringKebabCase(input ?? "");
|
|
152
|
+
/**
|
|
153
|
+
* Checks if value is an empty object or collection.
|
|
154
|
+
*
|
|
155
|
+
* @param {*} input - Value to check.
|
|
156
|
+
*
|
|
157
|
+
* @returns true if the object is empty, false otherwise.
|
|
158
|
+
*
|
|
159
|
+
* Usage:
|
|
160
|
+
* ```js
|
|
161
|
+
* isEmpty({}) // => true
|
|
162
|
+
* isEmpty([]) // => true
|
|
163
|
+
* isEmpty('') // => true
|
|
164
|
+
* isEmpty({ a: 1 }) // => false
|
|
165
|
+
* isEmpty([1, 2, 3]) // => false
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @preserve
|
|
169
|
+
*/
|
|
170
|
+
const isEmpty = (input) => objectIsEmpty(input);
|
|
171
|
+
/**
|
|
172
|
+
* Returns the string with its first character converted to uppercase.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} input - String to convert.
|
|
175
|
+
*
|
|
176
|
+
* @return {string} string with its first character converted to uppercase.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* upperFirst('new super Test-title') // => 'New super Test-title'
|
|
180
|
+
*
|
|
181
|
+
* @preserve
|
|
182
|
+
*/
|
|
183
|
+
const upperFirst = (input) => {
|
|
184
|
+
if (typeof input === "undefined") {
|
|
185
|
+
return "";
|
|
186
|
+
}
|
|
187
|
+
if (input === true) {
|
|
188
|
+
return "True";
|
|
189
|
+
} else if (input === false) {
|
|
190
|
+
return "False";
|
|
191
|
+
}
|
|
192
|
+
if (input.length < 2) {
|
|
193
|
+
return input.toUpperCase();
|
|
194
|
+
}
|
|
195
|
+
return input.charAt(0).toUpperCase() + input.slice(1);
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Returns the string with its first character converted to lowercase.
|
|
199
|
+
*
|
|
200
|
+
* @param {string} input - String to convert.
|
|
201
|
+
*
|
|
202
|
+
* @return {string} string with its first character converted to lowercase.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* lowerFirst('New super Test-title') // => 'new super Test-title'
|
|
206
|
+
*
|
|
207
|
+
* @preserve
|
|
208
|
+
*/
|
|
209
|
+
const lowerFirst = (input) => {
|
|
210
|
+
if (typeof input === "undefined") {
|
|
211
|
+
return "";
|
|
212
|
+
}
|
|
213
|
+
if (input === true) {
|
|
214
|
+
return "true";
|
|
215
|
+
} else if (input === false) {
|
|
216
|
+
return "false";
|
|
217
|
+
}
|
|
218
|
+
if ((input == null ? void 0 : input.length) < 2) {
|
|
219
|
+
return input.toLowerCase();
|
|
220
|
+
}
|
|
221
|
+
return input.charAt(0).toLowerCase() + input.slice(1);
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Checks if `key` is a direct property of `object`. Key may be a path of a value separated by `.`
|
|
225
|
+
*
|
|
226
|
+
* @param {object} obj - Object to check.
|
|
227
|
+
* @param {string} key - Key to check.
|
|
228
|
+
*
|
|
229
|
+
* @return {boolean} true if key is a direct property, false otherwise.
|
|
230
|
+
*
|
|
231
|
+
* Usage:
|
|
232
|
+
* ```js
|
|
233
|
+
* has({ a: 1 }, 'a') // => true
|
|
234
|
+
* has({ a: 1 }, 'b') // => false
|
|
235
|
+
* has({ a: { b: 2 } }, 'a.b') // => true
|
|
236
|
+
* has({ a: { b: 3 } }, 'a.c') // => false
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @preserve
|
|
240
|
+
*/
|
|
241
|
+
const has = (obj, key) => objectHas(obj, key);
|
|
242
|
+
/*
|
|
243
|
+
* Checks if value is a plain object, that is, an object created by the Object constructor or one with a `[[Prototype]]` of `null`.
|
|
244
|
+
*
|
|
245
|
+
* @param {*} value - Value to check.
|
|
246
|
+
* @returns {boolean} true if value is a plain object, false otherwise.
|
|
247
|
+
*
|
|
248
|
+
* Usage:
|
|
249
|
+
* ```js
|
|
250
|
+
* isPlainObject({ a: 2 }) // => true
|
|
251
|
+
* isPlainObject('Lorem') // => false
|
|
252
|
+
* isPlainObject([]) // => false
|
|
253
|
+
* isPlainObject(new Boolean()) // => false
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* @preserve
|
|
257
|
+
*/
|
|
258
|
+
const isPlainObject = (value) => {
|
|
259
|
+
if (typeof value !== "object" || value === null) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
const proto = Object.getPrototypeOf(value);
|
|
266
|
+
if (proto === null) {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
270
|
+
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Checks if value is the language type of `Object`. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(’’))
|
|
274
|
+
*
|
|
275
|
+
* @param {*} input - Value to check.
|
|
276
|
+
*
|
|
277
|
+
* @returns {boolean} true if value is an array, false otherwise.
|
|
278
|
+
*
|
|
279
|
+
* Usage:
|
|
280
|
+
* ```js
|
|
281
|
+
* isObject({}) // => true
|
|
282
|
+
* isObject([1, 2, 3]) // => true
|
|
283
|
+
* isObject(() => {}) // => true
|
|
284
|
+
* isObject(null) // => false
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* @preserve
|
|
288
|
+
*/
|
|
289
|
+
const isObject = (input) => input instanceof Object;
|
|
290
|
+
/**
|
|
291
|
+
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
292
|
+
*
|
|
293
|
+
* **Note**: works for simple types, arrays, and objects. Might not work for all the types the lodash version supports.
|
|
294
|
+
*
|
|
295
|
+
* @param {*} first First value to compare.
|
|
296
|
+
* @param {*} second Second value to compare.
|
|
297
|
+
*
|
|
298
|
+
* @returns true if the values are equivalent, false otherwise.
|
|
299
|
+
*
|
|
300
|
+
* Usage:
|
|
301
|
+
* ```js
|
|
302
|
+
* isEqual({ a: 1 }, { a: 1 }) // => true
|
|
303
|
+
* isEqual({ a: 1 }, { a: 2 }) // => false
|
|
304
|
+
* isEqual({ a: 1 }, 'b') // => false
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @preserve
|
|
308
|
+
*/
|
|
309
|
+
const isEqual = (first, second) => {
|
|
310
|
+
if (first === second) {
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
if ((first === void 0 || second === void 0 || first === null || second === null) && (first || second)) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
const firstType = first == null ? void 0 : first.constructor.name;
|
|
317
|
+
const secondType = second == null ? void 0 : second.constructor.name;
|
|
318
|
+
if (firstType !== secondType) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
if (firstType === "Array") {
|
|
322
|
+
if (first.length !== second.length) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
let equal = true;
|
|
326
|
+
for (let i = 0; i < first.length; i++) {
|
|
327
|
+
if (!isEqual(first[i], second[i])) {
|
|
328
|
+
equal = false;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return equal;
|
|
333
|
+
}
|
|
334
|
+
if (firstType === "Object") {
|
|
335
|
+
let equal = true;
|
|
336
|
+
const fKeys = Object.keys(first);
|
|
337
|
+
const sKeys = Object.keys(second);
|
|
338
|
+
if (fKeys.length !== sKeys.length) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
for (let i = 0; i < fKeys.length; i++) {
|
|
342
|
+
if (first[fKeys[i]] && second[fKeys[i]]) {
|
|
343
|
+
if (first[fKeys[i]] === second[fKeys[i]]) {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (first[fKeys[i]] && (first[fKeys[i]].constructor.name === "Array" || first[fKeys[i]].constructor.name === "Object")) {
|
|
347
|
+
equal = isEqual(first[fKeys[i]], second[fKeys[i]]);
|
|
348
|
+
if (!equal) {
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
} else if (first[fKeys[i]] !== second[fKeys[i]]) {
|
|
352
|
+
equal = false;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
} else if (first[fKeys[i]] && !second[fKeys[i]] || !first[fKeys[i]] && second[fKeys[i]]) {
|
|
356
|
+
equal = false;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return equal;
|
|
361
|
+
}
|
|
362
|
+
return first === second;
|
|
363
|
+
};
|
|
364
|
+
export {
|
|
365
|
+
camelCase,
|
|
366
|
+
has,
|
|
367
|
+
isEmpty,
|
|
368
|
+
isEqual,
|
|
369
|
+
isObject,
|
|
370
|
+
isPlainObject,
|
|
371
|
+
kebabCase,
|
|
372
|
+
lowerFirst,
|
|
373
|
+
pascalCase,
|
|
374
|
+
snakeCase,
|
|
375
|
+
upperFirst
|
|
376
|
+
};
|
package/dist/utilities/index.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { arrayMoveMultiple } from "./array-helpers.js";
|
|
2
|
-
import { camelCase, lowerFirst, upperFirst } from "./
|
|
2
|
+
import { camelCase, has, isEmpty, isEqual, isObject, isPlainObject, kebabCase, lowerFirst, pascalCase, snakeCase, upperFirst } from "./es-dash.js";
|
|
3
|
+
import { truncate, truncateMiddle, unescapeHTML } from "./text-helpers.js";
|
|
4
|
+
import { debounce, throttle } from "./debounce-throttle.js";
|
|
5
|
+
import { c } from "../lite-pbIeT7tm.js";
|
|
3
6
|
export {
|
|
4
7
|
arrayMoveMultiple,
|
|
5
8
|
camelCase,
|
|
9
|
+
c as clsx,
|
|
10
|
+
debounce,
|
|
11
|
+
has,
|
|
12
|
+
isEmpty,
|
|
13
|
+
isEqual,
|
|
14
|
+
isObject,
|
|
15
|
+
isPlainObject,
|
|
16
|
+
kebabCase,
|
|
6
17
|
lowerFirst,
|
|
18
|
+
pascalCase,
|
|
19
|
+
snakeCase,
|
|
20
|
+
throttle,
|
|
21
|
+
truncate,
|
|
22
|
+
truncateMiddle,
|
|
23
|
+
unescapeHTML,
|
|
7
24
|
upperFirst
|
|
8
25
|
};
|
|
@@ -1,105 +1,92 @@
|
|
|
1
|
-
var stringCamelCase = camelCase$1;
|
|
2
|
-
var wordSeparatorsRegEx = /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/;
|
|
3
|
-
var basicCamelRegEx = /^[a-z\u00E0-\u00FCA-Z\u00C0-\u00DC][\d|a-z\u00E0-\u00FCA-Z\u00C0-\u00DC]*$/;
|
|
4
|
-
var fourOrMoreConsecutiveCapsRegEx = /([A-Z\u00C0-\u00DC]{4,})/g;
|
|
5
|
-
var allCapsRegEx = /^[A-Z\u00C0-\u00DC]+$/;
|
|
6
|
-
function camelCase$1(str) {
|
|
7
|
-
var words = str.split(wordSeparatorsRegEx);
|
|
8
|
-
var len = words.length;
|
|
9
|
-
var mappedWords = new Array(len);
|
|
10
|
-
for (var i = 0; i < len; i++) {
|
|
11
|
-
var word = words[i];
|
|
12
|
-
if (word === "") {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
var isCamelCase = basicCamelRegEx.test(word) && !allCapsRegEx.test(word);
|
|
16
|
-
if (isCamelCase) {
|
|
17
|
-
word = word.replace(fourOrMoreConsecutiveCapsRegEx, function(match, p1, offset) {
|
|
18
|
-
return deCap(match, word.length - offset - match.length == 0);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
var firstLetter = word[0];
|
|
22
|
-
firstLetter = i > 0 ? firstLetter.toUpperCase() : firstLetter.toLowerCase();
|
|
23
|
-
mappedWords[i] = firstLetter + (!isCamelCase ? word.slice(1).toLowerCase() : word.slice(1));
|
|
24
|
-
}
|
|
25
|
-
return mappedWords.join("");
|
|
26
|
-
}
|
|
27
|
-
function deCap(match, endOfWord) {
|
|
28
|
-
var arr = match.split("");
|
|
29
|
-
var first = arr.shift().toUpperCase();
|
|
30
|
-
var last = endOfWord ? arr.pop().toLowerCase() : arr.pop();
|
|
31
|
-
return first + arr.join("").toLowerCase() + last;
|
|
32
|
-
}
|
|
33
1
|
/**
|
|
34
|
-
*
|
|
2
|
+
* Slices the string in the middle and inputs the provided separator so that the string is maxLength characters long.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} input - String to slice.
|
|
5
|
+
* @param {number} maxLength - Maximum allowed string length.
|
|
6
|
+
* @param {string} [separator='...'] - Separator to insert.
|
|
7
|
+
*
|
|
8
|
+
* @access public
|
|
35
9
|
*
|
|
36
|
-
* @
|
|
10
|
+
* @returns {string|Error} Truncated string or error if separator length exceeds maxLength.
|
|
37
11
|
*
|
|
38
|
-
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* ```js
|
|
14
|
+
* truncateMiddle('https://eightshift.com/contact/', 22);
|
|
15
|
+
* ```
|
|
39
16
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
17
|
+
* Output:
|
|
18
|
+
* ```js
|
|
19
|
+
* "https://ei.../contact/"
|
|
42
20
|
*
|
|
43
21
|
* @preserve
|
|
44
22
|
*/
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
return
|
|
23
|
+
const truncateMiddle = (input, maxLength, separator = "...") => {
|
|
24
|
+
if ((input == null ? void 0 : input.length) <= maxLength) {
|
|
25
|
+
return input;
|
|
48
26
|
}
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
} else if (input === false) {
|
|
52
|
-
return "False";
|
|
27
|
+
if (separator.length + 1 > maxLength) {
|
|
28
|
+
throw new Error("Separator length exceeds the passed maximum length, string wouldn't be visible.");
|
|
53
29
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
30
|
+
const maxStringLength = maxLength - separator.length;
|
|
31
|
+
const leftPartLength = Math.ceil(maxStringLength / 2);
|
|
32
|
+
const rightPartLength = Math.floor(maxStringLength / 2);
|
|
33
|
+
const leftPart = input.slice(0, leftPartLength).trim();
|
|
34
|
+
const rightPart = rightPartLength > 0 ? input.slice(-1 * rightPartLength).trim() : "";
|
|
35
|
+
return `${leftPart}${separator}${rightPart}`;
|
|
58
36
|
};
|
|
59
37
|
/**
|
|
60
|
-
|
|
38
|
+
* Un-escapes HTML entities.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} input - Input string.
|
|
41
|
+
*
|
|
42
|
+
* @access public
|
|
43
|
+
*
|
|
44
|
+
* @returns {string} String with HTML entities unescaped.
|
|
45
|
+
*
|
|
46
|
+
* Usage:
|
|
47
|
+
* ```js
|
|
48
|
+
* unescapeHTML('Test&Up');
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* Output:
|
|
52
|
+
* ```js
|
|
53
|
+
* Test&Up
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @preserve
|
|
57
|
+
*/
|
|
58
|
+
const unescapeHTML = (input = "") => new DOMParser().parseFromString(input, "text/html").documentElement.textContent;
|
|
59
|
+
/**
|
|
60
|
+
* Limits the string to the maximum length and adds the provided separator in case the string is longer.
|
|
61
61
|
*
|
|
62
|
-
* @param {string} input
|
|
62
|
+
* @param {string} input - String to slice.
|
|
63
|
+
* @param {number} maxLength - Maximum allowed string length.
|
|
64
|
+
* @param {string} [separator='...'] - Separator to insert.
|
|
63
65
|
*
|
|
64
66
|
* @access public
|
|
65
67
|
*
|
|
66
|
-
* @
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* camelCase('New super Test-title') // => 'newSuperTestTitle'
|
|
70
|
-
* camelCase(null) // => ''
|
|
68
|
+
* @returns {string|Error} Truncated string or error if separator length exceeds maxLength.
|
|
71
69
|
*
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* Returns the string with its first character converted to lowercase.
|
|
77
|
-
*
|
|
78
|
-
* @param {string} input - String to convert.
|
|
79
|
-
*
|
|
80
|
-
* @return {string} string with its first character converted to lowercase.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* lowerFirst('New super Test-title') // => 'new super Test-title'
|
|
70
|
+
* Usage:
|
|
71
|
+
* ```js
|
|
72
|
+
* truncate('Hello this is a string', 13); // => "Hello this..."
|
|
73
|
+
* ```
|
|
84
74
|
*
|
|
85
75
|
* @preserve
|
|
86
76
|
*/
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
if (input === true) {
|
|
92
|
-
return "true";
|
|
93
|
-
} else if (input === false) {
|
|
94
|
-
return "false";
|
|
77
|
+
const truncate = (input, maxLength, separator = "...") => {
|
|
78
|
+
if ((input == null ? void 0 : input.length) <= maxLength) {
|
|
79
|
+
return input;
|
|
95
80
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
81
|
+
if (separator.length + 1 > maxLength) {
|
|
82
|
+
throw new Error("Separator length exceeds the passed maximum length, string wouldn't be visible.");
|
|
98
83
|
}
|
|
99
|
-
|
|
84
|
+
const maxStringLength = maxLength - separator.length;
|
|
85
|
+
const leftPart = input.slice(0, maxStringLength).trim();
|
|
86
|
+
return `${leftPart}${separator}`;
|
|
100
87
|
};
|
|
101
88
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
truncate,
|
|
90
|
+
truncateMiddle,
|
|
91
|
+
unescapeHTML
|
|
105
92
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eightshift/ui-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -19,9 +19,14 @@
|
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"require": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./icons": "./dist/icons/index.js",
|
|
23
|
+
"./utilities": "./dist/utilities/index.js",
|
|
22
24
|
"./dist/assets/style.css": "./dist/assets/style.css",
|
|
23
25
|
"./dist/assets/fonts.css": "./dist/assets/fonts.css",
|
|
24
|
-
"./dist/assets/wp.css": "./dist/assets/wp.css"
|
|
26
|
+
"./dist/assets/wp.css": "./dist/assets/wp.css",
|
|
27
|
+
"./styles": "./dist/assets/style.css",
|
|
28
|
+
"./fonts": "./dist/assets/fonts.css",
|
|
29
|
+
"./wp-overrides": "./dist/assets/wp.css"
|
|
25
30
|
},
|
|
26
31
|
"scripts": {
|
|
27
32
|
"dev": "vite",
|
|
@@ -62,7 +67,6 @@
|
|
|
62
67
|
"eslint-plugin-react-refresh": "^0.4.7",
|
|
63
68
|
"framer-motion": "^11.2.10",
|
|
64
69
|
"glob": "^10.4.1",
|
|
65
|
-
"just-camel-case": "^6.2.0",
|
|
66
70
|
"postcss": "^8.4.38",
|
|
67
71
|
"prettier": "^3.3.0",
|
|
68
72
|
"prettier-plugin-tailwindcss": "^0.6.1",
|
|
@@ -73,6 +77,12 @@
|
|
|
73
77
|
"tailwindcss-animate": "^1.0.7",
|
|
74
78
|
"tailwindcss-react-aria-components": "^1.1.3",
|
|
75
79
|
"vite": "^5.2.12",
|
|
76
|
-
"vite-plugin-lib-inject-css": "^2.1.1"
|
|
80
|
+
"vite-plugin-lib-inject-css": "^2.1.1",
|
|
81
|
+
"just-camel-case": "^6.2.0",
|
|
82
|
+
"just-debounce-it": "^3.2.0",
|
|
83
|
+
"just-has": "^2.3.0",
|
|
84
|
+
"just-is-empty": "^3.4.1",
|
|
85
|
+
"just-kebab-case": "^4.2.0",
|
|
86
|
+
"just-throttle": "^4.2.0"
|
|
77
87
|
}
|
|
78
88
|
}
|