@janbox/storefront-ui 1.0.3 → 1.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/virtualized-list.d.ts +2 -2
- package/dist/components/virtualized-list.d.ts.map +1 -1
- package/dist/components/virtualized-list.js +15 -2
- package/dist/lib/cascader/cascader-floating-content.d.ts +30 -0
- package/dist/lib/cascader/cascader-floating-content.d.ts.map +1 -0
- package/dist/lib/cascader/cascader-floating-content.js +411 -0
- package/dist/lib/cascader/cascader.d.ts +2 -2
- package/dist/lib/cascader/cascader.d.ts.map +1 -1
- package/dist/lib/cascader/cascader.js +33 -363
- package/dist/lib/cascader/helpers.d.ts +10 -6
- package/dist/lib/cascader/helpers.d.ts.map +1 -1
- package/dist/lib/cascader/helpers.js +8 -2
- package/dist/lib/cascader/types.d.ts +17 -11
- package/dist/lib/cascader/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2,8 +2,8 @@ import { JSX, Ref } from 'react';
|
|
|
2
2
|
import { useVirtualizer, VirtualItem } from '@tanstack/react-virtual';
|
|
3
3
|
import { ScrollViewRef } from './scroll-view';
|
|
4
4
|
import { ShallowMerge } from '../types';
|
|
5
|
-
type VirtualizedListOptions = Omit<Parameters<typeof useVirtualizer<HTMLDivElement, HTMLDivElement>>[0],
|
|
6
|
-
type VirtualizedListProps = ShallowMerge<JSX.IntrinsicElements[
|
|
5
|
+
type VirtualizedListOptions = Omit<Parameters<typeof useVirtualizer<HTMLDivElement, HTMLDivElement>>[0], "getScrollElement">;
|
|
6
|
+
type VirtualizedListProps = ShallowMerge<JSX.IntrinsicElements["div"], {
|
|
7
7
|
RowComponent: React.ComponentType<{
|
|
8
8
|
row: VirtualItem;
|
|
9
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualized-list.d.ts","sourceRoot":"","sources":["../../src/components/virtualized-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAU,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAc,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,KAAK,sBAAsB,GAAG,IAAI,CAChC,UAAU,CAAC,OAAO,cAAc,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EACpE,kBAAkB,CACnB,CAAC;AAEF,KAAK,oBAAoB,GAAG,YAAY,CACtC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAC5B;IACE,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IACxD,OAAO,EAAE,sBAAsB,CAAC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC1B,CACF,CAAC;AAEF,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC;AAE1E,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"virtualized-list.d.ts","sourceRoot":"","sources":["../../src/components/virtualized-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAU,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAc,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,KAAK,sBAAsB,GAAG,IAAI,CAChC,UAAU,CAAC,OAAO,cAAc,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,EACpE,kBAAkB,CACnB,CAAC;AAEF,KAAK,oBAAoB,GAAG,YAAY,CACtC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAC5B;IACE,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IACxD,OAAO,EAAE,sBAAsB,CAAC;IAChC,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC1B,CACF,CAAC;AAEF,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC;AAE1E,eAAO,MAAM,eAAe,6CAKzB,oBAAoB,qDAgDtB,CAAC"}
|
|
@@ -4,7 +4,12 @@ import { useMergeRefs } from "@floating-ui/react";
|
|
|
4
4
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
import { motion } from "motion/react";
|
|
6
6
|
import { ScrollView } from "./scroll-view.js";
|
|
7
|
-
const VirtualizedList = ({
|
|
7
|
+
const VirtualizedList = ({
|
|
8
|
+
RowComponent,
|
|
9
|
+
options,
|
|
10
|
+
ref,
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
8
13
|
var _a;
|
|
9
14
|
const scrollRef = useRef(null);
|
|
10
15
|
const mergedRefs = useMergeRefs([scrollRef, ref]);
|
|
@@ -32,7 +37,15 @@ const VirtualizedList = ({ RowComponent, options, ref, ...props }) => {
|
|
|
32
37
|
style: {
|
|
33
38
|
transform: `translateY(${((_a = items.at(0)) == null ? void 0 : _a.start) ?? 0}px)`
|
|
34
39
|
},
|
|
35
|
-
children: items.map((virtualRow) => /* @__PURE__ */ jsx(
|
|
40
|
+
children: items.map((virtualRow) => /* @__PURE__ */ jsx(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
"data-index": virtualRow.index,
|
|
44
|
+
ref: virtualizer.measureElement,
|
|
45
|
+
children: /* @__PURE__ */ jsx(RowComponent, { row: virtualRow })
|
|
46
|
+
},
|
|
47
|
+
virtualRow.key
|
|
48
|
+
))
|
|
36
49
|
}
|
|
37
50
|
)
|
|
38
51
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { CascaderOption } from './types';
|
|
3
|
+
import { InputProps } from '../input';
|
|
4
|
+
import { SizeVariant } from '../../types';
|
|
5
|
+
type CascaderFloatingContentProps = {
|
|
6
|
+
searchable: boolean;
|
|
7
|
+
selectedPath: string[];
|
|
8
|
+
options: CascaderOption[];
|
|
9
|
+
loadOptions?: (tree: CascaderOption[]) => Promise<CascaderOption[]>;
|
|
10
|
+
onChange?: (value: string[], selectedOptions: CascaderOption[]) => void;
|
|
11
|
+
inputProps?: InputProps;
|
|
12
|
+
listProps?: HTMLAttributes<HTMLDivElement>;
|
|
13
|
+
separator: React.ReactNode;
|
|
14
|
+
lazy: boolean;
|
|
15
|
+
xs?: {
|
|
16
|
+
size?: SizeVariant;
|
|
17
|
+
};
|
|
18
|
+
sm?: {
|
|
19
|
+
size?: SizeVariant;
|
|
20
|
+
};
|
|
21
|
+
md?: {
|
|
22
|
+
size?: SizeVariant;
|
|
23
|
+
};
|
|
24
|
+
lg?: {
|
|
25
|
+
size?: SizeVariant;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const CascaderFloatingContent: ({ searchable, selectedPath, options, loadOptions, onChange, inputProps, listProps, separator, lazy, xs, sm, md, lg, }: CascaderFloatingContentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=cascader-floating-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cascader-floating-content.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/cascader-floating-content.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAOf,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAS,UAAU,EAAE,MAAM,UAAU,CAAC;AAe7C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMtC,KAAK,4BAA4B,GAAG;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IACxE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;IAC5B,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;IAC5B,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;IAC5B,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,0HAcjC,4BAA4B,qDA+b9B,CAAC"}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useRef, useId, useState, useEffect, useMemo, useCallback } from "react";
|
|
3
|
+
import { isString, isNil, trimStart } from "lodash-es";
|
|
4
|
+
import { findOptionPath, isExpandable, hasChildren } from "./helpers.js";
|
|
5
|
+
import ArrowRightIcon from "../../assets/svg/arrow-right.svg.js";
|
|
6
|
+
import CheckIcon from "../../assets/svg/done-check.svg.js";
|
|
7
|
+
import { SvgLoader } from "../../components/svg-loader.js";
|
|
8
|
+
import { VirtualizedList } from "../../components/virtualized-list.js";
|
|
9
|
+
import { getResponsiveProp, getSizeVariantState } from "../../utils/index.js";
|
|
10
|
+
import { useWindowScreen } from "../../hooks/use-window-screen/index.js";
|
|
11
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
12
|
+
import { getColorVar } from "../../theme/palette.js";
|
|
13
|
+
import { getTypographyVar } from "../../theme/typography.js";
|
|
14
|
+
import { useFloatingContext } from "../floating/floating/helpers.js";
|
|
15
|
+
import { ensureArray, matchSearch } from "../../utils/common.js";
|
|
16
|
+
import { Input } from "../input/input.js";
|
|
17
|
+
import { TextSkeleton } from "../loading/text-skeleton/text-skeleton.js";
|
|
18
|
+
import { truncate } from "../../utils/emotion-helpers.js";
|
|
19
|
+
const DEFAULT_DISPLAY_ROW_COUNT = 5;
|
|
20
|
+
const CascaderFloatingContent = ({
|
|
21
|
+
searchable,
|
|
22
|
+
selectedPath,
|
|
23
|
+
options,
|
|
24
|
+
loadOptions,
|
|
25
|
+
onChange,
|
|
26
|
+
inputProps,
|
|
27
|
+
listProps,
|
|
28
|
+
separator,
|
|
29
|
+
lazy,
|
|
30
|
+
xs,
|
|
31
|
+
sm,
|
|
32
|
+
md,
|
|
33
|
+
lg
|
|
34
|
+
}) => {
|
|
35
|
+
const { context } = useFloatingContext();
|
|
36
|
+
const searchInputRef = useRef(null);
|
|
37
|
+
const uniqueId = useId();
|
|
38
|
+
const [inputValue, setInputValue] = useControllableState({
|
|
39
|
+
defaultValue: (inputProps == null ? void 0 : inputProps.defaultValue) ?? "",
|
|
40
|
+
value: inputProps == null ? void 0 : inputProps.value
|
|
41
|
+
});
|
|
42
|
+
const windowScreen = useWindowScreen();
|
|
43
|
+
const [expandedPath, setExpandedPath] = useState([]);
|
|
44
|
+
const [dynamicChildren, setDynamicChildren] = useState({});
|
|
45
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (selectedPath.length === 0) return;
|
|
48
|
+
const resolveExpandedPath = (fullPath, opts) => {
|
|
49
|
+
const pathOptions = findOptionPath(opts, fullPath);
|
|
50
|
+
const lastOption = pathOptions[pathOptions.length - 1];
|
|
51
|
+
if (lastOption && !isExpandable(lastOption)) {
|
|
52
|
+
return fullPath.slice(0, -1);
|
|
53
|
+
}
|
|
54
|
+
return fullPath;
|
|
55
|
+
};
|
|
56
|
+
if (!loadOptions) {
|
|
57
|
+
setExpandedPath(resolveExpandedPath(selectedPath, options));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let cancelled = false;
|
|
61
|
+
const loadAlongPath = async () => {
|
|
62
|
+
var _a;
|
|
63
|
+
setIsLoading(true);
|
|
64
|
+
try {
|
|
65
|
+
let currentOpts = options;
|
|
66
|
+
const loadedChildren = {};
|
|
67
|
+
const pathSoFar = [];
|
|
68
|
+
const targetPath = resolveExpandedPath(selectedPath, options);
|
|
69
|
+
const existingPath = findOptionPath(options, targetPath);
|
|
70
|
+
if (existingPath.length === targetPath.length) {
|
|
71
|
+
if (!cancelled) setExpandedPath(targetPath);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < targetPath.length; i++) {
|
|
75
|
+
if (cancelled) return;
|
|
76
|
+
const value = targetPath[i];
|
|
77
|
+
const found = currentOpts.find((opt) => opt.value === value);
|
|
78
|
+
if (!found) break;
|
|
79
|
+
pathSoFar.push(found);
|
|
80
|
+
if (isExpandable(found) && !hasChildren(found)) {
|
|
81
|
+
const children = await loadOptions(pathSoFar);
|
|
82
|
+
if (cancelled) return;
|
|
83
|
+
const cacheKey = targetPath.slice(0, i + 1).join("/");
|
|
84
|
+
loadedChildren[cacheKey] = children;
|
|
85
|
+
currentOpts = children;
|
|
86
|
+
} else if ((_a = found.children) == null ? void 0 : _a.length) {
|
|
87
|
+
currentOpts = found.children;
|
|
88
|
+
} else {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!cancelled) {
|
|
93
|
+
if (Object.keys(loadedChildren).length > 0) {
|
|
94
|
+
setDynamicChildren((prev) => ({ ...prev, ...loadedChildren }));
|
|
95
|
+
}
|
|
96
|
+
setExpandedPath(targetPath);
|
|
97
|
+
}
|
|
98
|
+
} finally {
|
|
99
|
+
if (!cancelled) setIsLoading(false);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
loadAlongPath();
|
|
103
|
+
return () => {
|
|
104
|
+
cancelled = true;
|
|
105
|
+
};
|
|
106
|
+
}, []);
|
|
107
|
+
const mergedOptions = useMemo(() => {
|
|
108
|
+
if (!loadOptions || Object.keys(dynamicChildren).length === 0)
|
|
109
|
+
return options;
|
|
110
|
+
const mergeRecursive = (opts, parentKey) => {
|
|
111
|
+
return opts.map((opt) => {
|
|
112
|
+
const key = parentKey ? `${parentKey}/${opt.value}` : opt.value;
|
|
113
|
+
const loaded = dynamicChildren[key];
|
|
114
|
+
const children = loaded ?? opt.children;
|
|
115
|
+
return {
|
|
116
|
+
...opt,
|
|
117
|
+
children: children ? mergeRecursive(children, key) : void 0
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
return mergeRecursive(options, "");
|
|
122
|
+
}, [options, dynamicChildren, loadOptions]);
|
|
123
|
+
const handleBreadcrumbClick = (e) => {
|
|
124
|
+
const level = Number(e.currentTarget.dataset.index);
|
|
125
|
+
if (level < 0) {
|
|
126
|
+
setExpandedPath([]);
|
|
127
|
+
} else {
|
|
128
|
+
setExpandedPath(expandedPath.slice(0, level + 1));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const expandedOptions = useMemo(() => {
|
|
132
|
+
return findOptionPath(mergedOptions, expandedPath);
|
|
133
|
+
}, [mergedOptions, expandedPath]);
|
|
134
|
+
const currentOptions = useMemo(() => {
|
|
135
|
+
var _a;
|
|
136
|
+
if (expandedPath.length === 0) {
|
|
137
|
+
return mergedOptions;
|
|
138
|
+
}
|
|
139
|
+
let current = mergedOptions;
|
|
140
|
+
for (const value of expandedPath) {
|
|
141
|
+
const found = current.find((opt) => opt.value === value);
|
|
142
|
+
if ((_a = found == null ? void 0 : found.children) == null ? void 0 : _a.length) {
|
|
143
|
+
current = found.children;
|
|
144
|
+
} else {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return current;
|
|
149
|
+
}, [mergedOptions, expandedPath]);
|
|
150
|
+
const displayOptions = useMemo(() => {
|
|
151
|
+
if (!inputValue) {
|
|
152
|
+
return currentOptions;
|
|
153
|
+
}
|
|
154
|
+
return currentOptions.filter((option) => {
|
|
155
|
+
const searchLabels = ensureArray(option.searchLabel ?? []);
|
|
156
|
+
if (!searchLabels.length && isString(option.label)) {
|
|
157
|
+
searchLabels.push(option.label);
|
|
158
|
+
}
|
|
159
|
+
return matchSearch(searchLabels, inputValue);
|
|
160
|
+
});
|
|
161
|
+
}, [inputValue, currentOptions]);
|
|
162
|
+
const responsiveSize = isNil(windowScreen.name) ? void 0 : getResponsiveProp({ xs, sm, md, lg }, "size", windowScreen.name);
|
|
163
|
+
const { inputSize: rowMinHeight = 0, inputPaddingX } = getSizeVariantState(responsiveSize);
|
|
164
|
+
const onInputChange = (e) => {
|
|
165
|
+
var _a;
|
|
166
|
+
e.target.value = trimStart(e.target.value);
|
|
167
|
+
setInputValue(e.target.value);
|
|
168
|
+
(_a = inputProps == null ? void 0 : inputProps.onChange) == null ? void 0 : _a.call(inputProps, e);
|
|
169
|
+
};
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
const timer = setTimeout(() => {
|
|
172
|
+
var _a;
|
|
173
|
+
(_a = searchInputRef.current) == null ? void 0 : _a.focus();
|
|
174
|
+
}, 100);
|
|
175
|
+
return () => clearTimeout(timer);
|
|
176
|
+
}, []);
|
|
177
|
+
const estimateSize = useCallback(
|
|
178
|
+
(_index) => {
|
|
179
|
+
return rowMinHeight ?? 0;
|
|
180
|
+
},
|
|
181
|
+
[rowMinHeight]
|
|
182
|
+
);
|
|
183
|
+
const getItemKey = useCallback(
|
|
184
|
+
(index) => {
|
|
185
|
+
const option = displayOptions.at(index);
|
|
186
|
+
return option ? option.value : `${uniqueId}-${index}`;
|
|
187
|
+
},
|
|
188
|
+
[displayOptions, uniqueId]
|
|
189
|
+
);
|
|
190
|
+
const renderBreadcrumbs = () => {
|
|
191
|
+
if (expandedPath.length === 0) return null;
|
|
192
|
+
return /* @__PURE__ */ jsxs(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
css: {
|
|
196
|
+
paddingLeft: inputPaddingX,
|
|
197
|
+
paddingRight: inputPaddingX,
|
|
198
|
+
minHeight: rowMinHeight,
|
|
199
|
+
borderTop: `1px solid ${getColorVar("neutral.200")}`,
|
|
200
|
+
display: "flex",
|
|
201
|
+
alignItems: "center",
|
|
202
|
+
gap: "0.25rem",
|
|
203
|
+
flexWrap: "wrap",
|
|
204
|
+
paddingTop: "0.25rem",
|
|
205
|
+
paddingBottom: "0.25rem"
|
|
206
|
+
},
|
|
207
|
+
children: [
|
|
208
|
+
/* @__PURE__ */ jsx(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
"data-index": -1,
|
|
212
|
+
type: "button",
|
|
213
|
+
onClick: handleBreadcrumbClick,
|
|
214
|
+
css: {
|
|
215
|
+
color: getColorVar("neutral.500"),
|
|
216
|
+
transition: "color 150ms",
|
|
217
|
+
"&:hover": { color: getColorVar("primary.600") }
|
|
218
|
+
},
|
|
219
|
+
children: "All"
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
expandedOptions.map((opt, idx) => /* @__PURE__ */ jsxs(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
css: { display: "flex", alignItems: "center", gap: "0.25rem" },
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsx("span", { css: { color: getColorVar("neutral.400") }, children: separator }),
|
|
228
|
+
/* @__PURE__ */ jsx(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
"data-index": idx,
|
|
232
|
+
type: "button",
|
|
233
|
+
onClick: handleBreadcrumbClick,
|
|
234
|
+
css: {
|
|
235
|
+
color: idx === expandedOptions.length - 1 ? getColorVar("primary.600") : getColorVar("neutral.600"),
|
|
236
|
+
fontWeight: idx === expandedOptions.length - 1 ? 500 : void 0,
|
|
237
|
+
transition: "color 150ms",
|
|
238
|
+
"&:hover": { color: getColorVar("primary.600") }
|
|
239
|
+
},
|
|
240
|
+
children: opt.breadcrumbLabel ?? opt.label
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
`${uniqueId}-breadcrumb-${opt.value}`
|
|
246
|
+
))
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
const RowComponent = ({ row }) => {
|
|
252
|
+
const rowData = displayOptions.at(row.index);
|
|
253
|
+
if (isNil(rowData)) return /* @__PURE__ */ jsx(Fragment, {});
|
|
254
|
+
const isSelected = selectedPath.includes(rowData.value);
|
|
255
|
+
const handleSelect = async () => {
|
|
256
|
+
var _a, _b;
|
|
257
|
+
if (rowData.disabled || isLoading) return;
|
|
258
|
+
const parentPath = [];
|
|
259
|
+
let current = mergedOptions;
|
|
260
|
+
for (const value of expandedPath) {
|
|
261
|
+
const found = current.find((opt) => opt.value === value);
|
|
262
|
+
if ((_a = found == null ? void 0 : found.children) == null ? void 0 : _a.length) {
|
|
263
|
+
parentPath.push(value);
|
|
264
|
+
current = found.children;
|
|
265
|
+
} else {
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const newPath = [...parentPath, rowData.value];
|
|
270
|
+
const newSelectedOptions = findOptionPath(mergedOptions, newPath);
|
|
271
|
+
if (isExpandable(rowData)) {
|
|
272
|
+
if (!hasChildren(rowData) && loadOptions) {
|
|
273
|
+
const cacheKey = newPath.join("/");
|
|
274
|
+
setIsLoading(true);
|
|
275
|
+
try {
|
|
276
|
+
const children = await loadOptions(newSelectedOptions);
|
|
277
|
+
setDynamicChildren((prev) => ({ ...prev, [cacheKey]: children }));
|
|
278
|
+
setExpandedPath(newPath);
|
|
279
|
+
} finally {
|
|
280
|
+
setIsLoading(false);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
setExpandedPath(newPath);
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
onChange == null ? void 0 : onChange(newPath, newSelectedOptions);
|
|
287
|
+
(_b = context.onOpenChange) == null ? void 0 : _b.call(context, false);
|
|
288
|
+
}
|
|
289
|
+
setInputValue("");
|
|
290
|
+
setTimeout(() => {
|
|
291
|
+
var _a2;
|
|
292
|
+
(_a2 = searchInputRef.current) == null ? void 0 : _a2.focus();
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
return /* @__PURE__ */ jsx(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
"aria-hidden": true,
|
|
299
|
+
role: "button",
|
|
300
|
+
onClick: handleSelect,
|
|
301
|
+
css: {
|
|
302
|
+
minHeight: rowMinHeight,
|
|
303
|
+
paddingLeft: inputPaddingX,
|
|
304
|
+
paddingRight: inputPaddingX,
|
|
305
|
+
paddingTop: "0.25rem",
|
|
306
|
+
paddingBottom: "0.25rem",
|
|
307
|
+
display: "flex",
|
|
308
|
+
alignItems: "center",
|
|
309
|
+
gap: "0.5rem",
|
|
310
|
+
borderRadius: "0.5rem",
|
|
311
|
+
transition: "background-color 150ms, color 150ms",
|
|
312
|
+
"&:hover": { backgroundColor: getColorVar("neutral.100") },
|
|
313
|
+
...isSelected && !isExpandable(rowData) ? {
|
|
314
|
+
color: getColorVar("primary.600"),
|
|
315
|
+
backgroundColor: getColorVar("primary.100")
|
|
316
|
+
} : {},
|
|
317
|
+
...rowData.disabled ? { opacity: 0.5, cursor: "not-allowed" } : {}
|
|
318
|
+
},
|
|
319
|
+
children: isLoading ? /* @__PURE__ */ jsx(TextSkeleton, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
320
|
+
/* @__PURE__ */ jsx("div", { css: { flex: 1, ...truncate }, children: rowData.label }),
|
|
321
|
+
isExpandable(rowData) ? /* @__PURE__ */ jsx(
|
|
322
|
+
SvgLoader,
|
|
323
|
+
{
|
|
324
|
+
source: ArrowRightIcon,
|
|
325
|
+
width: 20,
|
|
326
|
+
height: 20,
|
|
327
|
+
css: { color: getColorVar("neutral.400") }
|
|
328
|
+
}
|
|
329
|
+
) : isSelected && /* @__PURE__ */ jsx(
|
|
330
|
+
SvgLoader,
|
|
331
|
+
{
|
|
332
|
+
source: CheckIcon,
|
|
333
|
+
width: 20,
|
|
334
|
+
height: 20,
|
|
335
|
+
css: { color: getColorVar("primary.600") }
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
] })
|
|
339
|
+
},
|
|
340
|
+
`${uniqueId}-option-${rowData.value}`
|
|
341
|
+
);
|
|
342
|
+
};
|
|
343
|
+
return /* @__PURE__ */ jsxs(
|
|
344
|
+
"div",
|
|
345
|
+
{
|
|
346
|
+
css: {
|
|
347
|
+
paddingTop: "0.5rem",
|
|
348
|
+
paddingBottom: "0.5rem",
|
|
349
|
+
border: `1px solid ${getColorVar("border.default")}`,
|
|
350
|
+
borderRadius: "0.5rem",
|
|
351
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
|
352
|
+
fontSize: getTypographyVar("sm").fontSize,
|
|
353
|
+
lineHeight: getTypographyVar("sm").lineHeight,
|
|
354
|
+
backgroundColor: getColorVar("surface.default")
|
|
355
|
+
},
|
|
356
|
+
children: [
|
|
357
|
+
!searchable && /* @__PURE__ */ jsx(
|
|
358
|
+
"div",
|
|
359
|
+
{
|
|
360
|
+
css: {
|
|
361
|
+
paddingLeft: "0.5rem",
|
|
362
|
+
paddingRight: "0.5rem",
|
|
363
|
+
paddingTop: "0.5rem",
|
|
364
|
+
paddingBottom: "0.5rem"
|
|
365
|
+
},
|
|
366
|
+
children: /* @__PURE__ */ jsx(
|
|
367
|
+
Input,
|
|
368
|
+
{
|
|
369
|
+
xs: { size: xs == null ? void 0 : xs.size },
|
|
370
|
+
sm: { size: sm == null ? void 0 : sm.size },
|
|
371
|
+
md: { size: md == null ? void 0 : md.size },
|
|
372
|
+
lg: { size: lg == null ? void 0 : lg.size },
|
|
373
|
+
value: inputValue,
|
|
374
|
+
placeholder: "Search...",
|
|
375
|
+
...inputProps,
|
|
376
|
+
onChange: onInputChange,
|
|
377
|
+
ref: searchInputRef
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ jsx(
|
|
383
|
+
VirtualizedList,
|
|
384
|
+
{
|
|
385
|
+
...listProps,
|
|
386
|
+
css: {
|
|
387
|
+
paddingLeft: 4,
|
|
388
|
+
paddingRight: 4,
|
|
389
|
+
...isLoading ? { cursor: "wait", pointerEvents: "none" } : {}
|
|
390
|
+
},
|
|
391
|
+
options: {
|
|
392
|
+
count: 2,
|
|
393
|
+
estimateSize,
|
|
394
|
+
getItemKey,
|
|
395
|
+
overscan: lazy ? void 0 : currentOptions.length
|
|
396
|
+
},
|
|
397
|
+
style: {
|
|
398
|
+
maxHeight: rowMinHeight * DEFAULT_DISPLAY_ROW_COUNT,
|
|
399
|
+
...listProps == null ? void 0 : listProps.style
|
|
400
|
+
},
|
|
401
|
+
RowComponent
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
renderBreadcrumbs()
|
|
405
|
+
]
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
};
|
|
409
|
+
export {
|
|
410
|
+
CascaderFloatingContent
|
|
411
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const Cascader:
|
|
1
|
+
import { CascaderProps } from './types';
|
|
2
|
+
export declare const Cascader: ({ ref, ..._props }: CascaderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=cascader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cascader.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/cascader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cascader.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/cascader.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAqBxC,eAAO,MAAM,QAAQ,uBAAwB,aAAa,qDAuJzD,CAAC"}
|
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
import { jsxs, jsx
|
|
2
|
-
import { useRef
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { VirtualizedList } from "../../components/virtualized-list.js";
|
|
7
|
-
import { useWindowScreen } from "../../hooks/use-window-screen/index.js";
|
|
8
|
-
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
9
|
-
import { getResponsiveProp, getSizeVariantState } from "../../utils/index.js";
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { isNil } from "lodash-es";
|
|
4
|
+
import { CascaderFloatingContent } from "./cascader-floating-content.js";
|
|
5
|
+
import { getCascaderProps } from "./helpers.js";
|
|
10
6
|
import ArrowDownIcon from "../../assets/svg/arrow-down.svg.js";
|
|
11
|
-
import ArrowRightIcon from "../../assets/svg/arrow-right.svg.js";
|
|
12
|
-
import CheckIcon from "../../assets/svg/done-check.svg.js";
|
|
13
7
|
import { getColorVar } from "../../theme/palette.js";
|
|
14
8
|
import { getTypographyVar } from "../../theme/typography.js";
|
|
15
|
-
import {
|
|
9
|
+
import { getSizeVariantState } from "../../utils/index.js";
|
|
10
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
11
|
+
import { SvgLoader } from "../../components/svg-loader.js";
|
|
12
|
+
import { Primitive } from "../primitive/primitive.js";
|
|
16
13
|
import { Floating } from "../floating/floating/floating.js";
|
|
17
14
|
import { FloatingTrigger } from "../floating/floating-trigger/floating-trigger.js";
|
|
18
15
|
import { InputMask as ForwardRefInputMask } from "../input-mask/input-mask.js";
|
|
16
|
+
import { truncate } from "../../utils/emotion-helpers.js";
|
|
19
17
|
import { FloatingContent } from "../floating/floating-content/floating-content.js";
|
|
20
|
-
import { Input } from "../input/input.js";
|
|
21
18
|
import { FormHelperText } from "../form-helper-text/form-helper-text.js";
|
|
22
19
|
const DEFAULT_SEPARATOR = "/";
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
ref,
|
|
26
|
-
..._props
|
|
27
|
-
}) => {
|
|
28
|
-
var _a, _b, _c, _d, _e;
|
|
20
|
+
const Cascader = ({ ref, ..._props }) => {
|
|
21
|
+
var _a;
|
|
29
22
|
const {
|
|
30
23
|
placement = "bottom-start",
|
|
31
24
|
open,
|
|
32
25
|
onOpenChange,
|
|
33
26
|
searchable = false,
|
|
34
27
|
value: selectedPath = [],
|
|
28
|
+
valueRenderer,
|
|
35
29
|
options,
|
|
30
|
+
loadOptions,
|
|
36
31
|
onChange,
|
|
37
32
|
placeholder,
|
|
38
33
|
listProps,
|
|
39
|
-
selectedRenderer,
|
|
40
34
|
separator = DEFAULT_SEPARATOR,
|
|
41
35
|
helperText,
|
|
42
36
|
error,
|
|
@@ -47,70 +41,15 @@ const Cascader = ({
|
|
|
47
41
|
menuWidth = "exact-reference",
|
|
48
42
|
...rest
|
|
49
43
|
} = getCascaderProps(_props);
|
|
50
|
-
const searchInputRef = useRef(null);
|
|
51
44
|
const floatingRef = useRef(null);
|
|
52
|
-
const uniqueId = useId();
|
|
53
|
-
const [inputValue, setInputValue] = useControllableState({
|
|
54
|
-
defaultValue: (inputProps == null ? void 0 : inputProps.defaultValue) ?? "",
|
|
55
|
-
value: inputProps == null ? void 0 : inputProps.value
|
|
56
|
-
});
|
|
57
|
-
const windowScreen = useWindowScreen();
|
|
58
45
|
const [isOpen, setIsOpen] = useControllableState({
|
|
59
46
|
defaultValue: open ?? false,
|
|
60
47
|
value: open
|
|
61
48
|
});
|
|
62
|
-
const [expandedPath, setExpandedPath] = useState([]);
|
|
63
49
|
const handleOpenChange = (nextOpen, event, reason) => {
|
|
64
50
|
setIsOpen(nextOpen);
|
|
65
51
|
onOpenChange == null ? void 0 : onOpenChange(nextOpen, event, reason);
|
|
66
|
-
if (!nextOpen) {
|
|
67
|
-
setExpandedPath(selectedPath);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const handleBreadcrumbClick = (e) => {
|
|
71
|
-
const level = Number(e.currentTarget.dataset.index);
|
|
72
|
-
if (level < 0) {
|
|
73
|
-
setExpandedPath([]);
|
|
74
|
-
} else {
|
|
75
|
-
setExpandedPath(expandedPath.slice(0, level + 1));
|
|
76
|
-
}
|
|
77
52
|
};
|
|
78
|
-
const selectedOptions = useMemo(() => {
|
|
79
|
-
return findOptionPath(options, selectedPath);
|
|
80
|
-
}, [options, selectedPath]);
|
|
81
|
-
const expandedOptions = useMemo(() => {
|
|
82
|
-
return findOptionPath(options, expandedPath);
|
|
83
|
-
}, [options, expandedPath]);
|
|
84
|
-
const currentOptions = useMemo(() => {
|
|
85
|
-
var _a2;
|
|
86
|
-
if (expandedPath.length === 0) {
|
|
87
|
-
return options;
|
|
88
|
-
}
|
|
89
|
-
let current = options;
|
|
90
|
-
for (const value of expandedPath) {
|
|
91
|
-
const found = current.find((opt) => opt.value === value);
|
|
92
|
-
if ((_a2 = found == null ? void 0 : found.children) == null ? void 0 : _a2.length) {
|
|
93
|
-
current = found.children;
|
|
94
|
-
} else {
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return current;
|
|
99
|
-
}, [options, expandedPath]);
|
|
100
|
-
const displayOptions = useMemo(() => {
|
|
101
|
-
if (!inputValue) {
|
|
102
|
-
return currentOptions;
|
|
103
|
-
}
|
|
104
|
-
return currentOptions.filter((option) => {
|
|
105
|
-
const searchLabels = ensureArray(option.searchLabel ?? []);
|
|
106
|
-
if (!searchLabels.length && isString(option.label)) {
|
|
107
|
-
searchLabels.push(option.label);
|
|
108
|
-
}
|
|
109
|
-
return matchSearch(searchLabels, inputValue);
|
|
110
|
-
});
|
|
111
|
-
}, [inputValue, currentOptions]);
|
|
112
|
-
const responsiveSize = isNil(windowScreen.name) ? void 0 : getResponsiveProp(rest, "size", windowScreen.name);
|
|
113
|
-
const { inputSize: rowMinHeight = 0, inputPaddingX } = getSizeVariantState(responsiveSize);
|
|
114
53
|
const sizeOptions = {
|
|
115
54
|
apply({ elements }) {
|
|
116
55
|
const { width } = elements.reference.getBoundingClientRect();
|
|
@@ -135,215 +74,8 @@ const Cascader = ({
|
|
|
135
74
|
if (isNil(textVariant)) return {};
|
|
136
75
|
return getTypographyVar(textVariant);
|
|
137
76
|
};
|
|
138
|
-
const onInputChange = (e) => {
|
|
139
|
-
var _a2;
|
|
140
|
-
e.target.value = trimStart(e.target.value);
|
|
141
|
-
setInputValue(e.target.value);
|
|
142
|
-
(_a2 = inputProps == null ? void 0 : inputProps.onChange) == null ? void 0 : _a2.call(inputProps, e);
|
|
143
|
-
};
|
|
144
|
-
const displayValue = useMemo(() => {
|
|
145
|
-
if (selectedOptions.length === 0) return null;
|
|
146
|
-
if (selectedRenderer) {
|
|
147
|
-
return selectedRenderer(selectedOptions);
|
|
148
|
-
}
|
|
149
|
-
return selectedOptions.map((opt, idx) => /* @__PURE__ */ jsxs(
|
|
150
|
-
"div",
|
|
151
|
-
{
|
|
152
|
-
css: { display: "flex", alignItems: "center" },
|
|
153
|
-
children: [
|
|
154
|
-
opt.label,
|
|
155
|
-
idx < selectedOptions.length - 1 && /* @__PURE__ */ jsx("span", { css: { marginLeft: 4, marginRight: 4, opacity: 0.6 }, children: separator })
|
|
156
|
-
]
|
|
157
|
-
},
|
|
158
|
-
`${uniqueId}-${opt.value}`
|
|
159
|
-
));
|
|
160
|
-
}, [selectedOptions, selectedRenderer, separator, uniqueId]);
|
|
161
|
-
useEffect(() => {
|
|
162
|
-
const timer = setTimeout(() => {
|
|
163
|
-
var _a2;
|
|
164
|
-
if (isOpen) {
|
|
165
|
-
(_a2 = searchInputRef.current) == null ? void 0 : _a2.focus();
|
|
166
|
-
setExpandedPath(selectedPath);
|
|
167
|
-
} else {
|
|
168
|
-
setInputValue("");
|
|
169
|
-
}
|
|
170
|
-
}, 100);
|
|
171
|
-
return () => clearTimeout(timer);
|
|
172
|
-
}, [isOpen]);
|
|
173
|
-
const estimateSize = useCallback(
|
|
174
|
-
(_index) => {
|
|
175
|
-
return rowMinHeight ?? 0;
|
|
176
|
-
},
|
|
177
|
-
[rowMinHeight]
|
|
178
|
-
);
|
|
179
|
-
const getItemKey = useCallback(
|
|
180
|
-
(index) => {
|
|
181
|
-
const option = displayOptions.at(index);
|
|
182
|
-
return option ? option.value : `${uniqueId}-${index}`;
|
|
183
|
-
},
|
|
184
|
-
[displayOptions, uniqueId]
|
|
185
|
-
);
|
|
186
|
-
const renderBreadcrumbs = () => {
|
|
187
|
-
if (expandedPath.length === 0) return null;
|
|
188
|
-
return /* @__PURE__ */ jsxs(
|
|
189
|
-
"div",
|
|
190
|
-
{
|
|
191
|
-
css: {
|
|
192
|
-
paddingLeft: inputPaddingX,
|
|
193
|
-
paddingRight: inputPaddingX,
|
|
194
|
-
minHeight: rowMinHeight,
|
|
195
|
-
borderTop: "1px solid",
|
|
196
|
-
borderColor: getColorVar("neutral.200"),
|
|
197
|
-
display: "flex",
|
|
198
|
-
alignItems: "center",
|
|
199
|
-
gap: 4,
|
|
200
|
-
flexWrap: "wrap",
|
|
201
|
-
paddingTop: 4,
|
|
202
|
-
paddingBottom: 4
|
|
203
|
-
},
|
|
204
|
-
children: [
|
|
205
|
-
/* @__PURE__ */ jsx(
|
|
206
|
-
"button",
|
|
207
|
-
{
|
|
208
|
-
"data-index": -1,
|
|
209
|
-
type: "button",
|
|
210
|
-
onClick: handleBreadcrumbClick,
|
|
211
|
-
css: {
|
|
212
|
-
color: getColorVar("neutral.500"),
|
|
213
|
-
":hover": { color: getColorVar("primary.600") },
|
|
214
|
-
transition: "color 150ms"
|
|
215
|
-
},
|
|
216
|
-
children: "All"
|
|
217
|
-
}
|
|
218
|
-
),
|
|
219
|
-
expandedOptions.map((opt, idx) => /* @__PURE__ */ jsxs(
|
|
220
|
-
"div",
|
|
221
|
-
{
|
|
222
|
-
css: { display: "flex", alignItems: "center", gap: 4 },
|
|
223
|
-
children: [
|
|
224
|
-
/* @__PURE__ */ jsx("span", { css: { color: getColorVar("neutral.400") }, children: separator }),
|
|
225
|
-
/* @__PURE__ */ jsx(
|
|
226
|
-
"button",
|
|
227
|
-
{
|
|
228
|
-
"data-index": idx,
|
|
229
|
-
type: "button",
|
|
230
|
-
onClick: handleBreadcrumbClick,
|
|
231
|
-
css: {
|
|
232
|
-
color: getColorVar("neutral.600"),
|
|
233
|
-
":hover": { color: getColorVar("primary.600") },
|
|
234
|
-
transition: "color 150ms",
|
|
235
|
-
...idx === expandedOptions.length - 1 ? {
|
|
236
|
-
color: getColorVar("primary.600"),
|
|
237
|
-
fontWeight: 500
|
|
238
|
-
} : {}
|
|
239
|
-
},
|
|
240
|
-
children: opt.breadcrumbLabel ?? opt.label
|
|
241
|
-
}
|
|
242
|
-
)
|
|
243
|
-
]
|
|
244
|
-
},
|
|
245
|
-
`${uniqueId}-breadcrumb-${opt.value}`
|
|
246
|
-
))
|
|
247
|
-
]
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
};
|
|
251
|
-
const RowComponent = ({ row }) => {
|
|
252
|
-
const rowData = displayOptions.at(row.index);
|
|
253
|
-
if (isNil(rowData)) return /* @__PURE__ */ jsx(Fragment, {});
|
|
254
|
-
const isSelected = selectedPath.includes(rowData.value);
|
|
255
|
-
const handleSelect = () => {
|
|
256
|
-
var _a2, _b2, _c2, _d2;
|
|
257
|
-
if (rowData.disabled) return;
|
|
258
|
-
const parentPath = [];
|
|
259
|
-
let current = options;
|
|
260
|
-
for (const value of expandedPath) {
|
|
261
|
-
const found = current.find((opt) => opt.value === value);
|
|
262
|
-
if ((_a2 = found == null ? void 0 : found.children) == null ? void 0 : _a2.length) {
|
|
263
|
-
parentPath.push(value);
|
|
264
|
-
current = found.children;
|
|
265
|
-
} else {
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
const newPath = [...parentPath, rowData.value];
|
|
270
|
-
const newSelectedOptions = findOptionPath(options, newPath);
|
|
271
|
-
if (hasChildren(rowData)) {
|
|
272
|
-
setExpandedPath(newPath);
|
|
273
|
-
} else {
|
|
274
|
-
onChange == null ? void 0 : onChange(newPath, newSelectedOptions);
|
|
275
|
-
(_d2 = (_b2 = floatingRef.current) == null ? void 0 : (_c2 = _b2.context).onOpenChange) == null ? void 0 : _d2.call(_c2, false);
|
|
276
|
-
}
|
|
277
|
-
setInputValue("");
|
|
278
|
-
setTimeout(() => {
|
|
279
|
-
var _a3;
|
|
280
|
-
(_a3 = searchInputRef.current) == null ? void 0 : _a3.focus();
|
|
281
|
-
});
|
|
282
|
-
};
|
|
283
|
-
return /* @__PURE__ */ jsxs(
|
|
284
|
-
"div",
|
|
285
|
-
{
|
|
286
|
-
"aria-hidden": true,
|
|
287
|
-
onClick: handleSelect,
|
|
288
|
-
css: {
|
|
289
|
-
minHeight: rowMinHeight,
|
|
290
|
-
paddingLeft: inputPaddingX,
|
|
291
|
-
paddingRight: inputPaddingX,
|
|
292
|
-
paddingTop: 4,
|
|
293
|
-
paddingBottom: 4,
|
|
294
|
-
display: "flex",
|
|
295
|
-
alignItems: "center",
|
|
296
|
-
gap: 8,
|
|
297
|
-
cursor: "pointer",
|
|
298
|
-
borderRadius: 8,
|
|
299
|
-
":hover": { backgroundColor: getColorVar("neutral.100") },
|
|
300
|
-
transition: "color 150ms, background-color 150ms",
|
|
301
|
-
...isSelected && !hasChildren(rowData) ? {
|
|
302
|
-
color: getColorVar("primary.600"),
|
|
303
|
-
backgroundColor: getColorVar("primary.100")
|
|
304
|
-
} : {},
|
|
305
|
-
...rowData.disabled ? {
|
|
306
|
-
opacity: 0.5,
|
|
307
|
-
cursor: "not-allowed"
|
|
308
|
-
} : {}
|
|
309
|
-
},
|
|
310
|
-
children: [
|
|
311
|
-
/* @__PURE__ */ jsx(
|
|
312
|
-
"div",
|
|
313
|
-
{
|
|
314
|
-
css: {
|
|
315
|
-
flex: 1,
|
|
316
|
-
overflow: "hidden",
|
|
317
|
-
textOverflow: "ellipsis",
|
|
318
|
-
whiteSpace: "nowrap"
|
|
319
|
-
},
|
|
320
|
-
children: rowData.label
|
|
321
|
-
}
|
|
322
|
-
),
|
|
323
|
-
hasChildren(rowData) ? /* @__PURE__ */ jsx(
|
|
324
|
-
SvgLoader,
|
|
325
|
-
{
|
|
326
|
-
source: ArrowRightIcon,
|
|
327
|
-
width: 20,
|
|
328
|
-
height: 20,
|
|
329
|
-
css: { color: getColorVar("neutral.400") }
|
|
330
|
-
}
|
|
331
|
-
) : isSelected && /* @__PURE__ */ jsx(
|
|
332
|
-
SvgLoader,
|
|
333
|
-
{
|
|
334
|
-
source: CheckIcon,
|
|
335
|
-
width: 20,
|
|
336
|
-
height: 20,
|
|
337
|
-
css: { color: getColorVar("primary.600") }
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
]
|
|
341
|
-
},
|
|
342
|
-
`${uniqueId}-option-${rowData.value}`
|
|
343
|
-
);
|
|
344
|
-
};
|
|
345
77
|
return /* @__PURE__ */ jsxs(
|
|
346
|
-
|
|
78
|
+
Primitive,
|
|
347
79
|
{
|
|
348
80
|
...containerProps,
|
|
349
81
|
css: {
|
|
@@ -351,6 +83,7 @@ const Cascader = ({
|
|
|
351
83
|
flexDirection: "column",
|
|
352
84
|
...fullWidth ? { width: "100%" } : {}
|
|
353
85
|
},
|
|
86
|
+
as: "div",
|
|
354
87
|
children: [
|
|
355
88
|
/* @__PURE__ */ jsxs(
|
|
356
89
|
Floating,
|
|
@@ -394,94 +127,31 @@ const Cascader = ({
|
|
|
394
127
|
{
|
|
395
128
|
flex: 1,
|
|
396
129
|
textAlign: "left",
|
|
397
|
-
|
|
398
|
-
textOverflow: "ellipsis",
|
|
399
|
-
whiteSpace: "nowrap"
|
|
130
|
+
...truncate
|
|
400
131
|
},
|
|
401
132
|
getTextCss((_a = rest.xs) == null ? void 0 : _a.size)
|
|
402
133
|
],
|
|
403
|
-
children:
|
|
404
|
-
"div",
|
|
405
|
-
{
|
|
406
|
-
css: {
|
|
407
|
-
display: "flex",
|
|
408
|
-
alignItems: "center",
|
|
409
|
-
flexWrap: "wrap"
|
|
410
|
-
},
|
|
411
|
-
children: displayValue
|
|
412
|
-
}
|
|
413
|
-
) : /* @__PURE__ */ jsx(
|
|
414
|
-
"span",
|
|
415
|
-
{
|
|
416
|
-
css: { color: getColorVar("neutral.400"), display: "block" },
|
|
417
|
-
children: placeholder
|
|
418
|
-
}
|
|
419
|
-
)
|
|
134
|
+
children: selectedPath.length > 0 ? /* @__PURE__ */ jsx("div", { children: valueRenderer ?? selectedPath.join(" / ") }) : /* @__PURE__ */ jsx("div", { css: { color: getColorVar("neutral.400") }, children: placeholder })
|
|
420
135
|
}
|
|
421
136
|
)
|
|
422
137
|
}
|
|
423
138
|
) }),
|
|
424
|
-
/* @__PURE__ */ jsx(FloatingContent, { children: /* @__PURE__ */
|
|
425
|
-
|
|
139
|
+
/* @__PURE__ */ jsx(FloatingContent, { children: /* @__PURE__ */ jsx(
|
|
140
|
+
CascaderFloatingContent,
|
|
426
141
|
{
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
"div",
|
|
441
|
-
{
|
|
442
|
-
css: {
|
|
443
|
-
paddingLeft: 8,
|
|
444
|
-
paddingRight: 8,
|
|
445
|
-
paddingTop: 8,
|
|
446
|
-
paddingBottom: 8,
|
|
447
|
-
borderColor: getColorVar("neutral.200")
|
|
448
|
-
},
|
|
449
|
-
children: /* @__PURE__ */ jsx(
|
|
450
|
-
Input,
|
|
451
|
-
{
|
|
452
|
-
xs: { size: (_b = rest.xs) == null ? void 0 : _b.size },
|
|
453
|
-
sm: { size: (_c = rest.sm) == null ? void 0 : _c.size },
|
|
454
|
-
md: { size: (_d = rest.md) == null ? void 0 : _d.size },
|
|
455
|
-
lg: { size: (_e = rest.lg) == null ? void 0 : _e.size },
|
|
456
|
-
value: inputValue,
|
|
457
|
-
placeholder: "Search...",
|
|
458
|
-
...inputProps,
|
|
459
|
-
onChange: onInputChange,
|
|
460
|
-
ref: searchInputRef
|
|
461
|
-
}
|
|
462
|
-
)
|
|
463
|
-
}
|
|
464
|
-
),
|
|
465
|
-
/* @__PURE__ */ jsx(
|
|
466
|
-
VirtualizedList,
|
|
467
|
-
{
|
|
468
|
-
...listProps,
|
|
469
|
-
css: { paddingLeft: 4, paddingRight: 4 },
|
|
470
|
-
options: {
|
|
471
|
-
count: displayOptions.length,
|
|
472
|
-
estimateSize,
|
|
473
|
-
getItemKey,
|
|
474
|
-
overscan: lazy ? void 0 : currentOptions.length
|
|
475
|
-
},
|
|
476
|
-
style: {
|
|
477
|
-
maxHeight: rowMinHeight * DEFAULT_DISPLAY_ROW_COUNT,
|
|
478
|
-
...listProps == null ? void 0 : listProps.style
|
|
479
|
-
},
|
|
480
|
-
RowComponent
|
|
481
|
-
}
|
|
482
|
-
),
|
|
483
|
-
renderBreadcrumbs()
|
|
484
|
-
]
|
|
142
|
+
searchable,
|
|
143
|
+
selectedPath,
|
|
144
|
+
options,
|
|
145
|
+
loadOptions,
|
|
146
|
+
onChange,
|
|
147
|
+
inputProps,
|
|
148
|
+
listProps,
|
|
149
|
+
separator,
|
|
150
|
+
lazy,
|
|
151
|
+
xs: rest.xs,
|
|
152
|
+
sm: rest.sm,
|
|
153
|
+
md: rest.md,
|
|
154
|
+
lg: rest.lg
|
|
485
155
|
}
|
|
486
156
|
) })
|
|
487
157
|
]
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { CascaderOption,
|
|
2
|
-
export declare const getCascaderProps:
|
|
1
|
+
import { CascaderOption, CascaderProps } from './types';
|
|
2
|
+
export declare const getCascaderProps: (extended: CascaderProps) => CascaderProps;
|
|
3
3
|
/**
|
|
4
4
|
* Find option path by value array
|
|
5
5
|
* Returns array of options from root to target
|
|
6
6
|
*/
|
|
7
|
-
export declare const findOptionPath:
|
|
7
|
+
export declare const findOptionPath: (options: CascaderOption[], values: string[]) => CascaderOption[];
|
|
8
8
|
/**
|
|
9
|
-
* Check if option has children
|
|
9
|
+
* Check if option has children already loaded
|
|
10
10
|
*/
|
|
11
|
-
export declare const hasChildren:
|
|
11
|
+
export declare const hasChildren: (option: CascaderOption) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check if option can be expanded (has children or is not a leaf and can lazy load)
|
|
14
|
+
*/
|
|
15
|
+
export declare const isExpandable: (option: CascaderOption) => boolean;
|
|
12
16
|
/**
|
|
13
17
|
* Filter options by search text
|
|
14
18
|
*/
|
|
15
|
-
export declare const filterOptions:
|
|
19
|
+
export declare const filterOptions: (options: CascaderOption[], searchText: string) => CascaderOption[];
|
|
16
20
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAUxD,eAAO,MAAM,gBAAgB,aAAc,aAAa,kBAEvD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,YAAa,cAAc,EAAE,UAAU,MAAM,EAAE,KAAG,cAAc,EAY1F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,WAAY,cAAc,KAAG,OAEpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,WAAY,cAAc,KAAG,OAKrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,YAAa,cAAc,EAAE,cAAc,MAAM,KAAG,cAAc,EA2B3F,CAAC"}
|
|
@@ -14,15 +14,21 @@ const findOptionPath = (options, values) => {
|
|
|
14
14
|
const found = currentOptions.find((opt) => opt.value === value);
|
|
15
15
|
if (!found) break;
|
|
16
16
|
result.push(found);
|
|
17
|
-
currentOptions = found.children
|
|
17
|
+
currentOptions = found.children ?? [];
|
|
18
18
|
}
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
const hasChildren = (option) => {
|
|
22
22
|
return Array.isArray(option.children) && option.children.length > 0;
|
|
23
23
|
};
|
|
24
|
+
const isExpandable = (option) => {
|
|
25
|
+
if (option.isLeaf === true) return false;
|
|
26
|
+
if (hasChildren(option)) return true;
|
|
27
|
+
return option.isLeaf === false;
|
|
28
|
+
};
|
|
24
29
|
export {
|
|
25
30
|
findOptionPath,
|
|
26
31
|
getCascaderProps,
|
|
27
|
-
hasChildren
|
|
32
|
+
hasChildren,
|
|
33
|
+
isExpandable
|
|
28
34
|
};
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { HTMLAttributes, JSX } from 'react';
|
|
1
|
+
import { HTMLAttributes, JSX, ReactNode } from 'react';
|
|
2
2
|
import { Placement, UseFloatingOptions } from '@floating-ui/react';
|
|
3
|
+
import { ResponsiveDesign } from '@janbox/storefront-ui/types';
|
|
3
4
|
import { InputProps } from '../input';
|
|
4
5
|
import { InputMaskProps, InputMaskResponsiveProps } from '../input-mask/types';
|
|
5
|
-
import {
|
|
6
|
+
import { ShallowMerge } from '../../types';
|
|
6
7
|
import { PrimitiveProps } from '../primitive';
|
|
7
8
|
export type CascaderResponsiveProps = InputMaskResponsiveProps;
|
|
8
9
|
export type CascaderOptionValue = string | number;
|
|
9
|
-
export interface CascaderOption
|
|
10
|
-
|
|
10
|
+
export interface CascaderOption {
|
|
11
|
+
metadata?: Record<string, any>;
|
|
12
|
+
value: string;
|
|
11
13
|
label: React.ReactNode;
|
|
12
14
|
breadcrumbLabel?: React.ReactNode;
|
|
13
15
|
searchLabel?: string | string[];
|
|
14
16
|
disabled?: boolean;
|
|
15
|
-
children?: CascaderOption
|
|
17
|
+
children?: CascaderOption[];
|
|
18
|
+
/** When true, this option is a leaf node and cannot be expanded. When false, it can be expanded even without children loaded yet. */
|
|
19
|
+
isLeaf?: boolean;
|
|
16
20
|
}
|
|
17
|
-
interface CascaderExtendedProps
|
|
21
|
+
interface CascaderExtendedProps extends ResponsiveDesign<CascaderResponsiveProps> {
|
|
18
22
|
/** Placement of the dropdown */
|
|
19
23
|
placement?: Placement;
|
|
20
24
|
/** Callback when dropdown open state changes */
|
|
@@ -25,17 +29,19 @@ interface CascaderExtendedProps<V extends CascaderOptionValue, O extends Cascade
|
|
|
25
29
|
searchable?: boolean;
|
|
26
30
|
/** Default selected path (array of values from root to leaf) */
|
|
27
31
|
/** Controlled selected path */
|
|
28
|
-
value?:
|
|
32
|
+
value?: string[];
|
|
33
|
+
valueRenderer?: ReactNode;
|
|
29
34
|
/** Tree options data */
|
|
30
|
-
options:
|
|
35
|
+
options: CascaderOption[];
|
|
36
|
+
/** Async function to load children. Receives the current expanded path as an array of selected options from root to the clicked node. */
|
|
37
|
+
loadOptions?: (tree: CascaderOption[]) => Promise<CascaderOption[]>;
|
|
31
38
|
/** Callback when selection changes */
|
|
32
|
-
onChange?: (value:
|
|
39
|
+
onChange?: (value: string[], selectedOptions: CascaderOption[]) => void;
|
|
33
40
|
/** Placeholder text */
|
|
34
41
|
placeholder?: string;
|
|
35
42
|
/** Props for the options list container */
|
|
36
43
|
listProps?: HTMLAttributes<HTMLDivElement>;
|
|
37
44
|
/** Custom renderer for selected value display */
|
|
38
|
-
selectedRenderer?: (selectedOptions: O[]) => React.ReactNode;
|
|
39
45
|
/** Separator for displaying selected path */
|
|
40
46
|
separator?: React.ReactNode;
|
|
41
47
|
/** Show error state */
|
|
@@ -53,6 +59,6 @@ interface CascaderExtendedProps<V extends CascaderOptionValue, O extends Cascade
|
|
|
53
59
|
/** Width of the menu */
|
|
54
60
|
menuWidth?: number | 'exact-reference' | 'min-reference';
|
|
55
61
|
}
|
|
56
|
-
export type CascaderProps
|
|
62
|
+
export type CascaderProps = ShallowMerge<InputMaskProps<JSX.IntrinsicElements['button']>, CascaderExtendedProps>;
|
|
57
63
|
export {};
|
|
58
64
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/cascader/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAE/D,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,qIAAqI;IACrI,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,qBAAsB,SAAQ,gBAAgB,CAAC,uBAAuB,CAAC;IAC/E,gCAAgC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gDAAgD;IAChD,YAAY,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAClD,4BAA4B;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gEAAgE;IAChE,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,wBAAwB;IACxB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,yIAAyI;IACzI,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACpE,sCAAsC;IACtC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IACxE,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC3C,iDAAiD;IACjD,6CAA6C;IAC7C,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,uBAAuB;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,cAAc,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,iCAAiC;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,yCAAyC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,eAAe,CAAC;CAC1D;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSObject } from '@emotion/serialize';
|
|
2
2
|
import { Screen } from '../theme';
|
|
3
|
+
import type * as CSS from "csstype";
|
|
3
4
|
export type Nullable<T> = T | null;
|
|
4
5
|
export type Dict<T> = Record<string, T>;
|
|
5
6
|
export type ShallowMerge<T1, T2> = Omit<T1, keyof T2> & T2;
|
|
@@ -11,7 +12,17 @@ export type ProgressDirection = "horizontal" | "vertical";
|
|
|
11
12
|
export type ContentTranslation = {
|
|
12
13
|
key: string;
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Stricter version of Emotion's CSSObject.
|
|
17
|
+
*
|
|
18
|
+
* Overrides all standard CSS properties with `CSS.Properties` from csstype
|
|
19
|
+
* so values only accept `string | number`, never an array.
|
|
20
|
+
* Pseudos and nested selectors also recurse through StrictCSSObject.
|
|
21
|
+
*/
|
|
22
|
+
export type StyledCSS = Omit<CSSObject, keyof CSS.Properties | keyof CSS.Pseudos> & CSS.Properties<number | string> & {
|
|
23
|
+
[K in CSS.Pseudos]?: StyledCSS;
|
|
24
|
+
};
|
|
14
25
|
export type PropsWithCSS<T extends object = object> = T & {
|
|
15
|
-
css?:
|
|
26
|
+
css?: StyledCSS;
|
|
16
27
|
};
|
|
17
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEnC,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAExC,MAAM,MAAM,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;AAE3D,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpD,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,WAAW,GACX,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG;IACxD,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,KAAK,GAAG,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEnC,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAExC,MAAM,MAAM,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;AAE3D,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvE,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpD,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,WAAW,GACX,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;GAMG;AAEH,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,SAAS,EACT,MAAM,GAAG,CAAC,UAAU,GAAG,MAAM,GAAG,CAAC,OAAO,CACzC,GACC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS;CAAE,CAAC;AAEvE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG;IACxD,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB,CAAC"}
|