@jbpark/ui-kit 10.0.2 → 10.1.0
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/README.ko.md +7 -0
- package/README.md +7 -0
- package/dist/Breadcrumb.d.mts +39 -0
- package/dist/Breadcrumb.d.mts.map +1 -0
- package/dist/Breadcrumb.mjs +103 -0
- package/dist/Breadcrumb.mjs.map +1 -0
- package/dist/Pagination.d.mts +53 -0
- package/dist/Pagination.d.mts.map +1 -0
- package/dist/Pagination.mjs +208 -0
- package/dist/Pagination.mjs.map +1 -0
- package/dist/Table.d.mts +48 -0
- package/dist/Table.d.mts.map +1 -0
- package/dist/Table.mjs +119 -0
- package/dist/Table.mjs.map +1 -0
- package/dist/components/atoms/checkbox/checkbox.mjs +2 -1
- package/dist/components/atoms/checkbox/checkbox.mjs.map +1 -1
- package/dist/components/atoms/checkbox/group.mjs +2 -1
- package/dist/components/atoms/checkbox/group.mjs.map +1 -1
- package/dist/components/atoms/color-picker.mjs +1 -1
- package/dist/components/atoms/date-picker.mjs +1 -1
- package/dist/components/atoms/float-button/back-top.mjs +1 -1
- package/dist/components/atoms/index.d.mts +2 -1
- package/dist/components/atoms/input/search.mjs +3 -1
- package/dist/components/atoms/input/search.mjs.map +1 -1
- package/dist/components/atoms/popover.mjs +1 -1
- package/dist/components/atoms/radio/group.mjs +1 -1
- package/dist/components/atoms/radio/radio.mjs +2 -1
- package/dist/components/atoms/radio/radio.mjs.map +1 -1
- package/dist/components/atoms/select-multiple.d.mts +29 -0
- package/dist/components/atoms/select-multiple.d.mts.map +1 -0
- package/dist/components/atoms/select-multiple.mjs +97 -0
- package/dist/components/atoms/select-multiple.mjs.map +1 -0
- package/dist/components/atoms/select-searchable-options.d.mts +21 -0
- package/dist/components/atoms/select-searchable-options.d.mts.map +1 -0
- package/dist/components/atoms/select-searchable-options.mjs +62 -0
- package/dist/components/atoms/select-searchable-options.mjs.map +1 -0
- package/dist/components/atoms/select-searchable.d.mts +22 -0
- package/dist/components/atoms/select-searchable.d.mts.map +1 -0
- package/dist/components/atoms/select-searchable.mjs +65 -0
- package/dist/components/atoms/select-searchable.mjs.map +1 -0
- package/dist/components/atoms/select.d.mts +8 -2
- package/dist/components/atoms/select.d.mts.map +1 -1
- package/dist/components/atoms/select.mjs +11 -1
- package/dist/components/atoms/select.mjs.map +1 -1
- package/dist/components/atoms/slider/slider.mjs +1 -1
- package/dist/components/atoms/switch.mjs +1 -1
- package/dist/components/atoms/tooltip.d.mts +21 -0
- package/dist/components/atoms/tooltip.d.mts.map +1 -0
- package/dist/components/atoms/tooltip.mjs +78 -0
- package/dist/components/atoms/tooltip.mjs.map +1 -0
- package/dist/components/atoms/typography/paragraph.mjs +1 -0
- package/dist/components/atoms/typography/paragraph.mjs.map +1 -1
- package/dist/components/atoms/typography/title.mjs +1 -0
- package/dist/components/atoms/typography/title.mjs.map +1 -1
- package/dist/components/molecules/dropdown.mjs +1 -1
- package/dist/components/molecules/index.d.mts +13 -10
- package/dist/components/molecules/marquees/marquees.mjs +1 -1
- package/dist/components/molecules/menu/menu.mjs +2 -1
- package/dist/components/molecules/menu/menu.mjs.map +1 -1
- package/dist/components/molecules/tabs.d.mts +37 -0
- package/dist/components/molecules/tabs.d.mts.map +1 -0
- package/dist/components/molecules/tabs.mjs +51 -0
- package/dist/components/molecules/tabs.mjs.map +1 -0
- package/dist/components/molecules/upload.mjs +2 -1
- package/dist/components/molecules/upload.mjs.map +1 -1
- package/dist/components/organisms/drawer.d.mts.map +1 -1
- package/dist/components/organisms/drawer.mjs +7 -2
- package/dist/components/organisms/drawer.mjs.map +1 -1
- package/dist/components/organisms/index.d.mts +6 -5
- package/dist/components/organisms/list/list.mjs +1 -1
- package/dist/components/organisms/modal.d.mts.map +1 -1
- package/dist/components/organisms/modal.mjs +7 -4
- package/dist/components/organisms/modal.mjs.map +1 -1
- package/dist/components/organisms/toast.d.mts.map +1 -1
- package/dist/components/organisms/toast.mjs +2 -1
- package/dist/components/organisms/toast.mjs.map +1 -1
- package/dist/components/templates/empty.mjs +1 -0
- package/dist/components/templates/empty.mjs.map +1 -1
- package/dist/components/templates/layout/content.mjs +1 -0
- package/dist/components/templates/layout/content.mjs.map +1 -1
- package/dist/components/templates/layout/footer.mjs +1 -0
- package/dist/components/templates/layout/footer.mjs.map +1 -1
- package/dist/components/templates/layout/header.mjs +1 -0
- package/dist/components/templates/layout/header.mjs.map +1 -1
- package/dist/components/templates/layout/layout.mjs +1 -0
- package/dist/components/templates/layout/layout.mjs.map +1 -1
- package/dist/components/templates/layout/sider.mjs +3 -1
- package/dist/components/templates/layout/sider.mjs.map +1 -1
- package/dist/components/templates/page-header.mjs +1 -0
- package/dist/components/templates/page-header.mjs.map +1 -1
- package/dist/components/templates/result.mjs +1 -0
- package/dist/components/templates/result.mjs.map +1 -1
- package/dist/core/badge.d.mts +1 -1
- package/dist/core/button.d.mts +2 -2
- package/dist/core/combobox.d.mts +7 -0
- package/dist/core/combobox.d.mts.map +1 -0
- package/dist/core/combobox.mjs +99 -0
- package/dist/core/combobox.mjs.map +1 -0
- package/dist/core/dialog.mjs.map +1 -1
- package/dist/core/drawer.mjs.map +1 -1
- package/dist/core/field.mjs +2 -4
- package/dist/core/field.mjs.map +1 -1
- package/dist/core/index.d.mts +4 -1
- package/dist/core/select.mjs +27 -22
- package/dist/core/select.mjs.map +1 -1
- package/dist/core/tabs.d.mts +9 -0
- package/dist/core/tabs.d.mts.map +1 -0
- package/dist/core/tabs.mjs +59 -0
- package/dist/core/tabs.mjs.map +1 -0
- package/dist/core/tooltip.d.mts +2 -0
- package/dist/core/tooltip.mjs +41 -0
- package/dist/core/tooltip.mjs.map +1 -0
- package/dist/index.d.mts +31 -26
- package/dist/index.mjs +7 -2
- package/dist/lib/z-layers.mjs +21 -0
- package/dist/lib/z-layers.mjs.map +1 -1
- package/dist/providers/config/dark-mode.mjs +2 -10
- package/dist/providers/config/dark-mode.mjs.map +1 -1
- package/dist/style.css +195 -16
- package/package.json +17 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { combobox_exports } from "../../core/combobox.mjs";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/atoms/select-searchable-options.tsx
|
|
6
|
+
const { ComboboxCollection, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxItem, ComboboxList, createItems } = combobox_exports;
|
|
7
|
+
const isGroup = (option) => {
|
|
8
|
+
return "options" in option && Array.isArray(option.options);
|
|
9
|
+
};
|
|
10
|
+
const useSelectItems = (options) => {
|
|
11
|
+
const groups = useMemo(() => {
|
|
12
|
+
const result = [];
|
|
13
|
+
options.forEach((option, index) => {
|
|
14
|
+
if (isGroup(option)) result.push({
|
|
15
|
+
key: index,
|
|
16
|
+
value: option.label,
|
|
17
|
+
items: option.options,
|
|
18
|
+
grouped: true
|
|
19
|
+
});
|
|
20
|
+
else {
|
|
21
|
+
const previous = result.at(-1);
|
|
22
|
+
if (previous && !previous.grouped) previous.items.push(option);
|
|
23
|
+
else result.push({
|
|
24
|
+
key: index,
|
|
25
|
+
value: "",
|
|
26
|
+
items: [option],
|
|
27
|
+
grouped: false
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
}, [options]);
|
|
33
|
+
return useMemo(() => createItems(groups, {
|
|
34
|
+
getValue: (option) => option.value,
|
|
35
|
+
getLabel: (option) => option.label
|
|
36
|
+
}), [groups]);
|
|
37
|
+
};
|
|
38
|
+
const SearchableOptions = ({ emptyText, classNames }) => {
|
|
39
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ComboboxEmpty, {
|
|
40
|
+
className: classNames?.empty,
|
|
41
|
+
children: emptyText
|
|
42
|
+
}), /* @__PURE__ */ jsx(ComboboxList, {
|
|
43
|
+
className: classNames?.list,
|
|
44
|
+
children: (group) => /* @__PURE__ */ jsxs(ComboboxGroup, {
|
|
45
|
+
items: group.items,
|
|
46
|
+
children: [group.grouped && /* @__PURE__ */ jsx(ComboboxGroupLabel, {
|
|
47
|
+
"data-slot": "combobox-group-label",
|
|
48
|
+
className: "text-muted-foreground px-2 py-1.5 text-xs",
|
|
49
|
+
children: group.value
|
|
50
|
+
}), /* @__PURE__ */ jsx(ComboboxCollection, { children: (option) => /* @__PURE__ */ jsx(ComboboxItem, {
|
|
51
|
+
value: option.value,
|
|
52
|
+
disabled: option.disabled,
|
|
53
|
+
className: classNames?.item,
|
|
54
|
+
children: option.label
|
|
55
|
+
}, option.value) })]
|
|
56
|
+
}, group.key)
|
|
57
|
+
})] });
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { SearchableOptions as default, useSelectItems };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=select-searchable-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-searchable-options.mjs","names":["combobox"],"sources":["../../../src/components/atoms/select-searchable-options.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, useMemo } from 'react';\n\nimport { combobox } from '../../core';\n\nconst {\n ComboboxCollection,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxGroupLabel,\n ComboboxItem,\n ComboboxList,\n createItems,\n} = combobox;\n\nexport interface Option {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\nexport interface OptionGroup {\n label: string;\n options: Option[];\n}\n\nexport interface ClassNames {\n input?: string;\n content?: string;\n list?: string;\n item?: string;\n empty?: string;\n}\n\ninterface ItemsGroup {\n key: number;\n value: string;\n items: Option[];\n grouped: boolean;\n}\n\nconst isGroup = (option: Option | OptionGroup): option is OptionGroup => {\n return 'options' in option && Array.isArray(option.options);\n};\n\nexport const useSelectItems = (options: (Option | OptionGroup)[]) => {\n const groups = useMemo(() => {\n const result: ItemsGroup[] = [];\n\n options.forEach((option, index) => {\n if (isGroup(option)) {\n result.push({\n key: index,\n value: option.label,\n items: option.options,\n grouped: true,\n });\n } else {\n const previous = result.at(-1);\n\n if (previous && !previous.grouped) {\n previous.items.push(option);\n } else {\n result.push({\n key: index,\n value: '',\n items: [option],\n grouped: false,\n });\n }\n }\n });\n\n return result;\n }, [options]);\n const items = useMemo(\n () =>\n createItems<Option, string>(groups, {\n getValue: option => option.value,\n getLabel: option => option.label,\n }),\n [groups],\n );\n\n return items;\n};\n\ninterface Props {\n emptyText: ReactNode;\n classNames?: ClassNames;\n}\n\nconst SearchableOptions = ({ emptyText, classNames }: Props) => {\n return (\n <>\n <ComboboxEmpty className={classNames?.empty}>{emptyText}</ComboboxEmpty>\n <ComboboxList className={classNames?.list}>\n {(group: ItemsGroup) => (\n <ComboboxGroup key={group.key} items={group.items}>\n {group.grouped && (\n <ComboboxGroupLabel\n data-slot=\"combobox-group-label\"\n className=\"text-muted-foreground px-2 py-1.5 text-xs\"\n >\n {group.value}\n </ComboboxGroupLabel>\n )}\n <ComboboxCollection>\n {(option: Option) => (\n <ComboboxItem\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n className={classNames?.item}\n >\n {option.label}\n </ComboboxItem>\n )}\n </ComboboxCollection>\n </ComboboxGroup>\n )}\n </ComboboxList>\n </>\n );\n};\n\nexport default SearchableOptions;\n"],"mappings":";;;;;AAMA,MAAM,EACJ,oBACA,eACA,eACA,oBACA,cACA,cACA,gBACEA;AA4BJ,MAAM,WAAW,WAAwD;CACvE,OAAO,aAAa,UAAU,MAAM,QAAQ,OAAO,OAAO;AAC5D;AAEA,MAAa,kBAAkB,YAAsC;CACnE,MAAM,SAAS,cAAc;EAC3B,MAAM,SAAuB,CAAC;EAE9B,QAAQ,SAAS,QAAQ,UAAU;GACjC,IAAI,QAAQ,MAAM,GAChB,OAAO,KAAK;IACV,KAAK;IACL,OAAO,OAAO;IACd,OAAO,OAAO;IACd,SAAS;GACX,CAAC;QACI;IACL,MAAM,WAAW,OAAO,GAAG,EAAE;IAE7B,IAAI,YAAY,CAAC,SAAS,SACxB,SAAS,MAAM,KAAK,MAAM;SAE1B,OAAO,KAAK;KACV,KAAK;KACL,OAAO;KACP,OAAO,CAAC,MAAM;KACd,SAAS;IACX,CAAC;GAEL;EACF,CAAC;EAED,OAAO;CACT,GAAG,CAAC,OAAO,CAAC;CAUZ,OATc,cAEV,YAA4B,QAAQ;EAClC,WAAU,WAAU,OAAO;EAC3B,WAAU,WAAU,OAAO;CAC7B,CAAC,GACH,CAAC,MAAM,CAGE;AACb;AAOA,MAAM,qBAAqB,EAAE,WAAW,iBAAwB;CAC9D,OACE,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,eAAD;EAAe,WAAW,YAAY;EAAQ,UAAA;CAAyB,CAAA,GACvE,oBAAC,cAAD;EAAc,WAAW,YAAY;EACjC,WAAA,UACA,qBAAC,eAAD;GAA+B,OAAO,MAAM;GAA5C,UAAA,CACG,MAAM,WACL,oBAAC,oBAAD;IACE,aAAU;IACV,WAAU;IAET,UAAA,MAAM;GACW,CAAA,GAEtB,oBAAC,oBAAD,EAAA,WACI,WACA,oBAAC,cAAD;IAEE,OAAO,OAAO;IACd,UAAU,OAAO;IACjB,WAAW,YAAY;IAEtB,UAAA,OAAO;GACI,GANP,OAAO,KAMA,EAEE,CAAA,CACP;EArBK,GAAA,MAAM,GAqBX;CAEL,CAAA,CACd,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RootProps } from "../../core/combobox.mjs";
|
|
2
|
+
import "../../core/index.mjs";
|
|
3
|
+
import { ClassNames, Option, OptionGroup } from "./select-searchable-options.mjs";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
//#region src/components/atoms/select-searchable.d.ts
|
|
6
|
+
interface Props extends Omit<RootProps<string, Option>, 'children' | 'items' | 'multiple' | 'filteredItems' | 'onValueChange' | 'itemToStringLabel' | 'itemToStringValue' | 'isItemEqualToValue'> {
|
|
7
|
+
searchable: true;
|
|
8
|
+
multiple?: false;
|
|
9
|
+
/** Accessible name for the trigger and search popup. */
|
|
10
|
+
label: string;
|
|
11
|
+
options: (Option | OptionGroup)[];
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
searchPlaceholder?: string;
|
|
14
|
+
emptyText?: ReactNode;
|
|
15
|
+
allowClear?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
classNames?: ClassNames;
|
|
18
|
+
onChange?: (value: string | null) => void;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Props };
|
|
22
|
+
//# sourceMappingURL=select-searchable.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-searchable.d.mts","names":[],"sources":["../../../src/components/atoms/select-searchable.tsx"],"mappings":";;;;;UA6BiB,cAAc,KAC7B,kBAA2B;EAU3B;EACA;;EAEA;EACA,UAAU,SAAS;EACnB;EACA;EACA,YAAY;EACZ;EACA;EACA,aAAa;EACb,YAAY"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../utils.mjs";
|
|
3
|
+
import { DEFAULT_LOCALE, useConfig } from "../../providers/config/context.mjs";
|
|
4
|
+
import { combobox_exports } from "../../core/combobox.mjs";
|
|
5
|
+
import { selectTriggerStyles } from "../../core/select.mjs";
|
|
6
|
+
import Button from "../../Button.mjs";
|
|
7
|
+
import Input from "./input/index.mjs";
|
|
8
|
+
import SearchableOptions, { useSelectItems } from "./select-searchable-options.mjs";
|
|
9
|
+
import { ChevronDownIcon, XIcon } from "lucide-react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/components/atoms/select-searchable.tsx
|
|
12
|
+
const { Combobox: Core, ComboboxClear, ComboboxContent, ComboboxIcon, ComboboxInput, ComboboxTrigger, ComboboxValue } = combobox_exports;
|
|
13
|
+
const SearchableSelect = ({ label, options, placeholder, searchPlaceholder = "Search...", emptyText = "No results found.", allowClear = true, className, classNames, onChange, searchable: _searchable, multiple: _multiple, ...props }) => {
|
|
14
|
+
const { locale } = useConfig();
|
|
15
|
+
const items = useSelectItems(options);
|
|
16
|
+
return /* @__PURE__ */ jsxs(Core, {
|
|
17
|
+
items,
|
|
18
|
+
onValueChange: (value) => onChange?.(value),
|
|
19
|
+
...props,
|
|
20
|
+
children: [/* @__PURE__ */ jsxs(ComboboxTrigger, {
|
|
21
|
+
"data-slot": "select-trigger",
|
|
22
|
+
"data-size": "default",
|
|
23
|
+
"aria-label": label,
|
|
24
|
+
className: cn(selectTriggerStyles, "w-full max-w-48", className),
|
|
25
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
26
|
+
"data-slot": "select-value",
|
|
27
|
+
className: "min-w-0 flex-1 truncate text-start",
|
|
28
|
+
children: /* @__PURE__ */ jsx(ComboboxValue, { placeholder })
|
|
29
|
+
}), /* @__PURE__ */ jsx(ComboboxIcon, {
|
|
30
|
+
className: "opacity-50",
|
|
31
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
32
|
+
})]
|
|
33
|
+
}), /* @__PURE__ */ jsxs(ComboboxContent, {
|
|
34
|
+
"aria-label": label,
|
|
35
|
+
className: classNames?.content,
|
|
36
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: "border-b p-1",
|
|
38
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: "relative flex items-center",
|
|
40
|
+
children: [/* @__PURE__ */ jsx(ComboboxInput, { render: /* @__PURE__ */ jsx(Input, {
|
|
41
|
+
"aria-label": `${label} search`,
|
|
42
|
+
placeholder: searchPlaceholder,
|
|
43
|
+
className: cn(allowClear && "pe-8", classNames?.input)
|
|
44
|
+
}) }), allowClear && /* @__PURE__ */ jsx(ComboboxClear, {
|
|
45
|
+
"data-slot": "combobox-clear",
|
|
46
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
47
|
+
variant: "text",
|
|
48
|
+
size: "icon-sm",
|
|
49
|
+
icon: /* @__PURE__ */ jsx(XIcon, {}),
|
|
50
|
+
"aria-label": locale.clear ?? DEFAULT_LOCALE.clear,
|
|
51
|
+
className: "absolute end-0"
|
|
52
|
+
})
|
|
53
|
+
})]
|
|
54
|
+
})
|
|
55
|
+
}), /* @__PURE__ */ jsx(SearchableOptions, {
|
|
56
|
+
emptyText,
|
|
57
|
+
classNames
|
|
58
|
+
})]
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { SearchableSelect as default };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=select-searchable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-searchable.mjs","names":["combobox","select.selectTriggerStyles"],"sources":["../../../src/components/atoms/select-searchable.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode } from 'react';\n\nimport { ChevronDownIcon, XIcon } from 'lucide-react';\n\nimport { DEFAULT_LOCALE, useConfig } from '@repo/ui/providers';\nimport { cn } from '@repo/ui/utils';\n\nimport { combobox, select } from '../../core';\nimport Button from './button';\nimport Input from './input';\nimport SearchableOptions, {\n type ClassNames,\n type Option,\n type OptionGroup,\n useSelectItems,\n} from './select-searchable-options';\n\nconst {\n Combobox: Core,\n ComboboxClear,\n ComboboxContent,\n ComboboxIcon,\n ComboboxInput,\n ComboboxTrigger,\n ComboboxValue,\n} = combobox;\n\nexport interface Props extends Omit<\n combobox.RootProps<string, Option>,\n | 'children'\n | 'items'\n | 'multiple'\n | 'filteredItems'\n | 'onValueChange'\n | 'itemToStringLabel'\n | 'itemToStringValue'\n | 'isItemEqualToValue'\n> {\n searchable: true;\n multiple?: false;\n /** Accessible name for the trigger and search popup. */\n label: string;\n options: (Option | OptionGroup)[];\n placeholder?: string;\n searchPlaceholder?: string;\n emptyText?: ReactNode;\n allowClear?: boolean;\n className?: string;\n classNames?: ClassNames;\n onChange?: (value: string | null) => void;\n}\n\nconst SearchableSelect = ({\n label,\n options,\n placeholder,\n searchPlaceholder = 'Search...',\n emptyText = 'No results found.',\n allowClear = true,\n className,\n classNames,\n onChange,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Do not forward the public mode switch to Base UI.\n searchable: _searchable,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- The single-select primitive fixes this mode internally.\n multiple: _multiple,\n ...props\n}: Props) => {\n const { locale } = useConfig();\n const items = useSelectItems(options);\n\n return (\n <Core items={items} onValueChange={value => onChange?.(value)} {...props}>\n <ComboboxTrigger\n data-slot=\"select-trigger\"\n data-size=\"default\"\n aria-label={label}\n className={cn(select.selectTriggerStyles, 'w-full max-w-48', className)}\n >\n <span\n data-slot=\"select-value\"\n className=\"min-w-0 flex-1 truncate text-start\"\n >\n <ComboboxValue placeholder={placeholder} />\n </span>\n <ComboboxIcon className=\"opacity-50\">\n <ChevronDownIcon />\n </ComboboxIcon>\n </ComboboxTrigger>\n <ComboboxContent aria-label={label} className={classNames?.content}>\n <div className=\"border-b p-1\">\n <div className=\"relative flex items-center\">\n <ComboboxInput\n render={\n <Input\n aria-label={`${label} search`}\n placeholder={searchPlaceholder}\n className={cn(allowClear && 'pe-8', classNames?.input)}\n />\n }\n />\n {allowClear && (\n <ComboboxClear\n data-slot=\"combobox-clear\"\n render={\n <Button\n variant=\"text\"\n size=\"icon-sm\"\n icon={<XIcon />}\n aria-label={locale.clear ?? DEFAULT_LOCALE.clear}\n className=\"absolute end-0\"\n />\n }\n />\n )}\n </div>\n </div>\n <SearchableOptions emptyText={emptyText} classNames={classNames} />\n </ComboboxContent>\n </Core>\n );\n};\n\nexport default SearchableSelect;\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,EACJ,UAAU,MACV,eACA,iBACA,cACA,eACA,iBACA,kBACEA;AA2BJ,MAAM,oBAAoB,EACxB,OACA,SACA,aACA,oBAAoB,aACpB,YAAY,qBACZ,aAAa,MACb,WACA,YACA,UAEA,YAAY,aAEZ,UAAU,WACV,GAAG,YACQ;CACX,MAAM,EAAE,WAAW,UAAU;CAC7B,MAAM,QAAQ,eAAe,OAAO;CAEpC,OACE,qBAAC,MAAD;EAAa;EAAO,gBAAe,UAAS,WAAW,KAAK;EAAG,GAAI;EAAnE,UAAA,CACE,qBAAC,iBAAD;GACE,aAAU;GACV,aAAU;GACV,cAAY;GACZ,WAAW,GAAGC,qBAA4B,mBAAmB,SAAS;GAJxE,UAAA,CAME,oBAAC,QAAD;IACE,aAAU;IACV,WAAU;IAEV,UAAA,oBAAC,eAAD,EAA4B,YAAc,CAAA;GACtC,CAAA,GACN,oBAAC,cAAD;IAAc,WAAU;IACtB,UAAA,oBAAC,iBAAD,CAAkB,CAAA;GACN,CAAA,CACC;EACjB,CAAA,GAAA,qBAAC,iBAAD;GAAiB,cAAY;GAAO,WAAW,YAAY;GAA3D,UAAA,CACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAAC,eAAD,EACE,QACE,oBAAC,OAAD;MACE,cAAY,GAAG,MAAM;MACrB,aAAa;MACb,WAAW,GAAG,cAAc,QAAQ,YAAY,KAAK;KACtD,CAAA,EAEJ,CAAA,GACA,cACC,oBAAC,eAAD;MACE,aAAU;MACV,QACE,oBAAC,QAAD;OACE,SAAQ;OACR,MAAK;OACL,MAAM,oBAAC,OAAD,CAAQ,CAAA;OACd,cAAY,OAAO,SAAS,eAAe;OAC3C,WAAU;MACX,CAAA;KAEJ,CAAA,CAEA;;GACF,CAAA,GACL,oBAAC,mBAAD;IAA8B;IAAuB;GAAa,CAAA,CACnD;EACb,CAAA,CAAA;;AAEV"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { Select as Select$1 } from "../../core/select.mjs";
|
|
2
2
|
import "../../core/index.mjs";
|
|
3
|
+
import { Props as Props$1 } from "./select-multiple.mjs";
|
|
4
|
+
import { Props as Props$2 } from "./select-searchable.mjs";
|
|
3
5
|
import React from "react";
|
|
4
6
|
//#region src/components/atoms/select.d.ts
|
|
5
7
|
declare const Core: typeof Select$1;
|
|
6
8
|
interface Option {
|
|
7
9
|
label: React.ReactNode;
|
|
8
10
|
value: string;
|
|
11
|
+
disabled?: boolean;
|
|
9
12
|
}
|
|
10
13
|
interface OptionGroup {
|
|
11
14
|
label: React.ReactNode;
|
|
12
15
|
options: Option[];
|
|
13
16
|
}
|
|
14
|
-
interface
|
|
17
|
+
interface StaticProps extends Omit<React.ComponentProps<typeof Core>, 'onValueChange'> {
|
|
18
|
+
searchable?: false;
|
|
15
19
|
placeholder?: string;
|
|
16
20
|
className?: string;
|
|
17
21
|
options?: (Option | OptionGroup)[];
|
|
18
22
|
onChange?: (value: string) => void;
|
|
23
|
+
'aria-label'?: string;
|
|
19
24
|
}
|
|
20
|
-
|
|
25
|
+
type Props = StaticProps | Props$2 | Props$1;
|
|
26
|
+
declare const Select: (props: Props) => React.JSX.Element;
|
|
21
27
|
//#endregion
|
|
22
28
|
export { Props, Select as default };
|
|
23
29
|
//# sourceMappingURL=select.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.mts","names":[],"sources":["../../../src/components/atoms/select.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.d.mts","names":[],"sources":["../../../src/components/atoms/select.tsx"],"mappings":";;;;;;cAWU,aAAI;UASJ;EACR,OAAO,MAAM;EACb;EACA;;UAGQ;EACR,OAAO,MAAM;EACb,SAAS;;UAOD,oBAAoB,KAC5B,MAAM,sBAAsB;EAG5B;EACA;EACA;EACA,WAAW,SAAS;EACpB,YAAY;EACZ;;KAGU,QAAQ,cAAc,UAAkB;cA8D9C,SAAU,OAAO,UAAK,MAAA,IAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../utils.mjs";
|
|
2
2
|
import { select_exports } from "../../core/select.mjs";
|
|
3
|
+
import MultipleSelect from "./select-multiple.mjs";
|
|
4
|
+
import SearchableSelect from "./select-searchable.mjs";
|
|
3
5
|
import "react";
|
|
4
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
7
|
//#region src/components/atoms/select.tsx
|
|
@@ -7,7 +9,7 @@ const { Select: Core, SelectContent, SelectGroup, SelectItem, SelectLabel, Selec
|
|
|
7
9
|
const isGroup = (option) => {
|
|
8
10
|
return "options" in option && Array.isArray(option.options);
|
|
9
11
|
};
|
|
10
|
-
const
|
|
12
|
+
const StaticSelect = ({ searchable: _searchable, className, placeholder, options, onChange, "aria-label": ariaLabel, ...props }) => {
|
|
11
13
|
const items = options?.flatMap((option) => isGroup(option) ? option.options : option);
|
|
12
14
|
return /* @__PURE__ */ jsxs(Core, {
|
|
13
15
|
items,
|
|
@@ -16,17 +18,25 @@ const Select = ({ className, placeholder, options, onChange, ...props }) => {
|
|
|
16
18
|
},
|
|
17
19
|
...props,
|
|
18
20
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
21
|
+
"aria-label": ariaLabel,
|
|
19
22
|
className: cn("w-full max-w-48", className),
|
|
20
23
|
children: /* @__PURE__ */ jsx(SelectValue, { placeholder })
|
|
21
24
|
}), /* @__PURE__ */ jsx(SelectContent, { children: options?.map((option, index) => isGroup(option) ? /* @__PURE__ */ jsxs(SelectGroup, { children: [/* @__PURE__ */ jsx(SelectLabel, { children: option.label }), option.options.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
22
25
|
value: item.value,
|
|
26
|
+
disabled: item.disabled,
|
|
23
27
|
children: item.label
|
|
24
28
|
}, item.value))] }, index) : /* @__PURE__ */ jsx(SelectItem, {
|
|
25
29
|
value: option.value,
|
|
30
|
+
disabled: option.disabled,
|
|
26
31
|
children: option.label
|
|
27
32
|
}, option.value)) })]
|
|
28
33
|
});
|
|
29
34
|
};
|
|
35
|
+
const Select = (props) => {
|
|
36
|
+
if (props.multiple) return /* @__PURE__ */ jsx(MultipleSelect, { ...props });
|
|
37
|
+
if (props.searchable) return /* @__PURE__ */ jsx(SearchableSelect, { ...props });
|
|
38
|
+
return /* @__PURE__ */ jsx(StaticSelect, { ...props });
|
|
39
|
+
};
|
|
30
40
|
//#endregion
|
|
31
41
|
export { Select as default };
|
|
32
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.mjs","names":["select"],"sources":["../../../src/components/atoms/select.tsx"],"sourcesContent":["import React from 'react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport { select } from '../../core';\n\nconst {\n Select: Core,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectTrigger,\n SelectValue,\n} = select;\n\ninterface Option {\n label: React.ReactNode;\n value: string;\n}\n\ninterface OptionGroup {\n label: React.ReactNode;\n options: Option[];\n}\n\nconst isGroup = (option: Option | OptionGroup): option is OptionGroup => {\n return 'options' in option && Array.isArray(option.options);\n};\n\
|
|
1
|
+
{"version":3,"file":"select.mjs","names":["select"],"sources":["../../../src/components/atoms/select.tsx"],"sourcesContent":["import React from 'react';\n\nimport { cn } from '@repo/ui/utils';\n\nimport { select } from '../../core';\nimport MultipleSelect, { type Props as MultipleProps } from './select-multiple';\nimport SearchableSelect, {\n type Props as SearchableProps,\n} from './select-searchable';\n\nconst {\n Select: Core,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectTrigger,\n SelectValue,\n} = select;\n\ninterface Option {\n label: React.ReactNode;\n value: string;\n disabled?: boolean;\n}\n\ninterface OptionGroup {\n label: React.ReactNode;\n options: Option[];\n}\n\nconst isGroup = (option: Option | OptionGroup): option is OptionGroup => {\n return 'options' in option && Array.isArray(option.options);\n};\n\ninterface StaticProps extends Omit<\n React.ComponentProps<typeof Core>,\n 'onValueChange'\n> {\n searchable?: false;\n placeholder?: string;\n className?: string;\n options?: (Option | OptionGroup)[];\n onChange?: (value: string) => void;\n 'aria-label'?: string;\n}\n\nexport type Props = StaticProps | SearchableProps | MultipleProps;\n\nconst StaticSelect = ({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Do not forward the public mode switch to Base UI.\n searchable: _searchable,\n className,\n placeholder,\n options,\n onChange,\n 'aria-label': ariaLabel,\n ...props\n}: StaticProps) => {\n const items = options?.flatMap(option =>\n isGroup(option) ? option.options : option,\n );\n\n return (\n <Core\n items={items}\n onValueChange={value => {\n if (value !== null) {\n onChange?.(value);\n }\n }}\n {...props}\n >\n <SelectTrigger\n aria-label={ariaLabel}\n className={cn('w-full max-w-48', className)}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options?.map((option, index) =>\n isGroup(option) ? (\n <SelectGroup key={index}>\n <SelectLabel>{option.label}</SelectLabel>\n {option.options.map(item => (\n <SelectItem\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n >\n {item.label}\n </SelectItem>\n ))}\n </SelectGroup>\n ) : (\n <SelectItem\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.label}\n </SelectItem>\n ),\n )}\n </SelectContent>\n </Core>\n );\n};\n\nconst Select = (props: Props) => {\n if (props.multiple) {\n return <MultipleSelect {...props} />;\n }\n\n if (props.searchable) {\n return <SearchableSelect {...props} />;\n }\n\n return <StaticSelect {...props} />;\n};\n\nexport default Select;\n"],"mappings":";;;;;;;AAUA,MAAM,EACJ,QAAQ,MACR,eACA,aACA,YACA,aACA,eACA,gBACEA;AAaJ,MAAM,WAAW,WAAwD;CACvE,OAAO,aAAa,UAAU,MAAM,QAAQ,OAAO,OAAO;AAC5D;AAgBA,MAAM,gBAAgB,EAEpB,YAAY,aACZ,WACA,aACA,SACA,UACA,cAAc,WACd,GAAG,YACc;CACjB,MAAM,QAAQ,SAAS,SAAQ,WAC7B,QAAQ,MAAM,IAAI,OAAO,UAAU,MACrC;CAEA,OACE,qBAAC,MAAD;EACS;EACP,gBAAe,UAAS;GACtB,IAAI,UAAU,MACZ,WAAW,KAAK;EAEpB;EACA,GAAI;EAPN,UAAA,CASE,oBAAC,eAAD;GACE,cAAY;GACZ,WAAW,GAAG,mBAAmB,SAAS;GAE1C,UAAA,oBAAC,aAAD,EAA0B,YAAc,CAAA;EAC3B,CAAA,GACf,oBAAC,eAAD,EAAA,UACG,SAAS,KAAK,QAAQ,UACrB,QAAQ,MAAM,IACZ,qBAAC,aAAD,EAAA,UAAA,CACE,oBAAC,aAAD,EAAA,UAAc,OAAO,MAAmB,CAAA,GACvC,OAAO,QAAQ,KAAI,SAClB,oBAAC,YAAD;GAEE,OAAO,KAAK;GACZ,UAAU,KAAK;GAEd,UAAA,KAAK;EACI,GALL,KAAK,KAKA,CACb,CACU,EAAA,GAXK,KAWL,IAEb,oBAAC,YAAD;GAEE,OAAO,OAAO;GACd,UAAU,OAAO;GAEhB,UAAA,OAAO;EACE,GALL,OAAO,KAKF,CAEhB,EACa,CAAA,CACX;;AAEV;AAEA,MAAM,UAAU,UAAiB;CAC/B,IAAI,MAAM,UACR,OAAO,oBAAC,gBAAD,EAAgB,GAAI,MAAQ,CAAA;CAGrC,IAAI,MAAM,YACR,OAAO,oBAAC,kBAAD,EAAkB,GAAI,MAAQ,CAAA;CAGvC,OAAO,oBAAC,cAAD,EAAc,GAAI,MAAQ,CAAA;AACnC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
3
|
import { slider_exports } from "../../../core/slider.mjs";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { useControllableState } from "@jbpark/use-hooks";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/atoms/slider/slider.tsx
|
|
7
7
|
const { Slider: Core } = slider_exports;
|
|
8
8
|
const toArray = (value) => {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../../utils.mjs";
|
|
3
3
|
import { useConfig } from "../../providers/config/context.mjs";
|
|
4
4
|
import { switch_exports } from "../../core/switch.mjs";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { useControllableState } from "@jbpark/use-hooks";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/atoms/switch.tsx
|
|
8
8
|
const { Switch: Core } = switch_exports;
|
|
9
9
|
const sizeConfig = {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
//#region src/components/atoms/tooltip.d.ts
|
|
3
|
+
declare const Core: <Payload>(props: import("@base-ui/react").TooltipRoot.Props<Payload>) => React.JSX.Element;
|
|
4
|
+
type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
5
|
+
interface Props extends Omit<React.ComponentProps<typeof Core>, 'children' | 'handle' | 'triggerId' | 'defaultTriggerId'> {
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
/** Supplementary visual hint; keep essential information visible elsewhere. */
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
/** Popup class; the child retains its own className. */
|
|
10
|
+
className?: string;
|
|
11
|
+
placement?: Placement;
|
|
12
|
+
/** Distance between the trigger and popup in pixels. */
|
|
13
|
+
offset?: number;
|
|
14
|
+
/** Hover delay in milliseconds. Keyboard focus opens without this delay. */
|
|
15
|
+
delay?: number;
|
|
16
|
+
closeDelay?: number;
|
|
17
|
+
}
|
|
18
|
+
declare const Tooltip: ({ children, content, className, placement, offset, delay, closeDelay, ...props }: Props) => import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Props, Tooltip as default };
|
|
21
|
+
//# sourceMappingURL=tooltip.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.mts","names":[],"sources":["../../../src/components/atoms/tooltip.tsx"],"mappings":";;cAMiB,OAAI,SAAA,gCAAA,YAAA,MAAA,aAAA,MAAA,IAAA;KAEhB;UAgCY,cAAc,KAC7B,MAAM,sBAAsB;EAG5B,UAAU;;EAEV,SAAS;;EAET;EACA,YAAY;;EAEZ;;EAEA;EACA;;cAGI,YAAW,UAAA,SAAA,WAAA,WAAA,QAAA,OAAA,eAAA,SASd,0BAAK,IAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { tooltip_exports } from "../../core/tooltip.mjs";
|
|
3
|
+
import { Children } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/atoms/tooltip.tsx
|
|
6
|
+
const { Tooltip: Core, TooltipContent, TooltipTrigger } = tooltip_exports;
|
|
7
|
+
const placementMap = {
|
|
8
|
+
top: {
|
|
9
|
+
side: "top",
|
|
10
|
+
align: "center"
|
|
11
|
+
},
|
|
12
|
+
left: {
|
|
13
|
+
side: "left",
|
|
14
|
+
align: "center"
|
|
15
|
+
},
|
|
16
|
+
right: {
|
|
17
|
+
side: "right",
|
|
18
|
+
align: "center"
|
|
19
|
+
},
|
|
20
|
+
bottom: {
|
|
21
|
+
side: "bottom",
|
|
22
|
+
align: "center"
|
|
23
|
+
},
|
|
24
|
+
topLeft: {
|
|
25
|
+
side: "top",
|
|
26
|
+
align: "start"
|
|
27
|
+
},
|
|
28
|
+
topRight: {
|
|
29
|
+
side: "top",
|
|
30
|
+
align: "end"
|
|
31
|
+
},
|
|
32
|
+
bottomLeft: {
|
|
33
|
+
side: "bottom",
|
|
34
|
+
align: "start"
|
|
35
|
+
},
|
|
36
|
+
bottomRight: {
|
|
37
|
+
side: "bottom",
|
|
38
|
+
align: "end"
|
|
39
|
+
},
|
|
40
|
+
leftTop: {
|
|
41
|
+
side: "left",
|
|
42
|
+
align: "start"
|
|
43
|
+
},
|
|
44
|
+
leftBottom: {
|
|
45
|
+
side: "left",
|
|
46
|
+
align: "end"
|
|
47
|
+
},
|
|
48
|
+
rightTop: {
|
|
49
|
+
side: "right",
|
|
50
|
+
align: "start"
|
|
51
|
+
},
|
|
52
|
+
rightBottom: {
|
|
53
|
+
side: "right",
|
|
54
|
+
align: "end"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const Tooltip = ({ children, content, className, placement = "top", offset = 8, delay, closeDelay, ...props }) => {
|
|
58
|
+
const trigger = Children.only(children);
|
|
59
|
+
const { side, align } = placementMap[placement];
|
|
60
|
+
return /* @__PURE__ */ jsxs(Core, {
|
|
61
|
+
...props,
|
|
62
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
63
|
+
render: trigger,
|
|
64
|
+
delay,
|
|
65
|
+
closeDelay
|
|
66
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
67
|
+
side,
|
|
68
|
+
align,
|
|
69
|
+
sideOffset: offset,
|
|
70
|
+
className,
|
|
71
|
+
children: content
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { Tooltip as default };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=tooltip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.mjs","names":["tooltip"],"sources":["../../../src/components/atoms/tooltip.tsx"],"sourcesContent":["'use client';\n\nimport { Children, type ReactElement, type ReactNode } from 'react';\n\nimport { tooltip } from '../../core';\n\nconst { Tooltip: Core, TooltipContent, TooltipTrigger } = tooltip;\n\ntype Placement =\n | 'top'\n | 'left'\n | 'right'\n | 'bottom'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n\ntype Side = NonNullable<React.ComponentProps<typeof TooltipContent>['side']>;\ntype Align = NonNullable<React.ComponentProps<typeof TooltipContent>['align']>;\n\nconst placementMap: Record<Placement, { side: Side; align: Align }> = {\n top: { side: 'top', align: 'center' },\n left: { side: 'left', align: 'center' },\n right: { side: 'right', align: 'center' },\n bottom: { side: 'bottom', align: 'center' },\n topLeft: { side: 'top', align: 'start' },\n topRight: { side: 'top', align: 'end' },\n bottomLeft: { side: 'bottom', align: 'start' },\n bottomRight: { side: 'bottom', align: 'end' },\n leftTop: { side: 'left', align: 'start' },\n leftBottom: { side: 'left', align: 'end' },\n rightTop: { side: 'right', align: 'start' },\n rightBottom: { side: 'right', align: 'end' },\n};\n\nexport interface Props extends Omit<\n React.ComponentProps<typeof Core>,\n 'children' | 'handle' | 'triggerId' | 'defaultTriggerId'\n> {\n children: ReactElement;\n /** Supplementary visual hint; keep essential information visible elsewhere. */\n content: ReactNode;\n /** Popup class; the child retains its own className. */\n className?: string;\n placement?: Placement;\n /** Distance between the trigger and popup in pixels. */\n offset?: number;\n /** Hover delay in milliseconds. Keyboard focus opens without this delay. */\n delay?: number;\n closeDelay?: number;\n}\n\nconst Tooltip = ({\n children,\n content,\n className,\n placement = 'top',\n offset = 8,\n delay,\n closeDelay,\n ...props\n}: Props) => {\n const trigger = Children.only(children);\n const { side, align } = placementMap[placement];\n\n return (\n <Core {...props}>\n <TooltipTrigger render={trigger} delay={delay} closeDelay={closeDelay} />\n <TooltipContent\n side={side}\n align={align}\n sideOffset={offset}\n className={className}\n >\n {content}\n </TooltipContent>\n </Core>\n );\n};\n\nexport default Tooltip;\n"],"mappings":";;;;;AAMA,MAAM,EAAE,SAAS,MAAM,gBAAgB,mBAAmBA;AAmB1D,MAAM,eAAgE;CACpE,KAAK;EAAE,MAAM;EAAO,OAAO;CAAS;CACpC,MAAM;EAAE,MAAM;EAAQ,OAAO;CAAS;CACtC,OAAO;EAAE,MAAM;EAAS,OAAO;CAAS;CACxC,QAAQ;EAAE,MAAM;EAAU,OAAO;CAAS;CAC1C,SAAS;EAAE,MAAM;EAAO,OAAO;CAAQ;CACvC,UAAU;EAAE,MAAM;EAAO,OAAO;CAAM;CACtC,YAAY;EAAE,MAAM;EAAU,OAAO;CAAQ;CAC7C,aAAa;EAAE,MAAM;EAAU,OAAO;CAAM;CAC5C,SAAS;EAAE,MAAM;EAAQ,OAAO;CAAQ;CACxC,YAAY;EAAE,MAAM;EAAQ,OAAO;CAAM;CACzC,UAAU;EAAE,MAAM;EAAS,OAAO;CAAQ;CAC1C,aAAa;EAAE,MAAM;EAAS,OAAO;CAAM;AAC7C;AAmBA,MAAM,WAAW,EACf,UACA,SACA,WACA,YAAY,OACZ,SAAS,GACT,OACA,YACA,GAAG,YACQ;CACX,MAAM,UAAU,SAAS,KAAK,QAAQ;CACtC,MAAM,EAAE,MAAM,UAAU,aAAa;CAErC,OACE,qBAAC,MAAD;EAAM,GAAI;EAAV,UAAA,CACE,oBAAC,gBAAD;GAAgB,QAAQ;GAAgB;GAAmB;EAAa,CAAA,GACxE,oBAAC,gBAAD;GACQ;GACC;GACP,YAAY;GACD;GAEV,UAAA;EACa,CAAA,CACZ;;AAEV"}
|
|
@@ -3,6 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
//#region src/components/atoms/typography/paragraph.tsx
|
|
4
4
|
const Paragraph = ({ children, className, ...props }) => {
|
|
5
5
|
return /* @__PURE__ */ jsx("p", {
|
|
6
|
+
"data-slot": "typography-paragraph",
|
|
6
7
|
...props,
|
|
7
8
|
className: cn("m-0", className),
|
|
8
9
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.mjs","names":[],"sources":["../../../../src/components/atoms/typography/paragraph.tsx"],"sourcesContent":["import { cn } from '@repo/ui/utils';\n\nexport interface Props extends React.ComponentPropsWithoutRef<'p'> {}\n\nconst Paragraph = ({ children, className, ...props }: Props) => {\n return (\n <p\n {...props}\n className={cn(\n 'm-0',\n className,\n //\n )}\n >\n {children}\n </p>\n );\n};\n\nexport default Paragraph;\n"],"mappings":";;;AAIA,MAAM,aAAa,EAAE,UAAU,WAAW,GAAG,YAAmB;CAC9D,OACE,oBAAC,KAAD;EACE,GAAI;EACJ,WAAW,GACT,OACA,SAEF;EAEC;CACA,CAAA;AAEP"}
|
|
1
|
+
{"version":3,"file":"paragraph.mjs","names":[],"sources":["../../../../src/components/atoms/typography/paragraph.tsx"],"sourcesContent":["import { cn } from '@repo/ui/utils';\n\nexport interface Props extends React.ComponentPropsWithoutRef<'p'> {}\n\nconst Paragraph = ({ children, className, ...props }: Props) => {\n return (\n <p\n data-slot=\"typography-paragraph\"\n {...props}\n className={cn(\n 'm-0',\n className,\n //\n )}\n >\n {children}\n </p>\n );\n};\n\nexport default Paragraph;\n"],"mappings":";;;AAIA,MAAM,aAAa,EAAE,UAAU,WAAW,GAAG,YAAmB;CAC9D,OACE,oBAAC,KAAD;EACE,aAAU;EACV,GAAI;EACJ,WAAW,GACT,OACA,SAEF;EAEC;CACA,CAAA;AAEP"}
|
|
@@ -12,6 +12,7 @@ const styles = {
|
|
|
12
12
|
const Title = ({ children, level = 1, className, ...props }) => {
|
|
13
13
|
const Element = level < 1 || level > 6 ? "h1" : `h${level}`;
|
|
14
14
|
return /* @__PURE__ */ jsx(Element, {
|
|
15
|
+
"data-slot": "typography-title",
|
|
15
16
|
className: cn("m-0 leading-snug font-bold", styles[Element], className),
|
|
16
17
|
...props,
|
|
17
18
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.mjs","names":[],"sources":["../../../../src/components/atoms/typography/title.tsx"],"sourcesContent":["import { cn } from '@repo/ui/utils';\n\nexport interface Props extends React.ComponentPropsWithoutRef<\n 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n> {\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n}\n\ntype ElementType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n// Scale up at wider breakpoints instead of a single fixed size — the desktop\n// size stays the same as before, but narrow/mobile viewports now get a\n// smaller starting size instead of always rendering at the full desktop size.\nconst styles: Record<string, string> = {\n h1: 'text-4xl sm:text-5xl lg:text-6xl',\n h2: 'text-3xl sm:text-4xl lg:text-5xl',\n h3: 'text-2xl sm:text-3xl lg:text-4xl',\n h4: 'text-xl sm:text-2xl lg:text-3xl',\n h5: 'text-lg sm:text-xl lg:text-2xl',\n h6: 'text-base sm:text-lg lg:text-xl',\n};\n\nconst Title = ({ children, level = 1, className, ...props }: Props) => {\n const Element: ElementType = level < 1 || level > 6 ? 'h1' : `h${level}`;\n\n return (\n <Element\n className={cn('m-0 leading-snug font-bold', styles[Element], className)}\n {...props}\n >\n {children}\n </Element>\n );\n};\n\nexport default Title;\n"],"mappings":";;;AAaA,MAAM,SAAiC;CACrC,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,SAAS,EAAE,UAAU,QAAQ,GAAG,WAAW,GAAG,YAAmB;CACrE,MAAM,UAAuB,QAAQ,KAAK,QAAQ,IAAI,OAAO,IAAI;CAEjE,OACE,oBAAC,SAAD;EACE,WAAW,GAAG,8BAA8B,OAAO,UAAU,SAAS;EACtE,GAAI;EAEH;CACM,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"title.mjs","names":[],"sources":["../../../../src/components/atoms/typography/title.tsx"],"sourcesContent":["import { cn } from '@repo/ui/utils';\n\nexport interface Props extends React.ComponentPropsWithoutRef<\n 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'\n> {\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n}\n\ntype ElementType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n// Scale up at wider breakpoints instead of a single fixed size — the desktop\n// size stays the same as before, but narrow/mobile viewports now get a\n// smaller starting size instead of always rendering at the full desktop size.\nconst styles: Record<string, string> = {\n h1: 'text-4xl sm:text-5xl lg:text-6xl',\n h2: 'text-3xl sm:text-4xl lg:text-5xl',\n h3: 'text-2xl sm:text-3xl lg:text-4xl',\n h4: 'text-xl sm:text-2xl lg:text-3xl',\n h5: 'text-lg sm:text-xl lg:text-2xl',\n h6: 'text-base sm:text-lg lg:text-xl',\n};\n\nconst Title = ({ children, level = 1, className, ...props }: Props) => {\n const Element: ElementType = level < 1 || level > 6 ? 'h1' : `h${level}`;\n\n return (\n <Element\n data-slot=\"typography-title\"\n className={cn('m-0 leading-snug font-bold', styles[Element], className)}\n {...props}\n >\n {children}\n </Element>\n );\n};\n\nexport default Title;\n"],"mappings":";;;AAaA,MAAM,SAAiC;CACrC,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,MAAM,SAAS,EAAE,UAAU,QAAQ,GAAG,WAAW,GAAG,YAAmB;CACrE,MAAM,UAAuB,QAAQ,KAAK,QAAQ,IAAI,OAAO,IAAI;CAEjE,OACE,oBAAC,SAAD;EACE,aAAU;EACV,WAAW,GAAG,8BAA8B,OAAO,UAAU,SAAS;EACtE,GAAI;EAEH;CACM,CAAA;AAEb"}
|
|
@@ -3,8 +3,8 @@ import { cn } from "../../utils.mjs";
|
|
|
3
3
|
import "../../lib/z-layers.mjs";
|
|
4
4
|
import Menu from "./menu/menu.mjs";
|
|
5
5
|
import { useId, useRef } from "react";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
6
|
import { useControllableState, useKeyPress } from "@jbpark/use-hooks";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AnimatePresence, motion } from "motion/react";
|
|
9
9
|
//#region src/components/molecules/dropdown.tsx
|
|
10
10
|
const Dropdown = ({ children, menu, trigger = "hover", open: _open, onOpenChange: _onOpenChange = () => {}, className, onMouseEnter, onMouseLeave, ...props }) => {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Props as Props$2 } from "./
|
|
1
|
+
import Breadcrumb, { Props } from "../../Breadcrumb.mjs";
|
|
2
|
+
import Card, { Props as Props$1 } from "../../Card.mjs";
|
|
3
|
+
import Menu, { Props as Props$2 } from "./menu/menu.mjs";
|
|
4
|
+
import Pagination, { Props as Props$3 } from "../../Pagination.mjs";
|
|
5
|
+
import { Props as Props$4 } from "./reveals/reveals.mjs";
|
|
4
6
|
import Reveals from "../../Reveals.mjs";
|
|
5
|
-
import Space, { Props as Props$
|
|
6
|
-
import Collapse, { Props as Props$
|
|
7
|
-
import Dropdown, { Props as Props$
|
|
8
|
-
import { Props as Props$
|
|
7
|
+
import Space, { Props as Props$5 } from "../../Space.mjs";
|
|
8
|
+
import Collapse, { Props as Props$6 } from "./collapse.mjs";
|
|
9
|
+
import Dropdown, { Props as Props$7 } from "./dropdown.mjs";
|
|
10
|
+
import { Props as Props$8 } from "./marquees/marquees.mjs";
|
|
9
11
|
import Marquees from "./marquees/index.mjs";
|
|
10
|
-
import { Props as Props$
|
|
12
|
+
import { Props as Props$9 } from "./splitter/splitter.mjs";
|
|
11
13
|
import Splitter from "./splitter/index.mjs";
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
+
import Tabs, { Props as Props$10 } from "./tabs.mjs";
|
|
15
|
+
import Upload, { Props as Props$11, UploadFile } from "./upload.mjs";
|
|
16
|
+
export { Breadcrumb, type Props as BreadcrumbProps, Card, type Props$1 as CardProps, Collapse, type Props$6 as CollapseProps, Dropdown, type Props$7 as DropdownProps, Marquees, type Props$8 as MarqueesProps, Menu, type Props$2 as MenuProps, Pagination, type Props$3 as PaginationProps, Reveals, type Props$4 as RevealsProps, Space, type Props$5 as SpaceProps, Splitter, type Props$9 as SplitterProps, Tabs, type Props$10 as TabsProps, Upload, type UploadFile, type Props$11 as UploadProps };
|
|
@@ -3,8 +3,8 @@ import { cn } from "../../../utils.mjs";
|
|
|
3
3
|
import usePauseOnHover from "./use-pause-on-hover.mjs";
|
|
4
4
|
import Item from "./item.mjs";
|
|
5
5
|
import { useEffect, useRef, useState } from "react";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
6
|
import { useMergedRef, useResponsiveSize, useThrottledValue } from "@jbpark/use-hooks";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region src/components/molecules/marquees/marquees.tsx
|
|
9
9
|
const Marquees = ({ className, items, speed, pauseOnHover = true, autoFill = true, gap, ...props }) => {
|
|
10
10
|
const [width, setWidth] = useState("100%");
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../../../utils.mjs";
|
|
3
3
|
import Item from "./item/item.mjs";
|
|
4
4
|
import { createElement, useMemo } from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
import { useControllableState } from "@jbpark/use-hooks";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/molecules/menu/menu.tsx
|
|
8
8
|
const MENU_CLASSNAMES = [
|
|
9
9
|
"m-0",
|
|
@@ -45,6 +45,7 @@ const Menu = ({ items, mode = "vertical", defaultSelectedKeys = [], selectedKeys
|
|
|
45
45
|
_onSelect?.(params);
|
|
46
46
|
};
|
|
47
47
|
return /* @__PURE__ */ jsx("ul", {
|
|
48
|
+
"data-slot": "menu",
|
|
48
49
|
role: "menu",
|
|
49
50
|
className: cn(MENU_CLASSNAMES, mode === "horizontal" ? "flex" : "inline-block", className),
|
|
50
51
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.mjs","names":[],"sources":["../../../../src/components/molecules/menu/menu.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { useControllableState } from '@jbpark/use-hooks';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Item from './item';\n\nexport interface MenuItem {\n label: React.ReactNode;\n key: React.Key;\n type?: string;\n path?: string;\n children?: MenuItem[];\n}\n\nexport interface Props {\n mode?: 'horizontal' | 'vertical' | 'inline';\n selectedKeys?: React.Key[];\n defaultSelectedKeys?: React.Key[];\n selectionMap?: SelectionMap;\n offset?: [number, number];\n inlineOffset?: number;\n classNames?: {\n rootItem?: string;\n subMenu?: string;\n item?: string;\n label?: string;\n };\n styles?: {\n rootItem?: React.CSSProperties;\n subMenu?: React.CSSProperties;\n item?: React.CSSProperties;\n label?: React.CSSProperties;\n };\n onClick?: ClickEventHandler;\n onSelect?: ClickEventHandler;\n}\n\nexport interface MenuProps\n extends\n Props,\n Omit<React.ComponentPropsWithoutRef<'ul'>, 'onClick' | 'onSelect'> {\n items?: MenuItem[];\n}\n\nexport type ClickEventHandler = (params: {\n domEvent: React.SyntheticEvent;\n key: React.Key;\n keyPath: React.Key[];\n item: MenuItem;\n}) => void;\n\nexport const MENU_CLASSNAMES = [\n 'm-0',\n 'list-none',\n 'p-0',\n 'bg-popover',\n 'text-popover-foreground',\n 'shadow-md',\n 'rounded-md',\n //\n];\n\nexport type SelectionMap = ReadonlyMap<React.Key, boolean>;\n\nexport const buildSelectionMap = (\n items: MenuItem[],\n selectedKeysSet: ReadonlySet<React.Key>,\n): SelectionMap => {\n const map = new Map<React.Key, boolean>();\n\n const dfs = (node: MenuItem): boolean => {\n const self = selectedKeysSet.has(node.key);\n const hasSelectedChild = node.children?.some(child => dfs(child)) ?? false;\n const isSelected = self || hasSelectedChild;\n map.set(node.key, isSelected);\n return isSelected;\n };\n\n items.forEach(dfs);\n return map;\n};\n\nexport const findKey = (\n menu: MenuItem,\n targetKeys: ReadonlySet<React.Key>,\n): boolean => {\n if (targetKeys.has(menu.key)) {\n return true;\n }\n\n if (menu.children && Array.isArray(menu.children)) {\n for (const child of menu.children) {\n if (findKey(child, targetKeys)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nconst Menu = ({\n items,\n mode = 'vertical',\n defaultSelectedKeys = [],\n selectedKeys: _selectedKeys,\n className,\n classNames,\n styles,\n offset,\n inlineOffset,\n onClick,\n onSelect: _onSelect,\n ...props\n}: MenuProps) => {\n const [selectedKeys, setSelectedKeys] = useControllableState<React.Key[]>({\n value: _selectedKeys,\n defaultValue: defaultSelectedKeys ?? [],\n });\n\n const selectedKeysSet = useMemo(\n () => new Set<React.Key>(selectedKeys ?? []),\n [selectedKeys],\n );\n\n const selectionMap = useMemo(\n () => buildSelectionMap(items ?? [], selectedKeysSet),\n [items, selectedKeysSet],\n );\n\n const onSelect = (params: {\n domEvent: React.SyntheticEvent;\n key: React.Key;\n keyPath: React.Key[];\n item: MenuItem;\n }) => {\n setSelectedKeys([params.key]);\n _onSelect?.(params);\n };\n\n return (\n <ul\n role=\"menu\"\n className={cn(\n MENU_CLASSNAMES,\n mode === 'horizontal' ? 'flex' : 'inline-block',\n className,\n )}\n {...props}\n >\n {items?.map((item, index) => (\n <Item\n root\n {...item}\n key={item.key}\n itemKey={item.key}\n keyPath={[item.key]}\n index={index}\n selectionMap={selectionMap}\n mode={mode}\n classNames={classNames}\n styles={styles}\n offset={offset}\n inlineOffset={inlineOffset}\n onClick={onClick}\n onSelect={onSelect}\n />\n ))}\n </ul>\n );\n};\n\nexport default Menu;\n"],"mappings":";;;;;;;AAuDA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;AAIA,MAAa,qBACX,OACA,oBACiB;CACjB,MAAM,sBAAM,IAAI,IAAwB;CAExC,MAAM,OAAO,SAA4B;EACvC,MAAM,OAAO,gBAAgB,IAAI,KAAK,GAAG;EACzC,MAAM,mBAAmB,KAAK,UAAU,MAAK,UAAS,IAAI,KAAK,CAAC,KAAK;EACrE,MAAM,aAAa,QAAQ;EAC3B,IAAI,IAAI,KAAK,KAAK,UAAU;EAC5B,OAAO;CACT;CAEA,MAAM,QAAQ,GAAG;CACjB,OAAO;AACT;AAEA,MAAa,WACX,MACA,eACY;CACZ,IAAI,WAAW,IAAI,KAAK,GAAG,GACzB,OAAO;CAGT,IAAI,KAAK,YAAY,MAAM,QAAQ,KAAK,QAAQ,GACzC;OAAA,MAAM,SAAS,KAAK,UACvB,IAAI,QAAQ,OAAO,UAAU,GAC3B,OAAO;CAAA;CAKb,OAAO;AACT;AAEA,MAAM,QAAQ,EACZ,OACA,OAAO,YACP,sBAAsB,CAAC,GACvB,cAAc,eACd,WACA,YACA,QACA,QACA,cACA,SACA,UAAU,WACV,GAAG,YACY;CACf,MAAM,CAAC,cAAc,mBAAmB,qBAAkC;EACxE,OAAO;EACP,cAAc,uBAAuB,CAAC;CACxC,CAAC;CAED,MAAM,kBAAkB,cAChB,IAAI,IAAe,gBAAgB,CAAC,CAAC,GAC3C,CAAC,YAAY,CACf;CAEA,MAAM,eAAe,cACb,kBAAkB,SAAS,CAAC,GAAG,eAAe,GACpD,CAAC,OAAO,eAAe,CACzB;CAEA,MAAM,YAAY,WAKZ;EACJ,gBAAgB,CAAC,OAAO,GAAG,CAAC;EAC5B,YAAY,MAAM;CACpB;CAEA,OACE,oBAAC,MAAD;EACE,MAAK;EACL,WAAW,GACT,iBACA,SAAS,eAAe,SAAS,gBACjC,SACF;EACA,GAAI;EAEH,UAAA,OAAO,KAAK,MAAM,UACjB,8BAAC,MAAD;GACE,MAAA;GACA,GAAI;GACJ,KAAK,KAAK;GACV,SAAS,KAAK;GACd,SAAS,CAAC,KAAK,GAAG;GACX;GACO;GACR;GACM;GACJ;GACA;GACM;GACL;GACC;EACX,CAAA,CACF;CACC,CAAA;AAER"}
|
|
1
|
+
{"version":3,"file":"menu.mjs","names":[],"sources":["../../../../src/components/molecules/menu/menu.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { useControllableState } from '@jbpark/use-hooks';\n\nimport { cn } from '@repo/ui/utils';\n\nimport Item from './item';\n\nexport interface MenuItem {\n label: React.ReactNode;\n key: React.Key;\n type?: string;\n path?: string;\n children?: MenuItem[];\n}\n\nexport interface Props {\n mode?: 'horizontal' | 'vertical' | 'inline';\n selectedKeys?: React.Key[];\n defaultSelectedKeys?: React.Key[];\n selectionMap?: SelectionMap;\n offset?: [number, number];\n inlineOffset?: number;\n classNames?: {\n rootItem?: string;\n subMenu?: string;\n item?: string;\n label?: string;\n };\n styles?: {\n rootItem?: React.CSSProperties;\n subMenu?: React.CSSProperties;\n item?: React.CSSProperties;\n label?: React.CSSProperties;\n };\n onClick?: ClickEventHandler;\n onSelect?: ClickEventHandler;\n}\n\nexport interface MenuProps\n extends\n Props,\n Omit<React.ComponentPropsWithoutRef<'ul'>, 'onClick' | 'onSelect'> {\n items?: MenuItem[];\n}\n\nexport type ClickEventHandler = (params: {\n domEvent: React.SyntheticEvent;\n key: React.Key;\n keyPath: React.Key[];\n item: MenuItem;\n}) => void;\n\nexport const MENU_CLASSNAMES = [\n 'm-0',\n 'list-none',\n 'p-0',\n 'bg-popover',\n 'text-popover-foreground',\n 'shadow-md',\n 'rounded-md',\n //\n];\n\nexport type SelectionMap = ReadonlyMap<React.Key, boolean>;\n\nexport const buildSelectionMap = (\n items: MenuItem[],\n selectedKeysSet: ReadonlySet<React.Key>,\n): SelectionMap => {\n const map = new Map<React.Key, boolean>();\n\n const dfs = (node: MenuItem): boolean => {\n const self = selectedKeysSet.has(node.key);\n const hasSelectedChild = node.children?.some(child => dfs(child)) ?? false;\n const isSelected = self || hasSelectedChild;\n map.set(node.key, isSelected);\n return isSelected;\n };\n\n items.forEach(dfs);\n return map;\n};\n\nexport const findKey = (\n menu: MenuItem,\n targetKeys: ReadonlySet<React.Key>,\n): boolean => {\n if (targetKeys.has(menu.key)) {\n return true;\n }\n\n if (menu.children && Array.isArray(menu.children)) {\n for (const child of menu.children) {\n if (findKey(child, targetKeys)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nconst Menu = ({\n items,\n mode = 'vertical',\n defaultSelectedKeys = [],\n selectedKeys: _selectedKeys,\n className,\n classNames,\n styles,\n offset,\n inlineOffset,\n onClick,\n onSelect: _onSelect,\n ...props\n}: MenuProps) => {\n const [selectedKeys, setSelectedKeys] = useControllableState<React.Key[]>({\n value: _selectedKeys,\n defaultValue: defaultSelectedKeys ?? [],\n });\n\n const selectedKeysSet = useMemo(\n () => new Set<React.Key>(selectedKeys ?? []),\n [selectedKeys],\n );\n\n const selectionMap = useMemo(\n () => buildSelectionMap(items ?? [], selectedKeysSet),\n [items, selectedKeysSet],\n );\n\n const onSelect = (params: {\n domEvent: React.SyntheticEvent;\n key: React.Key;\n keyPath: React.Key[];\n item: MenuItem;\n }) => {\n setSelectedKeys([params.key]);\n _onSelect?.(params);\n };\n\n return (\n <ul\n data-slot=\"menu\"\n role=\"menu\"\n className={cn(\n MENU_CLASSNAMES,\n mode === 'horizontal' ? 'flex' : 'inline-block',\n className,\n )}\n {...props}\n >\n {items?.map((item, index) => (\n <Item\n root\n {...item}\n key={item.key}\n itemKey={item.key}\n keyPath={[item.key]}\n index={index}\n selectionMap={selectionMap}\n mode={mode}\n classNames={classNames}\n styles={styles}\n offset={offset}\n inlineOffset={inlineOffset}\n onClick={onClick}\n onSelect={onSelect}\n />\n ))}\n </ul>\n );\n};\n\nexport default Menu;\n"],"mappings":";;;;;;;AAuDA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;AAEF;AAIA,MAAa,qBACX,OACA,oBACiB;CACjB,MAAM,sBAAM,IAAI,IAAwB;CAExC,MAAM,OAAO,SAA4B;EACvC,MAAM,OAAO,gBAAgB,IAAI,KAAK,GAAG;EACzC,MAAM,mBAAmB,KAAK,UAAU,MAAK,UAAS,IAAI,KAAK,CAAC,KAAK;EACrE,MAAM,aAAa,QAAQ;EAC3B,IAAI,IAAI,KAAK,KAAK,UAAU;EAC5B,OAAO;CACT;CAEA,MAAM,QAAQ,GAAG;CACjB,OAAO;AACT;AAEA,MAAa,WACX,MACA,eACY;CACZ,IAAI,WAAW,IAAI,KAAK,GAAG,GACzB,OAAO;CAGT,IAAI,KAAK,YAAY,MAAM,QAAQ,KAAK,QAAQ,GACzC;OAAA,MAAM,SAAS,KAAK,UACvB,IAAI,QAAQ,OAAO,UAAU,GAC3B,OAAO;CAAA;CAKb,OAAO;AACT;AAEA,MAAM,QAAQ,EACZ,OACA,OAAO,YACP,sBAAsB,CAAC,GACvB,cAAc,eACd,WACA,YACA,QACA,QACA,cACA,SACA,UAAU,WACV,GAAG,YACY;CACf,MAAM,CAAC,cAAc,mBAAmB,qBAAkC;EACxE,OAAO;EACP,cAAc,uBAAuB,CAAC;CACxC,CAAC;CAED,MAAM,kBAAkB,cAChB,IAAI,IAAe,gBAAgB,CAAC,CAAC,GAC3C,CAAC,YAAY,CACf;CAEA,MAAM,eAAe,cACb,kBAAkB,SAAS,CAAC,GAAG,eAAe,GACpD,CAAC,OAAO,eAAe,CACzB;CAEA,MAAM,YAAY,WAKZ;EACJ,gBAAgB,CAAC,OAAO,GAAG,CAAC;EAC5B,YAAY,MAAM;CACpB;CAEA,OACE,oBAAC,MAAD;EACE,aAAU;EACV,MAAK;EACL,WAAW,GACT,iBACA,SAAS,eAAe,SAAS,gBACjC,SACF;EACA,GAAI;EAEH,UAAA,OAAO,KAAK,MAAM,UACjB,8BAAC,MAAD;GACE,MAAA;GACA,GAAI;GACJ,KAAK,KAAK;GACV,SAAS,KAAK;GACd,SAAS,CAAC,KAAK,GAAG;GACX;GACO;GACR;GACM;GACJ;GACA;GACM;GACL;GACC;EACX,CAAA,CACF;CACC,CAAA;AAER"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Tabs as Tabs$1 } from "../../core/tabs.mjs";
|
|
2
|
+
import "../../core/index.mjs";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
//#region src/components/molecules/tabs.d.ts
|
|
5
|
+
declare const Core: typeof Tabs$1;
|
|
6
|
+
interface Item {
|
|
7
|
+
key: string;
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** Decorative icon rendered before the label with consistent spacing. */
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
interface Props extends Omit<React.ComponentProps<typeof Core>, 'children'> {
|
|
15
|
+
items: Item[];
|
|
16
|
+
listLabel?: string;
|
|
17
|
+
/** Preserve inactive panel DOM and local state. */
|
|
18
|
+
keepMounted?: boolean;
|
|
19
|
+
/** Select a tab when arrow-key focus moves to it. */
|
|
20
|
+
activateOnFocus?: boolean;
|
|
21
|
+
/** Scroll the tab list when its items exceed the available space. */
|
|
22
|
+
scrollable?: boolean;
|
|
23
|
+
/** Give tabs equal width in horizontal mode; ignored when scrollable. */
|
|
24
|
+
fitted?: boolean;
|
|
25
|
+
/** Content shown after the tab list, outside the tablist role. */
|
|
26
|
+
extra?: ReactNode;
|
|
27
|
+
classNames?: {
|
|
28
|
+
list?: string;
|
|
29
|
+
tab?: string;
|
|
30
|
+
panel?: string;
|
|
31
|
+
extra?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
declare const Tabs: ({ items, listLabel, keepMounted, activateOnFocus, scrollable, fitted, extra, classNames, defaultValue, orientation, ...props }: Props) => import("react").JSX.Element;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Item, Props, Tabs as default };
|
|
37
|
+
//# sourceMappingURL=tabs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.mts","names":[],"sources":["../../../src/components/molecules/tabs.tsx"],"mappings":";;;;cAQc,aAAI;UAED;EACf;EACA,OAAO;EACP,UAAU;EACV;;EAEA,OAAO;;UAGQ,cAAc,KAC7B,MAAM,sBAAsB;EAG5B,OAAO;EACP;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,QAAQ;EACR;IACE;IACA;IACA;IACA;;;cAIE,SAAQ,OAAA,WAAA,aAAA,iBAAA,YAAA,QAAA,OAAA,YAAA,cAAA,gBAAA,SAYX,0BAAK,IAAA"}
|