@caspeco/casper-ui-library 4.0.1 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/box/box.d.ts +3 -3
- package/dist/components/box/box.d.ts.map +1 -1
- package/dist/components/button/button.d.ts +3 -2
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.d.ts +1 -1
- package/dist/components/combobox/combobox-button.d.ts +1 -1
- package/dist/components/combobox/combobox-button.d.ts.map +1 -1
- package/dist/components/combobox/combobox-button.js +90 -73
- package/dist/components/combobox/combobox-item.d.ts +2 -1
- package/dist/components/combobox/combobox-item.d.ts.map +1 -1
- package/dist/components/combobox/combobox-item.js +10 -10
- package/dist/components/combobox/combobox.d.ts +1 -1
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +90 -88
- package/dist/components/combobox/types.d.ts +2 -0
- package/dist/components/combobox/types.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +1 -1
- package/dist/components/date-picker/date-range-picker.d.ts +1 -1
- package/dist/components/date-picker/date-week-picker.d.ts +1 -1
- package/dist/components/divider/divider.d.ts +1 -1
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/form-control/form-control.d.ts +1 -1
- package/dist/components/form-control/form-error-message.d.ts +1 -1
- package/dist/components/form-control/form-helper-text.d.ts +1 -1
- package/dist/components/form-control/form-label.d.ts +1 -1
- package/dist/components/grid/grid-item.d.ts +1 -1
- package/dist/components/grid/grid.d.ts +1 -1
- package/dist/components/heading/heading.d.ts +1 -1
- package/dist/components/icon-button/icon-button.d.ts +1 -1
- package/dist/components/image/image.d.ts +1 -1
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/link/link.d.ts +1 -1
- package/dist/components/list/list.d.ts +1 -1
- package/dist/components/message/message.d.ts +1 -1
- package/dist/components/modal/modal-body.d.ts +1 -1
- package/dist/components/modal/modal-close-button.d.ts +1 -1
- package/dist/components/modal/modal-footer.d.ts +1 -1
- package/dist/components/modal/modal-header.d.ts +1 -1
- package/dist/components/navigation-list/navigation-list-item.d.ts +2 -2
- package/dist/components/navigation-list/navigation-list.d.ts +1 -1
- package/dist/components/radio/radio-addon.d.ts +1 -1
- package/dist/components/radio/radio-card.d.ts +1 -1
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio-group/radio-group.d.ts +1 -1
- package/dist/components/segmented-control/segmented-control.d.ts +1 -1
- package/dist/components/skeleton/skeleton-text.d.ts +1 -1
- package/dist/components/skeleton/skeleton.d.ts +1 -1
- package/dist/components/stack/stack.d.ts +3 -3
- package/dist/components/stack/stack.d.ts.map +1 -1
- package/dist/components/stepper/stepper.d.ts +1 -1
- package/dist/components/tabs/tab-list.d.ts +1 -1
- package/dist/components/tabs/tab-panel.d.ts +1 -1
- package/dist/components/tabs/tab-panels.d.ts +1 -1
- package/dist/components/tabs/tab.d.ts +1 -1
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/toast/toast.d.ts +1 -1
- package/dist/components/toggle-button/toggle-button.d.ts +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/theme/theme-provider.d.ts +1 -1
- package/dist/theme/theme-style-props.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ThemeStyleProps } from '../../theme/index.js';
|
|
2
|
-
import { BoxProps as ChakraBoxProps } from '@chakra-ui/react';
|
|
2
|
+
import { BoxProps as ChakraBoxProps, ComponentWithAs } from '@chakra-ui/react';
|
|
3
3
|
export type BoxProps = ThemeStyleProps & Pick<ChakraBoxProps, "children" | "as">;
|
|
4
4
|
/**
|
|
5
|
-
* @see Docs https://
|
|
5
|
+
* @see Docs https://caspeco.github.io/casper-ui-library/components/box
|
|
6
6
|
*/
|
|
7
|
-
export declare const Box:
|
|
7
|
+
export declare const Box: ComponentWithAs<"div", BoxProps>;
|
|
8
8
|
//# sourceMappingURL=box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../lib/components/box/box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../lib/components/box/box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAEN,KAAK,QAAQ,IAAI,cAAc,EAC/B,KAAK,eAAe,EAEpB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC;AAEjF;;GAEG;AAGH,eAAO,MAAM,GAAG,EAMV,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ComponentWithAs } from '@chakra-ui/react';
|
|
1
2
|
import { ButtonProps } from './types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Button component is used to trigger an action or event,
|
|
4
5
|
* such as submitting a form, opening a Dialog, canceling an action, or performing a delete operation.
|
|
5
6
|
*
|
|
6
|
-
* @see Docs https://
|
|
7
|
+
* @see Docs https://caspeco.github.io/casper-ui-library/components/button
|
|
7
8
|
* @see WAI-ARIA https://www.w3.org/WAI/ARIA/apg/patterns/button
|
|
8
9
|
*/
|
|
9
|
-
export declare const Button:
|
|
10
|
+
export declare const Button: ComponentWithAs<"button", ButtonProps>;
|
|
10
11
|
//# sourceMappingURL=button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../lib/components/button/button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../lib/components/button/button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAG5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;GAMG;AAGH,eAAO,MAAM,MAAM,EAqCb,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { CheckboxProps } from './types.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Used in forms when a user needs to select multiple values from several options.
|
|
5
5
|
*
|
|
6
|
-
* @see Docs https://
|
|
6
|
+
* @see Docs https://caspeco.github.io/casper-ui-library/components/checkbox
|
|
7
7
|
* @see WAI-ARIA https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/
|
|
8
8
|
*/
|
|
9
9
|
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -3,7 +3,7 @@ import { CheckboxGroupProps } from './types.js';
|
|
|
3
3
|
* Used for multiple checkboxes which are bound in one group,
|
|
4
4
|
* and it indicates whether one or more options are selected.
|
|
5
5
|
*
|
|
6
|
-
* @see Docs https://
|
|
6
|
+
* @see Docs https://caspeco.github.io/casper-ui-library/components/checkbox-group
|
|
7
7
|
*/
|
|
8
8
|
export declare function CheckboxGroup({ children, ...props }: CheckboxGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
//# sourceMappingURL=checkbox-group.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ComboboxInnerProps } from './types.js';
|
|
2
|
-
export declare function ComboboxButton({ id, asPlainText, inputValue, selectedItems, displayItems, toggleItem, highlightState, openState, parentStrings, size, variant, label, placeHolderText, isDisabled, isReadOnly, isInvalid, collapsed, setInputValue, onSearch, isSingleSelect, }: ComboboxInnerProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function ComboboxButton({ id, asPlainText, inputValue, selectedItems, displayItems, toggleItem, highlightState, openState, parentStrings, size, variant, label, placeHolderText, isDisabled, isReadOnly, isInvalid, collapsed, hasPendingDelete, setHasPendingDelete, setInputValue, onSearch, isSingleSelect, }: ComboboxInnerProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=combobox-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-button.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-button.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAsBlD,wBAAgB,cAAc,CAAC,EAC9B,EAAE,EACF,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,IAAI,EACJ,OAAO,EACP,KAAK,EACL,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,QAAQ,EACR,cAAc,GACd,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"combobox-button.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-button.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAsBlD,wBAAgB,cAAc,CAAC,EAC9B,EAAE,EACF,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,IAAI,EACJ,OAAO,EACP,KAAK,EACL,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,cAAc,GACd,EAAE,kBAAkB,2CAwKpB"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useStyleConfig as
|
|
3
|
-
import { Fragment as
|
|
4
|
-
import { ComboboxItem as
|
|
5
|
-
import { Tag as
|
|
6
|
-
import { Icon as
|
|
7
|
-
import { Icons as
|
|
8
|
-
import { ThemeColorVariable as n, ThemeSpaceVariable as
|
|
9
|
-
function
|
|
1
|
+
import { jsxs as p, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useStyleConfig as E, Flex as u, Box as d, Input as F } from "@chakra-ui/react";
|
|
3
|
+
import { Fragment as L } from "react";
|
|
4
|
+
import { ComboboxItem as O } from "./combobox-item.js";
|
|
5
|
+
import { Tag as N } from "../tag/tag.js";
|
|
6
|
+
import { Icon as X } from "../icon/icon.js";
|
|
7
|
+
import { Icons as K } from "../icon/types.js";
|
|
8
|
+
import { ThemeColorVariable as n, ThemeSpaceVariable as c, ThemeRadiusVariable as T, ThemeIconSizeVariable as U } from "../../theme/theme-types.js";
|
|
9
|
+
function y() {
|
|
10
10
|
return /* @__PURE__ */ i(
|
|
11
|
-
|
|
11
|
+
d,
|
|
12
12
|
{
|
|
13
13
|
backgroundColor: n.NeutralContainer,
|
|
14
14
|
width: "8px",
|
|
@@ -26,47 +26,49 @@ function k() {
|
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function H({
|
|
30
30
|
id: s,
|
|
31
|
-
asPlainText:
|
|
32
|
-
inputValue:
|
|
31
|
+
asPlainText: l,
|
|
32
|
+
inputValue: b,
|
|
33
33
|
selectedItems: r,
|
|
34
|
-
displayItems:
|
|
35
|
-
toggleItem:
|
|
36
|
-
highlightState:
|
|
34
|
+
displayItems: _,
|
|
35
|
+
toggleItem: x,
|
|
36
|
+
highlightState: f,
|
|
37
37
|
openState: a,
|
|
38
|
-
parentStrings:
|
|
39
|
-
size:
|
|
40
|
-
variant:
|
|
41
|
-
label:
|
|
42
|
-
placeHolderText:
|
|
43
|
-
isDisabled:
|
|
44
|
-
isReadOnly:
|
|
45
|
-
isInvalid:
|
|
46
|
-
collapsed:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
parentStrings: j,
|
|
39
|
+
size: B,
|
|
40
|
+
variant: R,
|
|
41
|
+
label: C,
|
|
42
|
+
placeHolderText: V,
|
|
43
|
+
isDisabled: h,
|
|
44
|
+
isReadOnly: m,
|
|
45
|
+
isInvalid: W,
|
|
46
|
+
collapsed: S,
|
|
47
|
+
hasPendingDelete: w,
|
|
48
|
+
setHasPendingDelete: g,
|
|
49
|
+
setInputValue: k,
|
|
50
|
+
onSearch: t,
|
|
51
|
+
isSingleSelect: v
|
|
50
52
|
}) {
|
|
51
|
-
const
|
|
52
|
-
if (o.key === "Enter" && (o.preventDefault(), o.stopPropagation(), a.isOpen ?
|
|
53
|
+
const z = E("Combobox", { size: B, variant: R }), A = (o) => {
|
|
54
|
+
if (o.key === "Enter" && (o.preventDefault(), o.stopPropagation(), a.isOpen ? x(_[f.index]) : a.open()), o.key === "Escape") {
|
|
53
55
|
if (!a.isOpen) return;
|
|
54
|
-
o.preventDefault(), o.stopPropagation(), a.close(),
|
|
56
|
+
o.preventDefault(), o.stopPropagation(), a.close(), l || (k(""), t?.(""));
|
|
55
57
|
}
|
|
56
|
-
o.key === "Backspace"
|
|
57
|
-
},
|
|
58
|
+
o.key === "Backspace" ? b.length === 0 && r.length > 0 && !l && (w ? (x(r[r.length - 1]), g(!1)) : g(!0)) : g(!1), o.key === "ArrowDown" && (a.isOpen ? f.next() : a.open()), o.key === "ArrowUp" && (a.isOpen ? f.previous() : a.open());
|
|
59
|
+
}, D = (o) => {
|
|
58
60
|
o.preventDefault(), o.stopPropagation();
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
+
const e = o.target.value;
|
|
62
|
+
k(e), t?.(e), f.set(0), a.open();
|
|
61
63
|
};
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
|
|
64
|
+
return /* @__PURE__ */ p(
|
|
65
|
+
u,
|
|
64
66
|
{
|
|
65
|
-
__css:
|
|
66
|
-
"aria-disabled":
|
|
67
|
-
"aria-readonly":
|
|
68
|
-
borderRadius:
|
|
69
|
-
padding:
|
|
67
|
+
__css: z,
|
|
68
|
+
"aria-disabled": h,
|
|
69
|
+
"aria-readonly": m,
|
|
70
|
+
borderRadius: T.Small,
|
|
71
|
+
padding: c.Small,
|
|
70
72
|
_focusWithin: {
|
|
71
73
|
borderColor: n.Info,
|
|
72
74
|
boxShadow: `0 0 0 4px ${n.InfoContainer}`,
|
|
@@ -77,33 +79,48 @@ function Q({
|
|
|
77
79
|
backgroundColor: n.SurfaceDisabled
|
|
78
80
|
},
|
|
79
81
|
children: [
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
82
|
+
/* @__PURE__ */ p(
|
|
83
|
+
u,
|
|
82
84
|
{
|
|
83
|
-
flexWrap:
|
|
84
|
-
gap:
|
|
85
|
+
flexWrap: S || v ? "nowrap" : "wrap",
|
|
86
|
+
gap: c.Small,
|
|
85
87
|
overflow: "hidden",
|
|
86
88
|
children: [
|
|
87
|
-
|
|
88
|
-
!
|
|
89
|
-
|
|
89
|
+
C && /* @__PURE__ */ i(d, { whiteSpace: "nowrap", children: C }),
|
|
90
|
+
!l && (S ? r.length > 0 && /* @__PURE__ */ p(
|
|
91
|
+
u,
|
|
90
92
|
{
|
|
91
|
-
gap:
|
|
93
|
+
gap: c.XSmall,
|
|
92
94
|
flexShrink: "1",
|
|
93
95
|
overflow: "hidden",
|
|
94
96
|
whiteSpace: "nowrap",
|
|
95
97
|
textOverflow: "ellipsis",
|
|
96
98
|
children: [
|
|
97
|
-
r.length > 3 && /* @__PURE__ */ i(
|
|
98
|
-
r.length > 2 && /* @__PURE__ */ i(
|
|
99
|
-
r.length > 1 && /* @__PURE__ */ i(
|
|
100
|
-
/* @__PURE__ */ i(
|
|
99
|
+
r.length > 3 && /* @__PURE__ */ i(y, {}),
|
|
100
|
+
r.length > 2 && /* @__PURE__ */ i(y, {}),
|
|
101
|
+
r.length > 1 && /* @__PURE__ */ i(N, { children: r.length - 1 }),
|
|
102
|
+
/* @__PURE__ */ i(
|
|
103
|
+
O,
|
|
104
|
+
{
|
|
105
|
+
isDeleting: w,
|
|
106
|
+
item: r[r.length - 1],
|
|
107
|
+
asPlainText: l
|
|
108
|
+
}
|
|
109
|
+
)
|
|
101
110
|
]
|
|
102
111
|
}
|
|
103
|
-
) : r.map((o) => /* @__PURE__ */ i(
|
|
104
|
-
|
|
112
|
+
) : r.map((o, e) => /* @__PURE__ */ i(
|
|
113
|
+
O,
|
|
114
|
+
{
|
|
115
|
+
item: o,
|
|
116
|
+
asPlainText: l,
|
|
117
|
+
isDeleting: e === r.length - 1 && w
|
|
118
|
+
},
|
|
119
|
+
o.id
|
|
120
|
+
))),
|
|
121
|
+
l && r.length > 0 && b === r[0].label && j[r[0].id]?.map((o) => /* @__PURE__ */ p(L, { children: [
|
|
105
122
|
/* @__PURE__ */ i(
|
|
106
|
-
|
|
123
|
+
d,
|
|
107
124
|
{
|
|
108
125
|
color: n.OnSurfaceSubdued,
|
|
109
126
|
textOverflow: "ellipsis",
|
|
@@ -112,22 +129,22 @@ function Q({
|
|
|
112
129
|
children: o
|
|
113
130
|
}
|
|
114
131
|
),
|
|
115
|
-
/* @__PURE__ */ i(
|
|
132
|
+
/* @__PURE__ */ i(d, { color: n.OnSurfaceSubdued, children: "/" })
|
|
116
133
|
] }, o)),
|
|
117
134
|
/* @__PURE__ */ i(
|
|
118
|
-
|
|
135
|
+
F,
|
|
119
136
|
{
|
|
120
137
|
id: s,
|
|
121
|
-
isDisabled:
|
|
122
|
-
isReadOnly:
|
|
123
|
-
isInvalid:
|
|
124
|
-
onKeyDown:
|
|
138
|
+
isDisabled: h,
|
|
139
|
+
isReadOnly: m,
|
|
140
|
+
isInvalid: W,
|
|
141
|
+
onKeyDown: A,
|
|
125
142
|
variant: "unstyled",
|
|
126
|
-
value:
|
|
143
|
+
value: b,
|
|
127
144
|
autoComplete: "off",
|
|
128
|
-
minWidth:
|
|
129
|
-
onChange:
|
|
130
|
-
placeholder:
|
|
145
|
+
minWidth: c.XLarge,
|
|
146
|
+
onChange: D,
|
|
147
|
+
placeholder: V,
|
|
131
148
|
border: "none",
|
|
132
149
|
flex: 1,
|
|
133
150
|
color: n.OnSurface,
|
|
@@ -144,12 +161,12 @@ function Q({
|
|
|
144
161
|
]
|
|
145
162
|
}
|
|
146
163
|
),
|
|
147
|
-
/* @__PURE__ */ i(
|
|
148
|
-
|
|
164
|
+
/* @__PURE__ */ i(u, { className: "combobox-dropdown-icon", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ i(
|
|
165
|
+
X,
|
|
149
166
|
{
|
|
150
|
-
icon:
|
|
151
|
-
size:
|
|
152
|
-
color:
|
|
167
|
+
icon: K.TreeViewCollapse,
|
|
168
|
+
size: U.Small,
|
|
169
|
+
color: h || m ? n.OnSurfaceSubdued : n.OnSurface
|
|
153
170
|
}
|
|
154
171
|
) })
|
|
155
172
|
]
|
|
@@ -157,5 +174,5 @@ function Q({
|
|
|
157
174
|
);
|
|
158
175
|
}
|
|
159
176
|
export {
|
|
160
|
-
|
|
177
|
+
H as ComboboxButton
|
|
161
178
|
};
|
|
@@ -2,7 +2,8 @@ import { ComboboxItem as ComboboxItemType } from './types.js';
|
|
|
2
2
|
type ComboboxItemProps = {
|
|
3
3
|
item: ComboboxItemType;
|
|
4
4
|
asPlainText?: boolean;
|
|
5
|
+
isDeleting?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function ComboboxItem({ item, asPlainText }: ComboboxItemProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function ComboboxItem({ item, asPlainText, isDeleting }: ComboboxItemProps): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=combobox-item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox-item.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAahE,KAAK,iBAAiB,GAAG;IACxB,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"combobox-item.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox-item.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAahE,KAAK,iBAAiB,GAAG;IACxB,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,iBAAiB,2CAiBhF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Flex as
|
|
3
|
-
import { Box as
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Flex as d } from "@chakra-ui/react";
|
|
3
|
+
import { Box as a } from "../box/box.js";
|
|
4
4
|
import { Tag as r } from "../tag/tag.js";
|
|
5
|
-
import { ThemeSpaceVariable as
|
|
6
|
-
const
|
|
5
|
+
import { ThemeSpaceVariable as c } from "../../theme/theme-types.js";
|
|
6
|
+
const s = {
|
|
7
7
|
info: r.Info,
|
|
8
8
|
success: r.Success,
|
|
9
9
|
warning: r.Warning,
|
|
@@ -13,13 +13,13 @@ const c = {
|
|
|
13
13
|
neutral: r,
|
|
14
14
|
undefined: r.ComboboxItem
|
|
15
15
|
};
|
|
16
|
-
function
|
|
17
|
-
const l = o.variant || "neutral",
|
|
18
|
-
return
|
|
16
|
+
function b({ item: o, asPlainText: p, isDeleting: n }) {
|
|
17
|
+
const l = n ? "primary" : o.variant || "neutral", i = s[l];
|
|
18
|
+
return p ? /* @__PURE__ */ t(d, { gap: c.XSmall, overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", children: [
|
|
19
19
|
o.prepend,
|
|
20
20
|
o.label
|
|
21
|
-
] }) : /* @__PURE__ */ e(
|
|
21
|
+
] }) : /* @__PURE__ */ e(a, { overflow: "hidden", children: /* @__PURE__ */ e(i, { prepend: o.prepend, dot: o.dot, solid: n, children: /* @__PURE__ */ e(a, { display: "block", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis", children: o.label }) }) });
|
|
22
22
|
}
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
b as ComboboxItem
|
|
25
25
|
};
|
|
@@ -4,7 +4,7 @@ import { ComboboxProps } from './types.js';
|
|
|
4
4
|
* are many and can benefit from having a search filter. Can be used as both single select
|
|
5
5
|
* and multiselect.
|
|
6
6
|
*
|
|
7
|
-
* @see Docs https://
|
|
7
|
+
* @see Docs https://caspeco.github.io/casper-ui-library/components/combobox
|
|
8
8
|
*/
|
|
9
9
|
export declare function Combobox({ id, label, isSingleSelect, selectedItems, locale, size, variant, asPlainText, onSearch, items, maxVisibleItems, onChange, onBlur, isDisabled, isReadOnly, isRequired, placeholder, isInvalid, footerContent, popoverWidth, popoverPlacement, collapsed, ...props }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIX,aAAa,EAKb,MAAM,SAAS,CAAC;AAiGjB;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EACxB,EAAE,EACF,KAAU,EACV,cAAsB,EACtB,aAAkB,EAClB,MAAgB,EAChB,IAAW,EACX,OAAmB,EACnB,WAAmB,EACnB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,SAAiB,EACjB,GAAG,KAAK,EACR,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../lib/components/combobox/combobox.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIX,aAAa,EAKb,MAAM,SAAS,CAAC;AAiGjB;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EACxB,EAAE,EACF,KAAU,EACV,cAAsB,EACtB,aAAkB,EAClB,MAAgB,EAChB,IAAW,EACX,OAAmB,EACnB,WAAmB,EACnB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,SAAiB,EACjB,GAAG,KAAK,EACR,EAAE,aAAa,2CA2Lf"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { ComboboxButton as
|
|
5
|
-
import { ComboboxMenu as
|
|
6
|
-
import { translations as
|
|
7
|
-
const
|
|
8
|
-
const [n, e] =
|
|
9
|
-
if (!
|
|
10
|
-
const b = [...
|
|
1
|
+
import { jsxs as ee, jsx as V } from "react/jsx-runtime";
|
|
2
|
+
import { Box as ne } from "@chakra-ui/react";
|
|
3
|
+
import { useState as p, useRef as _, useEffect as q, useMemo as m } from "react";
|
|
4
|
+
import { ComboboxButton as te } from "./combobox-button.js";
|
|
5
|
+
import { ComboboxMenu as re } from "./combobox-menu.js";
|
|
6
|
+
import { translations as oe } from "./translations.js";
|
|
7
|
+
const le = (o, c) => {
|
|
8
|
+
const [n, e] = p(0), i = (l) => {
|
|
9
|
+
if (!c.current) return;
|
|
10
|
+
const b = [...c.current.querySelectorAll("li")];
|
|
11
11
|
b[l] && (b[l]?.scrollIntoView({
|
|
12
12
|
behavior: "smooth",
|
|
13
13
|
block: "nearest"
|
|
@@ -15,28 +15,28 @@ const re = (o, s) => {
|
|
|
15
15
|
};
|
|
16
16
|
return {
|
|
17
17
|
index: n,
|
|
18
|
-
set:
|
|
19
|
-
next: () =>
|
|
20
|
-
previous: () =>
|
|
18
|
+
set: i,
|
|
19
|
+
next: () => i((n + 1) % o.length),
|
|
20
|
+
previous: () => i((n - 1 + o.length) % o.length)
|
|
21
21
|
};
|
|
22
|
-
},
|
|
23
|
-
const [
|
|
24
|
-
return
|
|
22
|
+
}, se = (o, c, n, e) => {
|
|
23
|
+
const [i, t] = p(!1);
|
|
24
|
+
return q(() => {
|
|
25
25
|
e && t(!1);
|
|
26
|
-
}, [e, t]), { isOpen:
|
|
27
|
-
|
|
26
|
+
}, [e, t]), { isOpen: i, close: () => {
|
|
27
|
+
c || n(""), t(!1);
|
|
28
28
|
}, open: () => {
|
|
29
|
-
|
|
29
|
+
i || e || (t(!0), o.set(0));
|
|
30
30
|
} };
|
|
31
|
-
},
|
|
32
|
-
const [n, e] =
|
|
31
|
+
}, ie = (o, c) => {
|
|
32
|
+
const [n, e] = p([]), i = m(() => {
|
|
33
33
|
if (!n.length) return o;
|
|
34
34
|
const t = n[n.length - 1], h = {
|
|
35
35
|
id: "_back",
|
|
36
|
-
label:
|
|
36
|
+
label: c.back
|
|
37
37
|
}, l = n[n.length - 1].children || [];
|
|
38
38
|
return t.isSelectableParent ? [h, t, ...l] : [h, ...l];
|
|
39
|
-
}, [n, o,
|
|
39
|
+
}, [n, o, c]);
|
|
40
40
|
return {
|
|
41
41
|
open: (t) => {
|
|
42
42
|
e((h) => [...h, t]);
|
|
@@ -45,65 +45,65 @@ const re = (o, s) => {
|
|
|
45
45
|
n.length && e((t) => [...t.slice(0, n.length - 1)]);
|
|
46
46
|
},
|
|
47
47
|
opened: n,
|
|
48
|
-
current:
|
|
48
|
+
current: i
|
|
49
49
|
};
|
|
50
|
-
},
|
|
51
|
-
const
|
|
52
|
-
function n(e,
|
|
53
|
-
|
|
50
|
+
}, ce = (o) => m(() => {
|
|
51
|
+
const c = {};
|
|
52
|
+
function n(e, i) {
|
|
53
|
+
c[e.id] = [...i], e.children && e.children.forEach((t) => n(t, [...i, e.label]));
|
|
54
54
|
}
|
|
55
|
-
return o.forEach((e) => n(e, [])),
|
|
55
|
+
return o.forEach((e) => n(e, [])), c;
|
|
56
56
|
}, [o]);
|
|
57
|
-
function
|
|
57
|
+
function be({
|
|
58
58
|
id: o,
|
|
59
|
-
label:
|
|
59
|
+
label: c = "",
|
|
60
60
|
isSingleSelect: n = !1,
|
|
61
61
|
selectedItems: e = [],
|
|
62
|
-
locale:
|
|
62
|
+
locale: i = "en-US",
|
|
63
63
|
size: t = "md",
|
|
64
64
|
variant: h = "outline",
|
|
65
65
|
asPlainText: l = !1,
|
|
66
66
|
onSearch: b,
|
|
67
67
|
items: I,
|
|
68
|
-
maxVisibleItems:
|
|
69
|
-
onChange:
|
|
70
|
-
onBlur:
|
|
68
|
+
maxVisibleItems: M,
|
|
69
|
+
onChange: L,
|
|
70
|
+
onBlur: N,
|
|
71
71
|
isDisabled: S,
|
|
72
72
|
isReadOnly: x,
|
|
73
|
-
isRequired:
|
|
74
|
-
placeholder:
|
|
73
|
+
isRequired: U,
|
|
74
|
+
placeholder: W,
|
|
75
75
|
isInvalid: B,
|
|
76
|
-
footerContent:
|
|
77
|
-
popoverWidth:
|
|
78
|
-
popoverPlacement:
|
|
79
|
-
collapsed:
|
|
80
|
-
...
|
|
76
|
+
footerContent: z,
|
|
77
|
+
popoverWidth: G,
|
|
78
|
+
popoverPlacement: J,
|
|
79
|
+
collapsed: K = !1,
|
|
80
|
+
...Q
|
|
81
81
|
}) {
|
|
82
|
-
const [
|
|
82
|
+
const [H, g] = p(""), [X, j] = p(!1), k = oe[i], w = _(null), O = _(null), f = ie(I, k), Y = H.toLowerCase() === e[0]?.label.toLowerCase(), v = H.length > 0 && !(l && Y);
|
|
83
83
|
let u = f.current;
|
|
84
|
-
if (
|
|
85
|
-
const r = [], d = (
|
|
86
|
-
r.push(
|
|
84
|
+
if (v) {
|
|
85
|
+
const r = [], d = (s) => {
|
|
86
|
+
r.push(s), s.children && s.children.forEach(d);
|
|
87
87
|
};
|
|
88
|
-
I.forEach(d), u = r.filter((
|
|
89
|
-
const
|
|
90
|
-
return (!(
|
|
88
|
+
I.forEach(d), u = r.filter((s) => {
|
|
89
|
+
const F = s.label.toLowerCase().includes(H.toLowerCase());
|
|
90
|
+
return (!(s.children && s.children.length > 0) || s.isSelectableParent) && F;
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
const E =
|
|
94
|
-
|
|
95
|
-
l && !a.isOpen &&
|
|
93
|
+
const E = le(u, O), a = se(E, l, g, S);
|
|
94
|
+
q(() => {
|
|
95
|
+
l && !a.isOpen && g(e[0]?.label || "");
|
|
96
96
|
}, [a.isOpen, e, l]);
|
|
97
|
-
const [
|
|
98
|
-
|
|
99
|
-
!a.isOpen || n ||
|
|
100
|
-
}, [a.isOpen]),
|
|
101
|
-
...
|
|
102
|
-
...u.filter((r) => !
|
|
97
|
+
const [P, Z] = p([]);
|
|
98
|
+
q(() => {
|
|
99
|
+
!a.isOpen || n || Z(e);
|
|
100
|
+
}, [a.isOpen]), v || (u = [
|
|
101
|
+
...P,
|
|
102
|
+
...u.filter((r) => !P.find((d) => d.label === r.label))
|
|
103
103
|
]);
|
|
104
|
-
let
|
|
105
|
-
x ? u = e : (
|
|
106
|
-
const
|
|
104
|
+
let y = !1;
|
|
105
|
+
x ? u = e : (y = u.length > (M ?? 1 / 0), u = u.slice(0, M));
|
|
106
|
+
const $ = ce(I), R = (r) => {
|
|
107
107
|
if (x || S)
|
|
108
108
|
return;
|
|
109
109
|
if (r.id === "_back") {
|
|
@@ -112,50 +112,52 @@ function pe({
|
|
|
112
112
|
}
|
|
113
113
|
O.current?.parentNode?.querySelector("input")?.focus();
|
|
114
114
|
const d = f.opened.length > 0 && f.opened[f.opened.length - 1].id === r.id;
|
|
115
|
-
if (!
|
|
115
|
+
if (!v && !d && r.children && r.children.length > 0) {
|
|
116
116
|
f.open(r), requestAnimationFrame(() => E.set(1));
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
let
|
|
120
|
-
n || (e.some((
|
|
121
|
-
},
|
|
122
|
-
w.current?.contains(r.relatedTarget) || (a.close(),
|
|
123
|
-
},
|
|
119
|
+
let s = [r];
|
|
120
|
+
n || (e.some((C) => C.id === r.id) ? s = e.filter((C) => C.id !== r.id) : s = [...e, r]), g(l ? s[0]?.label : ""), n && (s.length === 0 ? a.open() : a.close()), L && L(s);
|
|
121
|
+
}, T = e.length === 0 ? W ?? k.search : void 0, D = (r) => {
|
|
122
|
+
w.current?.contains(r.relatedTarget) || (a.close(), j(!1), N && N(e));
|
|
123
|
+
}, A = {
|
|
124
124
|
id: o,
|
|
125
125
|
asPlainText: l,
|
|
126
|
-
inputValue:
|
|
126
|
+
inputValue: H,
|
|
127
127
|
selectedItems: e,
|
|
128
128
|
displayItems: u,
|
|
129
|
-
toggleItem:
|
|
129
|
+
toggleItem: R,
|
|
130
130
|
highlightState: E,
|
|
131
131
|
openState: a,
|
|
132
|
-
parentStrings:
|
|
132
|
+
parentStrings: $,
|
|
133
133
|
// Button
|
|
134
134
|
size: t,
|
|
135
135
|
variant: h,
|
|
136
|
-
label:
|
|
137
|
-
placeHolderText:
|
|
136
|
+
label: c,
|
|
137
|
+
placeHolderText: T,
|
|
138
138
|
isDisabled: S,
|
|
139
139
|
isReadOnly: x,
|
|
140
140
|
isInvalid: B,
|
|
141
|
-
collapsed:
|
|
142
|
-
|
|
141
|
+
collapsed: K,
|
|
142
|
+
hasPendingDelete: X,
|
|
143
|
+
setHasPendingDelete: j,
|
|
144
|
+
setInputValue: g,
|
|
143
145
|
onSearch: b,
|
|
144
146
|
// Menu
|
|
145
147
|
isSingleSelect: n,
|
|
146
|
-
isSearching:
|
|
147
|
-
isHidingItems:
|
|
148
|
-
popoverWidth:
|
|
149
|
-
popoverPlacement:
|
|
150
|
-
previousSelectedItems:
|
|
148
|
+
isSearching: v,
|
|
149
|
+
isHidingItems: y,
|
|
150
|
+
popoverWidth: G,
|
|
151
|
+
popoverPlacement: J,
|
|
152
|
+
previousSelectedItems: P,
|
|
151
153
|
parentRef: w,
|
|
152
154
|
popupRef: O,
|
|
153
|
-
footerContent:
|
|
155
|
+
footerContent: z,
|
|
154
156
|
subMenuState: f,
|
|
155
157
|
translation: k
|
|
156
158
|
};
|
|
157
|
-
return /* @__PURE__ */
|
|
158
|
-
|
|
159
|
+
return /* @__PURE__ */ ee(
|
|
160
|
+
ne,
|
|
159
161
|
{
|
|
160
162
|
role: "combobox",
|
|
161
163
|
as: "label",
|
|
@@ -163,22 +165,22 @@ function pe({
|
|
|
163
165
|
className: "combobox",
|
|
164
166
|
ref: w,
|
|
165
167
|
onClick: a.open,
|
|
166
|
-
onBlur:
|
|
168
|
+
onBlur: D,
|
|
167
169
|
overflow: "visible",
|
|
168
170
|
width: "100%",
|
|
169
171
|
"aria-expanded": a.isOpen,
|
|
170
172
|
"aria-invalid": B,
|
|
171
|
-
"aria-required":
|
|
173
|
+
"aria-required": U,
|
|
172
174
|
"aria-disabled": S,
|
|
173
175
|
"aria-readonly": x,
|
|
174
|
-
...
|
|
176
|
+
...Q,
|
|
175
177
|
children: [
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
a.isOpen && /* @__PURE__ */
|
|
178
|
+
/* @__PURE__ */ V(te, { ...A }),
|
|
179
|
+
a.isOpen && /* @__PURE__ */ V(re, { ...A })
|
|
178
180
|
]
|
|
179
181
|
}
|
|
180
182
|
);
|
|
181
183
|
}
|
|
182
184
|
export {
|
|
183
|
-
|
|
185
|
+
be as Combobox
|
|
184
186
|
};
|