@krizaka/ui 3.65.0 → 3.66.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.md +3 -0
- package/dist/account-settings.js +1 -1
- package/dist/action-bar.js +1 -1
- package/dist/app-header/search.js +1 -1
- package/dist/app-header.d.ts +3 -3
- package/dist/app-shell.js +1 -1
- package/dist/argument-card.js +2 -2
- package/dist/audio-player.js +1 -1
- package/dist/{chunk-5QEXOGO2.js → chunk-6BMKLAZ7.js} +1 -1
- package/dist/{chunk-XCBVFMNV.js.map → chunk-6BMKLAZ7.js.map} +1 -1
- package/dist/{chunk-SHBYNQFS.js → chunk-7DYZTEE3.js} +1 -1
- package/dist/{chunk-SHBYNQFS.js.map → chunk-7DYZTEE3.js.map} +1 -1
- package/dist/{chunk-YCZ7N6Q6.js → chunk-7MQNG35Q.js} +2 -2
- package/dist/{chunk-XCBVFMNV.js → chunk-C57KK5VB.js} +7 -2
- package/dist/chunk-C57KK5VB.js.map +1 -0
- package/dist/{chunk-VB7MWE2N.js → chunk-DSDFXPL6.js} +2 -2
- package/dist/{chunk-P7GZR5CU.js → chunk-GFRUTPGG.js} +1 -1
- package/dist/{chunk-P7GZR5CU.js.map → chunk-GFRUTPGG.js.map} +1 -1
- package/dist/{chunk-4GQH27IT.js → chunk-GW5EI7MI.js} +2 -2
- package/dist/{chunk-F6JTHPHE.js → chunk-I6EOLPSH.js} +2 -2
- package/dist/chunk-NG6G6V5E.js +33 -0
- package/dist/{chunk-5QEXOGO2.js.map → chunk-NG6G6V5E.js.map} +1 -1
- package/dist/{chunk-CPA5CF35.js → chunk-PGBF3UBX.js} +1 -1
- package/dist/{chunk-CPA5CF35.js.map → chunk-PGBF3UBX.js.map} +1 -1
- package/dist/{chunk-BG5APGX6.js → chunk-Q5DYWQ6S.js} +4 -4
- package/dist/{chunk-RCKXJEDQ.js → chunk-ST5P5HNI.js} +2 -2
- package/dist/code-block.js +1 -1
- package/dist/collection-switcher.d.ts +68 -0
- package/dist/collection-switcher.js +131 -0
- package/dist/collection-switcher.js.map +1 -0
- package/dist/combobox.js +2 -2
- package/dist/cover-hero.js +1 -1
- package/dist/data-table.js +4 -4
- package/dist/date-picker.js +1 -1
- package/dist/decision-list.js +1 -1
- package/dist/default-avatar-D9kiSFNB.d.ts +26 -0
- package/dist/docs-layout.js +1 -1
- package/dist/entity-header.d.ts +92 -0
- package/dist/entity-header.js +165 -0
- package/dist/entity-header.js.map +1 -0
- package/dist/file-upload.js +1 -1
- package/dist/filter-bar.d.ts +3 -3
- package/dist/filter-bar.js +2 -2
- package/dist/genui.js +4 -4
- package/dist/link-card.js +2 -2
- package/dist/list.js +1 -1
- package/dist/media-capture.js +1 -1
- package/dist/native.d.ts +121 -3
- package/dist/native.js +1770 -1228
- package/dist/native.js.map +1 -1
- package/dist/opening-hours.js +1 -1
- package/dist/page-hero.js +1 -1
- package/dist/pagination.js +1 -1
- package/dist/photo-grid.js +1 -1
- package/dist/pricing-page.js.map +1 -1
- package/dist/qr-code.d.ts +42 -0
- package/dist/qr-code.js +350 -0
- package/dist/qr-code.js.map +1 -0
- package/dist/radio-group.js +1 -1
- package/dist/rail-nav.js +1 -1
- package/dist/retro-tv.js +2 -2
- package/dist/search-field.js +2 -2
- package/dist/service-card.js +1 -1
- package/dist/shop-composer.js +1 -1
- package/dist/shop-composer.js.map +1 -1
- package/dist/site-cahier.js +1 -1
- package/dist/status-chip.js +1 -1
- package/dist/tag-input.js +2 -2
- package/dist/terminal-replay.js +1 -1
- package/dist/tree-view.js +1 -1
- package/dist/video-player.js +2 -2
- package/dist/virtual.d.ts +3 -3
- package/package.json +48 -5
- package/registry/account-menu.json +1 -1
- package/registry/account-settings.json +2 -2
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +2 -2
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +2 -2
- package/registry/app-header.json +2 -2
- package/registry/app-shell.json +2 -2
- package/registry/argument-card.json +2 -2
- package/registry/audio-player.json +2 -2
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +2 -2
- package/registry/collection-switcher.json +436 -0
- package/registry/combobox.json +2 -2
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +2 -2
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +2 -2
- package/registry/date-picker.json +2 -2
- package/registry/decision-list.json +2 -2
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +1 -1
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +2 -2
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +2 -2
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/entity-header.json +502 -0
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/collection-switcher/entity.d.ts +4 -0
- package/registry/examples/collection-switcher/entity.js +17 -0
- package/registry/examples/collection-switcher/entity.tsx +13 -0
- package/registry/examples/collection-switcher/list.d.ts +4 -0
- package/registry/examples/collection-switcher/list.js +32 -0
- package/registry/examples/collection-switcher/list.tsx +27 -0
- package/registry/examples/collection-switcher/native/list.d.ts +4 -0
- package/registry/examples/collection-switcher/native/list.dark.png +0 -0
- package/registry/examples/collection-switcher/native/list.js +18 -0
- package/registry/examples/collection-switcher/native/list.light.png +0 -0
- package/registry/examples/collection-switcher/native/list.tsx +14 -0
- package/registry/examples/collection-switcher/tree.d.ts +4 -0
- package/registry/examples/collection-switcher/tree.js +19 -0
- package/registry/examples/collection-switcher/tree.tsx +15 -0
- package/registry/examples/entity-header/basic.d.ts +4 -0
- package/registry/examples/entity-header/basic.js +31 -0
- package/registry/examples/entity-header/basic.tsx +25 -0
- package/registry/examples/entity-header/native/basic.d.ts +4 -0
- package/registry/examples/entity-header/native/basic.dark.png +0 -0
- package/registry/examples/entity-header/native/basic.js +17 -0
- package/registry/examples/entity-header/native/basic.light.png +0 -0
- package/registry/examples/entity-header/native/basic.tsx +12 -0
- package/registry/examples/qr-code/basic.d.ts +4 -0
- package/registry/examples/qr-code/basic.js +11 -0
- package/registry/examples/qr-code/basic.tsx +6 -0
- package/registry/examples/qr-code/calendar-feed.d.ts +4 -0
- package/registry/examples/qr-code/calendar-feed.js +24 -0
- package/registry/examples/qr-code/calendar-feed.tsx +18 -0
- package/registry/examples/qr-code/native/calendar-feed.d.ts +4 -0
- package/registry/examples/qr-code/native/calendar-feed.dark.png +0 -0
- package/registry/examples/qr-code/native/calendar-feed.js +25 -0
- package/registry/examples/qr-code/native/calendar-feed.light.png +0 -0
- package/registry/examples/qr-code/native/calendar-feed.tsx +19 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +2 -2
- package/registry/filter-bar.json +2 -2
- package/registry/flock.json +1 -1
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/how-it-works-page.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +102 -8
- package/registry/iso.json +1 -1
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +1 -1
- package/registry/kpi-explained.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +2 -2
- package/registry/list.json +2 -2
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +2 -2
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +2 -2
- package/registry/media-gallery.json +1 -1
- package/registry/media-grid.json +1 -1
- package/registry/meta-row.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/nav-bar.json +2 -2
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/opening-hours.json +2 -2
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +2 -2
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +2 -2
- package/registry/photo-grid.json +2 -2
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/pricing-page.json +2 -2
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/qr-code.json +343 -0
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +2 -2
- package/registry/rail-nav.json +3 -3
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +1 -1
- package/registry/reviews.json +1 -1
- package/registry/router.json +1 -1
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +2 -2
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +2 -2
- package/registry/settings-layout.json +1 -1
- package/registry/shop-composer.json +2 -2
- package/registry/shop.json +2 -2
- package/registry/showcase.json +1 -1
- package/registry/signature.json +1 -1
- package/registry/site-cahier.json +1 -1
- package/registry/site-footer.json +2 -2
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/status-chip.json +2 -2
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +2 -2
- package/registry/text-style.json +1 -1
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +2 -2
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +2 -2
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +1 -1
- package/registry/waveform.json +1 -1
- /package/dist/{chunk-YCZ7N6Q6.js.map → chunk-7MQNG35Q.js.map} +0 -0
- /package/dist/{chunk-VB7MWE2N.js.map → chunk-DSDFXPL6.js.map} +0 -0
- /package/dist/{chunk-4GQH27IT.js.map → chunk-GW5EI7MI.js.map} +0 -0
- /package/dist/{chunk-F6JTHPHE.js.map → chunk-I6EOLPSH.js.map} +0 -0
- /package/dist/{chunk-BG5APGX6.js.map → chunk-Q5DYWQ6S.js.map} +0 -0
- /package/dist/{chunk-RCKXJEDQ.js.map → chunk-ST5P5HNI.js.map} +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
ChevronGlyph,
|
|
4
|
+
CloseGlyph,
|
|
5
|
+
PlusGlyph
|
|
6
|
+
} from "./chunk-NG6G6V5E.js";
|
|
7
|
+
|
|
8
|
+
// src/collection-switcher/collection-switcher.tsx
|
|
9
|
+
import { Avatar } from "@krizaka/ui/avatar";
|
|
10
|
+
import { cn } from "@krizaka/ui/cn";
|
|
11
|
+
import { Popover } from "@krizaka/ui/popover";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
|
|
14
|
+
// src/collection-switcher/tree.ts
|
|
15
|
+
function collectionTree(items) {
|
|
16
|
+
const byId = new Map(items.map((item) => [item.id, item]));
|
|
17
|
+
const branches = new Map(items.map((item) => [item.id, { item, children: [] }]));
|
|
18
|
+
const roots = [];
|
|
19
|
+
const reaches = (start, target) => {
|
|
20
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21
|
+
for (let id = start; id && !seen.has(id); id = byId.get(id)?.parentId) {
|
|
22
|
+
if (id === target) return true;
|
|
23
|
+
seen.add(id);
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
for (const item of items) {
|
|
28
|
+
const parent = item.parentId && item.parentId !== item.id && byId.has(item.parentId) && !reaches(item.parentId, item.id) ? branches.get(item.parentId) : void 0;
|
|
29
|
+
(parent ? parent.children : roots).push(branches.get(item.id));
|
|
30
|
+
}
|
|
31
|
+
return roots;
|
|
32
|
+
}
|
|
33
|
+
var isRemovable = (item) => !item.isDefault;
|
|
34
|
+
|
|
35
|
+
// src/collection-switcher/collection-switcher.tsx
|
|
36
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
37
|
+
function Row({ branch, value, props }) {
|
|
38
|
+
const { item, children } = branch;
|
|
39
|
+
const current = item.id === value;
|
|
40
|
+
const { href, onValueChange, defaultLabel, onRemove, removeLabel, close } = props;
|
|
41
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
+
item.avatar ? /* @__PURE__ */ jsx(Avatar, { size: "xs", alt: "", ...item.avatar }) : null,
|
|
43
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: item.name }),
|
|
44
|
+
item.isDefault ? /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded-full border border-border-default px-1.5 text-[11px] text-fg-secondary", children: defaultLabel }) : null,
|
|
45
|
+
item.count !== void 0 ? /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs tabular-nums text-fg-muted", children: item.count }) : null
|
|
46
|
+
] });
|
|
47
|
+
const shared = {
|
|
48
|
+
"aria-current": current ? "page" : void 0,
|
|
49
|
+
className: cn(
|
|
50
|
+
"flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-sm text-fg hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-ring",
|
|
51
|
+
current && "bg-surface-2 font-medium"
|
|
52
|
+
),
|
|
53
|
+
onClick: () => {
|
|
54
|
+
onValueChange?.(item.id);
|
|
55
|
+
close?.();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ jsxs("li", { "data-collection": item.id, children: [
|
|
59
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
60
|
+
href ? /* @__PURE__ */ jsx("a", { href: href(item.id), ...shared, children: content }) : /* @__PURE__ */ jsx("button", { type: "button", ...shared, children: content }),
|
|
61
|
+
onRemove && isRemovable(item) ? /* @__PURE__ */ jsx(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
type: "button",
|
|
65
|
+
"aria-label": removeLabel?.(item.name) ?? item.name,
|
|
66
|
+
onClick: () => onRemove(item.id),
|
|
67
|
+
className: "shrink-0 rounded-md p-1.5 text-fg-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-ring",
|
|
68
|
+
children: /* @__PURE__ */ jsx(CloseGlyph, { "aria-hidden": true, className: "h-3.5 w-3.5" })
|
|
69
|
+
}
|
|
70
|
+
) : null
|
|
71
|
+
] }),
|
|
72
|
+
children.length ? /* @__PURE__ */ jsx("ul", { className: "m-0 ms-4 flex list-none flex-col gap-0.5 border-s border-border-subtle p-0 ps-1", children: children.map((child) => /* @__PURE__ */ jsx(Row, { branch: child, value, props }, child.item.id)) }) : null
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
function Body(props) {
|
|
76
|
+
const { collections, value, label, layout = "list", onCreate, createLabel, close } = props;
|
|
77
|
+
const branches = React.useMemo(() => layout === "tree" ? collectionTree(collections) : collections.map((item) => ({ item, children: [] })), [collections, layout]);
|
|
78
|
+
const create = onCreate ? /* @__PURE__ */ jsxs(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
onClick: () => {
|
|
83
|
+
onCreate();
|
|
84
|
+
close?.();
|
|
85
|
+
},
|
|
86
|
+
className: "mt-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-sm text-fg-secondary hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-ring",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx(PlusGlyph, { "aria-hidden": true, className: "h-3.5 w-3.5" }),
|
|
89
|
+
createLabel
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
) : null;
|
|
93
|
+
return /* @__PURE__ */ jsxs("nav", { "aria-label": label, children: [
|
|
94
|
+
/* @__PURE__ */ jsx("ul", { className: "m-0 flex list-none flex-col gap-0.5 p-0", children: branches.map((branch) => /* @__PURE__ */ jsx(Row, { branch, value, props }, branch.item.id)) }),
|
|
95
|
+
create
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
function CollectionSwitcher(props) {
|
|
99
|
+
const { mode = "collection", collections, value, label, className } = props;
|
|
100
|
+
const [open, setOpen] = React.useState(false);
|
|
101
|
+
if (mode === "collection") {
|
|
102
|
+
return /* @__PURE__ */ jsx("div", { className, "data-collection-switcher": true, children: /* @__PURE__ */ jsx(Body, { ...props }) });
|
|
103
|
+
}
|
|
104
|
+
const current = collections.find((c) => c.id === value);
|
|
105
|
+
return /* @__PURE__ */ jsxs(Popover.Root, { open, onOpenChange: setOpen, children: [
|
|
106
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
107
|
+
"button",
|
|
108
|
+
{
|
|
109
|
+
type: "button",
|
|
110
|
+
"aria-label": current ? `${current.name}, ${label}` : label,
|
|
111
|
+
className: cn(
|
|
112
|
+
"inline-flex max-w-full items-center gap-2 rounded-md border border-border-control bg-surface-1 px-2.5 py-1.5 text-sm text-fg hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
|
|
113
|
+
className
|
|
114
|
+
),
|
|
115
|
+
"data-collection-switcher": true,
|
|
116
|
+
children: [
|
|
117
|
+
current?.avatar ? /* @__PURE__ */ jsx(Avatar, { size: "xs", alt: "", ...current.avatar }) : null,
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: current?.name ?? label }),
|
|
119
|
+
/* @__PURE__ */ jsx(ChevronGlyph, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-fg-muted" })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
) }),
|
|
123
|
+
/* @__PURE__ */ jsx(Popover.Content, { align: "start", className: "w-72 p-2", children: /* @__PURE__ */ jsx(Body, { ...props, close: () => setOpen(false) }) })
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
CollectionSwitcher,
|
|
128
|
+
collectionTree,
|
|
129
|
+
isRemovable
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=collection-switcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/collection-switcher/collection-switcher.tsx","../src/collection-switcher/tree.ts"],"sourcesContent":["// Client (the open state of the entity popover, the tree's keyboard). Moves between the collections of a workspace — or,\n// in `entity` mode, between the shops or studios of an account. The current one is held by the URL: the product passes\n// `value` from it and navigates in `onValueChange` (or gives `href`, and each row is a real link).\nimport { Avatar } from \"@krizaka/ui/avatar\";\nimport { cn } from \"@krizaka/ui/cn\";\nimport { Popover } from \"@krizaka/ui/popover\";\nimport * as React from \"react\";\n\nimport { ChevronGlyph, CloseGlyph, PlusGlyph } from \"../glyphs\";\nimport { type CollectionBranch, type CollectionItem, collectionTree, isRemovable } from \"./tree\";\n\nexport type CollectionSwitcherProps = {\n /** The collections, flat; `parentId` nests them in the `tree` layout. */\n collections: readonly CollectionItem[];\n /** The current one (read from the URL), or `null`. */\n value: string | null;\n /** The viewer chooses a collection: navigate (push the URL). */\n onValueChange?: (id: string) => void;\n /** Gives each row of the `list` layout a real address (open in a new tab, SSR); a click still calls `onValueChange`. */\n href?: (id: string) => string;\n /** The accessible name (“Collections”) — passed translated. */\n label: string;\n /**\n * `list`: a flat list. `tree`: the nesting by `parentId`, as nested lists (every row stays a link or a button, in the tab order).\n * @default \"list\"\n */\n layout?: \"list\" | \"tree\";\n /**\n * `collection`: the list or the tree itself. `entity`: a compact button showing the current one that opens it, to switch shop or studio from the shell.\n * @default \"collection\"\n */\n mode?: \"collection\" | \"entity\";\n /** The mark on the default collection (“Default”), passed translated. */\n defaultLabel: string;\n /** Removes a collection — never offered on the default one. Without it there is no remove action. */\n onRemove?: (id: string) => void;\n /** The remove button's accessible name for a collection (“Remove Archive”), passed translated. */\n removeLabel?: (name: string) => string;\n /** Adds a collection: a row at the end. Without it there is none. */\n onCreate?: () => void;\n /** The create row's words (“New collection”), passed translated. */\n createLabel?: string;\n /** Classes merged last, on the switcher. */\n className?: string;\n};\n\nfunction Row({ branch, value, props }: { branch: CollectionBranch; value: string | null; props: CollectionSwitcherProps & { close?: () => void } }) {\n const { item, children } = branch;\n const current = item.id === value;\n const { href, onValueChange, defaultLabel, onRemove, removeLabel, close } = props;\n const content = (\n <>\n {item.avatar ? <Avatar size=\"xs\" alt=\"\" {...item.avatar} /> : null}\n <span className=\"min-w-0 flex-1 truncate\">{item.name}</span>\n {item.isDefault ? <span className=\"shrink-0 rounded-full border border-border-default px-1.5 text-[11px] text-fg-secondary\">{defaultLabel}</span> : null}\n {item.count !== undefined ? <span className=\"shrink-0 text-xs tabular-nums text-fg-muted\">{item.count}</span> : null}\n </>\n );\n const shared = {\n \"aria-current\": current ? (\"page\" as const) : undefined,\n className: cn(\n \"flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-sm text-fg hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-ring\",\n current && \"bg-surface-2 font-medium\",\n ),\n onClick: () => {\n onValueChange?.(item.id);\n close?.();\n },\n };\n return (\n <li data-collection={item.id}>\n <div className=\"flex items-center gap-1\">\n {href ? (\n <a href={href(item.id)} {...shared}>\n {content}\n </a>\n ) : (\n <button type=\"button\" {...shared}>\n {content}\n </button>\n )}\n {onRemove && isRemovable(item) ? (\n <button\n type=\"button\"\n aria-label={removeLabel?.(item.name) ?? item.name}\n onClick={() => onRemove(item.id)}\n className=\"shrink-0 rounded-md p-1.5 text-fg-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-ring\"\n >\n <CloseGlyph aria-hidden className=\"h-3.5 w-3.5\" />\n </button>\n ) : null}\n </div>\n {children.length ? (\n <ul className=\"m-0 ms-4 flex list-none flex-col gap-0.5 border-s border-border-subtle p-0 ps-1\">\n {children.map((child) => (\n <Row key={child.item.id} branch={child} value={value} props={props} />\n ))}\n </ul>\n ) : null}\n </li>\n );\n}\n\nfunction Body(props: CollectionSwitcherProps & { close?: () => void }) {\n const { collections, value, label, layout = \"list\", onCreate, createLabel, close } = props;\n const branches = React.useMemo(() => (layout === \"tree\" ? collectionTree(collections) : collections.map((item) => ({ item, children: [] }))), [collections, layout]);\n const create = onCreate ? (\n <button\n type=\"button\"\n onClick={() => {\n onCreate();\n close?.();\n }}\n className=\"mt-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-sm text-fg-secondary hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-ring\"\n >\n <PlusGlyph aria-hidden className=\"h-3.5 w-3.5\" />\n {createLabel}\n </button>\n ) : null;\n return (\n <nav aria-label={label}>\n <ul className=\"m-0 flex list-none flex-col gap-0.5 p-0\">\n {branches.map((branch) => (\n <Row key={branch.item.id} branch={branch} value={value} props={props} />\n ))}\n </ul>\n {create}\n </nav>\n );\n}\n\n/** The collections of a workspace — or the shops of an account — to move between; the default one marked and never removable. */\nexport function CollectionSwitcher(props: CollectionSwitcherProps) {\n const { mode = \"collection\", collections, value, label, className } = props;\n const [open, setOpen] = React.useState(false);\n if (mode === \"collection\") {\n return (\n <div className={className} data-collection-switcher>\n <Body {...props} />\n </div>\n );\n }\n const current = collections.find((c) => c.id === value);\n return (\n <Popover.Root open={open} onOpenChange={setOpen}>\n <Popover.Trigger asChild>\n <button\n type=\"button\"\n aria-label={current ? `${current.name}, ${label}` : label}\n className={cn(\n \"inline-flex max-w-full items-center gap-2 rounded-md border border-border-control bg-surface-1 px-2.5 py-1.5 text-sm text-fg hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\n className,\n )}\n data-collection-switcher\n >\n {current?.avatar ? <Avatar size=\"xs\" alt=\"\" {...current.avatar} /> : null}\n <span className=\"min-w-0 truncate\">{current?.name ?? label}</span>\n <ChevronGlyph aria-hidden className=\"h-3.5 w-3.5 shrink-0 text-fg-muted\" />\n </button>\n </Popover.Trigger>\n <Popover.Content align=\"start\" className=\"w-72 p-2\">\n <Body {...props} close={() => setOpen(false)} />\n </Popover.Content>\n </Popover.Root>\n );\n}\n","// Pure helpers of the collection switcher: the nesting of a flat list, and what may be removed. No React and no web\n// component: the native switcher imports this file.\nimport type { DefaultAvatar } from \"../avatar/default-avatar\";\n\nexport type CollectionItem = {\n /** A stable id. */\n id: string;\n /** Its name — it is the user's own text, never translated. */\n name: string;\n /** The collection it is nested in; `null`/missing for a root. An unknown parent makes it a root (nothing is lost). */\n parentId?: string | null;\n /** The default collection: marked, and never removable. */\n isDefault?: boolean;\n /** How many items it holds. */\n count?: number;\n /** Its picture (a shop or studio in `entity` mode). */\n avatar?: { src?: string | null; defaultAvatar?: DefaultAvatar };\n};\n\nexport type CollectionBranch = { item: CollectionItem; children: CollectionBranch[] };\n\n/** The forest of a flat list, in the order given; a cycle or an unknown parent never hides a collection. */\nexport function collectionTree(items: readonly CollectionItem[]): CollectionBranch[] {\n const byId = new Map(items.map((item) => [item.id, item]));\n const branches = new Map<string, CollectionBranch>(items.map((item) => [item.id, { item, children: [] }]));\n const roots: CollectionBranch[] = [];\n const reaches = (start: string, target: string): boolean => {\n const seen = new Set<string>();\n for (let id: string | null | undefined = start; id && !seen.has(id); id = byId.get(id)?.parentId) {\n if (id === target) return true;\n seen.add(id);\n }\n return false;\n };\n for (const item of items) {\n const parent = item.parentId && item.parentId !== item.id && byId.has(item.parentId) && !reaches(item.parentId, item.id) ? branches.get(item.parentId) : undefined;\n (parent ? parent.children : roots).push(branches.get(item.id)!);\n }\n return roots;\n}\n\n/** The default collection is never removable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,mBAAS,QAAQ,OAAM;AAAA,UAC3D,oBAAC,gBAAa,eAAW,MAAC,WAAU,sCAAqC;AAAA;AAAA;AAAA,IAC3E,GACF;AAAA,IACA,oBAAC,QAAQ,SAAR,EAAgB,OAAM,SAAQ,WAAU,YACvC,8BAAC,QAAM,GAAG,OAAO,OAAO,MAAM,QAAQ,KAAK,GAAG,GAChD;AAAA,KACF;AAEJ;","names":[]}
|
package/dist/combobox.js
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
Combobox,
|
|
4
4
|
combobox,
|
|
5
5
|
comboboxLabels
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GW5EI7MI.js";
|
|
7
7
|
import "./chunk-UYGUSYIC.js";
|
|
8
8
|
import "./chunk-D3T54RSL.js";
|
|
9
9
|
import "./chunk-NSLXEDIS.js";
|
|
10
10
|
import "./chunk-ZIXB33X7.js";
|
|
11
11
|
import "./chunk-FZBWEDQI.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-PGBF3UBX.js";
|
|
13
13
|
export {
|
|
14
14
|
Combobox,
|
|
15
15
|
combobox,
|
package/dist/cover-hero.js
CHANGED
package/dist/data-table.js
CHANGED
|
@@ -17,20 +17,20 @@ import {
|
|
|
17
17
|
selectionBarLabels,
|
|
18
18
|
useDataTable,
|
|
19
19
|
writeTable
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Q5DYWQ6S.js";
|
|
21
21
|
import "./chunk-3X3OF4TI.js";
|
|
22
22
|
import "./chunk-JXLDUDTD.js";
|
|
23
23
|
import "./chunk-M3GEYLMR.js";
|
|
24
24
|
import "./chunk-KVDB4GXV.js";
|
|
25
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-I6EOLPSH.js";
|
|
26
26
|
import "./chunk-UYGUSYIC.js";
|
|
27
27
|
import "./chunk-D3T54RSL.js";
|
|
28
28
|
import "./chunk-J3NC6ER4.js";
|
|
29
29
|
import "./chunk-NSLXEDIS.js";
|
|
30
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-DSDFXPL6.js";
|
|
31
31
|
import "./chunk-ZIXB33X7.js";
|
|
32
32
|
import "./chunk-FZBWEDQI.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-PGBF3UBX.js";
|
|
34
34
|
export {
|
|
35
35
|
DataTable,
|
|
36
36
|
DataTableColumnsMenu,
|
package/dist/date-picker.js
CHANGED
package/dist/decision-list.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** A brand of the default avatars. `orochia`, `yasakia`, `yororis` and `kachizaka` are deprecated: paused products (2026-10-25), removed in the next major; their pictures stay served until then. */
|
|
2
|
+
type DefaultAvatarBrand = "krizaka" | "orazaka" | "orochia" | "yasakia" | "yororis" | "yomizaka" | "kachizaka" | "akinaza";
|
|
3
|
+
/**
|
|
4
|
+
* What the picture is of. `person`: a neutral silhouette. `plain`: the brand's gradient alone, ready for initials.
|
|
5
|
+
* `folder`, `organisation` and `shop` are the pictures of a thing that is not a person (a folder or collection, a company, a shop):
|
|
6
|
+
* a glyph on the gradient, never a silhouette. The central sets of these kinds are in the Krizaka org JSON (`defaults`, `@krizaka/org`).
|
|
7
|
+
*/
|
|
8
|
+
type DefaultAvatarKind = "person" | "plain" | "folder" | "organisation" | "shop";
|
|
9
|
+
/** The kinds of entity that have a set of default pictures of their own (`plain` is a style of `person`). */
|
|
10
|
+
type DefaultAvatarEntityKind = "person" | "folder" | "organisation" | "shop";
|
|
11
|
+
interface DefaultAvatar {
|
|
12
|
+
/** The brand of the product showing the avatar: its gradient, its hues. */
|
|
13
|
+
brand: DefaultAvatarBrand;
|
|
14
|
+
/** Any stable text or number of the person (their id): the same seed gives the same tone everywhere. */
|
|
15
|
+
seed?: string | number;
|
|
16
|
+
/** Force a tone, 1 to 6, instead of deriving it from `seed`. */
|
|
17
|
+
tone?: number;
|
|
18
|
+
/**
|
|
19
|
+
* `person` (default): a silhouette. `plain`: the gradient alone. `folder`, `organisation`, `shop`: that thing's glyph, drawn here
|
|
20
|
+
* (a data URL, no request) — a folder is never given a person.
|
|
21
|
+
* @default "person"
|
|
22
|
+
*/
|
|
23
|
+
kind?: DefaultAvatarKind;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type { DefaultAvatar as D, DefaultAvatarEntityKind as a };
|
package/dist/docs-layout.js
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Marker, OrganizeCode } from '@krizaka/organize/contract';
|
|
3
|
+
import { D as DefaultAvatar, a as DefaultAvatarEntityKind } from './default-avatar-D9kiSFNB.js';
|
|
4
|
+
|
|
5
|
+
/** The refusals a header knows how to say: the product passes the words (translated) for the codes it can get. */
|
|
6
|
+
type EntityRefusals = Partial<Record<OrganizeCode, string>>;
|
|
7
|
+
/** The entity's picture: an address, or one of Krizaka's default pictures. */
|
|
8
|
+
type EntityAvatar = {
|
|
9
|
+
src?: string | null;
|
|
10
|
+
defaultAvatar?: DefaultAvatar;
|
|
11
|
+
fallback?: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/** One picture to choose from (the shape of `AvatarPicker`'s options). */
|
|
14
|
+
type EntityAvatarOption = {
|
|
15
|
+
/** The value of the choice. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Its name for assistive technology, passed translated. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** A picture's address; otherwise `defaultAvatar` draws one of the family's pictures. */
|
|
20
|
+
src?: string;
|
|
21
|
+
/** One of Krizaka's default pictures. */
|
|
22
|
+
defaultAvatar?: DefaultAvatar;
|
|
23
|
+
/** What this picture is of. */
|
|
24
|
+
kind?: DefaultAvatarEntityKind;
|
|
25
|
+
};
|
|
26
|
+
type EntityTag = {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
marker: Marker;
|
|
30
|
+
};
|
|
31
|
+
/** The props both platforms take: plain data, the editing callbacks, the refusals. */
|
|
32
|
+
type EntityHeaderBase = {
|
|
33
|
+
/** The entity's name. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Makes the name editable in place: called with the trimmed new name. Throw (or reject with) an error carrying a `code` to show its refusal. */
|
|
36
|
+
onNameChange?: (name: string) => void | Promise<void>;
|
|
37
|
+
/** What editing the name does (“Rename the collection”), passed translated: the field's name, and the button's after the visible name. */
|
|
38
|
+
nameLabel?: string;
|
|
39
|
+
/** One line under the name. */
|
|
40
|
+
description?: string;
|
|
41
|
+
/** Makes the description editable in place. Same contract as `onNameChange`. */
|
|
42
|
+
onDescriptionChange?: (description: string) => void | Promise<void>;
|
|
43
|
+
/** What editing the description does (“Edit the description”), passed translated: the field's name, and the button's after the visible text. */
|
|
44
|
+
descriptionLabel?: string;
|
|
45
|
+
/** Shown when there is no description and it is editable (“Add a description”), passed translated. */
|
|
46
|
+
descriptionPlaceholder?: string;
|
|
47
|
+
/** The picture. */
|
|
48
|
+
avatar?: EntityAvatar;
|
|
49
|
+
/** The entity's tags. */
|
|
50
|
+
tags?: readonly EntityTag[];
|
|
51
|
+
/** A refusal to say now (the last answer of the server), by its code. */
|
|
52
|
+
refusal?: {
|
|
53
|
+
code: OrganizeCode;
|
|
54
|
+
} | null;
|
|
55
|
+
/** The messages by refusal code: `NAME_TAKEN`, `AVATAR_NOT_ALLOWED`, `DEFAULT_COLLECTION`, … A code with no message says nothing. */
|
|
56
|
+
refusals?: EntityRefusals;
|
|
57
|
+
/** After the text: the actions of the entity (a menu, a button). */
|
|
58
|
+
actions?: React.ReactNode;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type EntityHeaderProps = EntityHeaderBase & {
|
|
62
|
+
/** Makes the picture changeable: a button over it opens the library's `AvatarPicker`. */
|
|
63
|
+
avatarPicker?: {
|
|
64
|
+
/** The picker's accessible name (“Profile picture”), passed translated. */
|
|
65
|
+
label: string;
|
|
66
|
+
/** What the pictures are of: `folder`, `organisation`, `shop`, `person`. */
|
|
67
|
+
kind?: EntityAvatarOption["kind"];
|
|
68
|
+
/** The pictures to choose from. */
|
|
69
|
+
options: readonly EntityAvatarOption[];
|
|
70
|
+
/** Adds a « no picture » tile first, with these words, passed translated. */
|
|
71
|
+
noneLabel?: string;
|
|
72
|
+
/** The chosen id. */
|
|
73
|
+
value?: string;
|
|
74
|
+
/** The viewer chooses another picture. */
|
|
75
|
+
onValueChange?: (id: string) => void;
|
|
76
|
+
/** The accessible name of the picture's button (“Change the picture”), passed translated. */
|
|
77
|
+
triggerLabel: string;
|
|
78
|
+
};
|
|
79
|
+
/** The accessible name of the tags' list (“Tags”), passed translated. */
|
|
80
|
+
tagsLabel?: string;
|
|
81
|
+
/** Lets the viewer remove a tag: each `TagChip` gets a remove button. Without it the tags are read-only labels. */
|
|
82
|
+
onTagRemove?: (id: string) => void;
|
|
83
|
+
/** The remove button's accessible name for a tag (“Remove Seasonal”), passed translated. */
|
|
84
|
+
tagRemoveLabel?: (label: string) => string;
|
|
85
|
+
/** Classes merged last, on the header. */
|
|
86
|
+
className?: string;
|
|
87
|
+
};
|
|
88
|
+
/** The head of an entity: picture, name and description editable in place, tags, a refusal said in words, actions. */
|
|
89
|
+
declare function EntityHeader({ name, onNameChange, nameLabel, description, onDescriptionChange, descriptionLabel, descriptionPlaceholder, avatar, avatarPicker, tags, tagsLabel, onTagRemove, tagRemoveLabel, refusal, refusals, actions, className, }: EntityHeaderProps): React.JSX.Element;
|
|
90
|
+
|
|
91
|
+
export { EntityHeader };
|
|
92
|
+
export type { EntityHeaderProps, EntityRefusals, EntityTag };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
PencilGlyph
|
|
4
|
+
} from "./chunk-NG6G6V5E.js";
|
|
5
|
+
|
|
6
|
+
// src/entity-header/entity-header.tsx
|
|
7
|
+
import { AvatarPicker } from "@krizaka/ui/account-settings";
|
|
8
|
+
import { Avatar } from "@krizaka/ui/avatar";
|
|
9
|
+
import { TagChip, TagMarker } from "@krizaka/ui/chip";
|
|
10
|
+
import { cn } from "@krizaka/ui/cn";
|
|
11
|
+
import { Popover } from "@krizaka/ui/popover";
|
|
12
|
+
import * as React2 from "react";
|
|
13
|
+
|
|
14
|
+
// src/entity-header/shared.ts
|
|
15
|
+
import * as React from "react";
|
|
16
|
+
function refusalCode(error) {
|
|
17
|
+
const code = typeof error === "object" && error !== null ? error.code : void 0;
|
|
18
|
+
return typeof code === "string" ? code : void 0;
|
|
19
|
+
}
|
|
20
|
+
var editName = (visible, placeholder, label) => `${visible || placeholder || ""} (${label})`.trim();
|
|
21
|
+
function useEditable(value, onCommit, onRefusal, required) {
|
|
22
|
+
const [editing, setEditing] = React.useState(false);
|
|
23
|
+
const [draft, setDraft] = React.useState(value);
|
|
24
|
+
const [pending, setPending] = React.useState(false);
|
|
25
|
+
const open = () => {
|
|
26
|
+
setDraft(value);
|
|
27
|
+
setEditing(true);
|
|
28
|
+
};
|
|
29
|
+
const stop = () => {
|
|
30
|
+
setEditing(false);
|
|
31
|
+
setDraft(value);
|
|
32
|
+
};
|
|
33
|
+
const commit = async () => {
|
|
34
|
+
if (pending) return;
|
|
35
|
+
const next = draft.trim();
|
|
36
|
+
if (!onCommit || next === value || required && next === "") return stop();
|
|
37
|
+
setPending(true);
|
|
38
|
+
try {
|
|
39
|
+
await onCommit(next);
|
|
40
|
+
onRefusal(void 0);
|
|
41
|
+
setEditing(false);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
onRefusal(refusalCode(error));
|
|
44
|
+
} finally {
|
|
45
|
+
setPending(false);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return { editing, draft, setDraft, pending, open, stop, commit };
|
|
49
|
+
}
|
|
50
|
+
function useRefusal(refusal, refusals) {
|
|
51
|
+
const [local, setLocal] = React.useState();
|
|
52
|
+
const code = local ?? refusal?.code;
|
|
53
|
+
return { message: code ? refusals?.[code] : void 0, setLocal };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/entity-header/entity-header.tsx
|
|
57
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
58
|
+
function Editable({ value, label, placeholder, onCommit, onRefusal, className, inputClassName, required, multiline }) {
|
|
59
|
+
const { editing, draft, setDraft, pending, open, stop, commit } = useEditable(value, onCommit, onRefusal, required);
|
|
60
|
+
const input = React2.useRef(null);
|
|
61
|
+
React2.useEffect(() => {
|
|
62
|
+
if (editing) input.current?.focus();
|
|
63
|
+
}, [editing, pending]);
|
|
64
|
+
if (!onCommit) return value ? /* @__PURE__ */ jsx("p", { className, children: value }) : null;
|
|
65
|
+
if (!editing) {
|
|
66
|
+
return /* @__PURE__ */ jsxs(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
type: "button",
|
|
70
|
+
"aria-label": editName(value, placeholder, label),
|
|
71
|
+
onClick: open,
|
|
72
|
+
className: cn(className, "group/edit -mx-1 inline-flex max-w-full items-center gap-2 rounded-md px-1 text-start hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"),
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate", !value && "text-fg-muted"), children: value || placeholder }),
|
|
75
|
+
/* @__PURE__ */ jsx(PencilGlyph, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-fg-muted opacity-0 group-hover/edit:opacity-100 group-focus-visible/edit:opacity-100 [@media(hover:none)]:opacity-100" })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const shared = {
|
|
81
|
+
ref: input,
|
|
82
|
+
value: draft,
|
|
83
|
+
"aria-label": label,
|
|
84
|
+
disabled: pending,
|
|
85
|
+
onChange: (event) => setDraft(event.target.value),
|
|
86
|
+
onBlur: () => void commit(),
|
|
87
|
+
onKeyDown: (event) => {
|
|
88
|
+
if (event.key === "Escape") {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
stop();
|
|
91
|
+
} else if (event.key === "Enter" && !(multiline && event.shiftKey)) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
void commit();
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
className: cn(inputClassName, "w-full rounded-md border border-border-control bg-surface-1 px-2 py-1 outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring")
|
|
97
|
+
};
|
|
98
|
+
return multiline ? /* @__PURE__ */ jsx("textarea", { rows: 2, ...shared }) : /* @__PURE__ */ jsx("input", { type: "text", ...shared });
|
|
99
|
+
}
|
|
100
|
+
function EntityHeader({
|
|
101
|
+
name,
|
|
102
|
+
onNameChange,
|
|
103
|
+
nameLabel = name,
|
|
104
|
+
description,
|
|
105
|
+
onDescriptionChange,
|
|
106
|
+
descriptionLabel = "Description",
|
|
107
|
+
descriptionPlaceholder,
|
|
108
|
+
avatar,
|
|
109
|
+
avatarPicker,
|
|
110
|
+
tags,
|
|
111
|
+
tagsLabel,
|
|
112
|
+
onTagRemove,
|
|
113
|
+
tagRemoveLabel,
|
|
114
|
+
refusal,
|
|
115
|
+
refusals,
|
|
116
|
+
actions,
|
|
117
|
+
className
|
|
118
|
+
}) {
|
|
119
|
+
const { message, setLocal } = useRefusal(refusal, refusals);
|
|
120
|
+
const picture = /* @__PURE__ */ jsx(Avatar, { size: "xl", alt: "", ...avatar });
|
|
121
|
+
const errorId = React2.useId();
|
|
122
|
+
return /* @__PURE__ */ jsxs("header", { className: cn("flex flex-wrap items-start gap-4", className), "data-entity-header": true, children: [
|
|
123
|
+
avatarPicker ? /* @__PURE__ */ jsxs(Popover.Root, { children: [
|
|
124
|
+
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { type: "button", "aria-label": avatarPicker.triggerLabel, className: "shrink-0 rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", children: picture }) }),
|
|
125
|
+
/* @__PURE__ */ jsx(Popover.Content, { className: "w-80", align: "start", children: /* @__PURE__ */ jsx(AvatarPicker, { ...avatarPicker, dense: true }) })
|
|
126
|
+
] }) : avatar ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: picture }) : null,
|
|
127
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
128
|
+
/* @__PURE__ */ jsx("h1", { className: "m-0 min-w-0 text-xl font-semibold text-fg-title", children: /* @__PURE__ */ jsx(
|
|
129
|
+
Editable,
|
|
130
|
+
{
|
|
131
|
+
value: name,
|
|
132
|
+
label: nameLabel,
|
|
133
|
+
onCommit: onNameChange,
|
|
134
|
+
onRefusal: setLocal,
|
|
135
|
+
className: "text-xl font-semibold text-fg-title",
|
|
136
|
+
inputClassName: "text-xl font-semibold text-fg-title",
|
|
137
|
+
required: true
|
|
138
|
+
}
|
|
139
|
+
) }),
|
|
140
|
+
description || onDescriptionChange ? /* @__PURE__ */ jsx(
|
|
141
|
+
Editable,
|
|
142
|
+
{
|
|
143
|
+
value: description ?? "",
|
|
144
|
+
label: descriptionLabel,
|
|
145
|
+
placeholder: descriptionPlaceholder,
|
|
146
|
+
onCommit: onDescriptionChange,
|
|
147
|
+
onRefusal: setLocal,
|
|
148
|
+
className: "text-sm text-fg-secondary",
|
|
149
|
+
inputClassName: "text-sm text-fg-secondary",
|
|
150
|
+
multiline: true
|
|
151
|
+
}
|
|
152
|
+
) : null,
|
|
153
|
+
tags?.length ? /* @__PURE__ */ jsx("ul", { "aria-label": tagsLabel, className: "m-0 mt-1 flex list-none flex-wrap gap-1.5 p-0", children: tags.map((tag) => /* @__PURE__ */ jsx("li", { children: onTagRemove ? /* @__PURE__ */ jsx(TagChip, { marker: tag.marker, removable: true, removeLabel: tagRemoveLabel?.(tag.label) ?? tag.label, onRemove: () => onTagRemove(tag.id), children: tag.label }) : /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-border-default px-2.5 py-0.5 text-xs text-fg", children: [
|
|
154
|
+
/* @__PURE__ */ jsx(TagMarker, { marker: tag.marker }),
|
|
155
|
+
tag.label
|
|
156
|
+
] }) }, tag.id)) }) : null,
|
|
157
|
+
message ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "m-0 text-sm text-danger-text", children: message }) : null
|
|
158
|
+
] }),
|
|
159
|
+
actions ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions }) : null
|
|
160
|
+
] });
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
EntityHeader
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=entity-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entity-header/entity-header.tsx","../src/entity-header/shared.ts"],"sourcesContent":["// Client (inline editing, the avatar popover). The head of an entity — a collection, a shop, a studio: its picture, its\n// name and description edited where they are read, its tags. Plain data in (the shapes of `@krizaka/organize/contract`),\n// a refusal `code` out, mapped to the message the product passes.\nimport { AvatarPicker } from \"@krizaka/ui/account-settings\";\nimport { Avatar } from \"@krizaka/ui/avatar\";\nimport { TagChip, TagMarker } from \"@krizaka/ui/chip\";\nimport { cn } from \"@krizaka/ui/cn\";\nimport { Popover } from \"@krizaka/ui/popover\";\nimport * as React from \"react\";\n\nimport { PencilGlyph } from \"../glyphs\";\nimport { type EditableBase, editName, type EntityAvatarOption, type EntityHeaderBase, type EntityRefusals, type EntityTag, useEditable, useRefusal } from \"./shared\";\n\nexport type { EntityRefusals, EntityTag };\n\nexport type EntityHeaderProps = EntityHeaderBase & {\n /** Makes the picture changeable: a button over it opens the library's `AvatarPicker`. */\n avatarPicker?: {\n /** The picker's accessible name (“Profile picture”), passed translated. */\n label: string;\n /** What the pictures are of: `folder`, `organisation`, `shop`, `person`. */\n kind?: EntityAvatarOption[\"kind\"];\n /** The pictures to choose from. */\n options: readonly EntityAvatarOption[];\n /** Adds a « no picture » tile first, with these words, passed translated. */\n noneLabel?: string;\n /** The chosen id. */\n value?: string;\n /** The viewer chooses another picture. */\n onValueChange?: (id: string) => void;\n /** The accessible name of the picture's button (“Change the picture”), passed translated. */\n triggerLabel: string;\n };\n /** The accessible name of the tags' list (“Tags”), passed translated. */\n tagsLabel?: string;\n /** Lets the viewer remove a tag: each `TagChip` gets a remove button. Without it the tags are read-only labels. */\n onTagRemove?: (id: string) => void;\n /** The remove button's accessible name for a tag (“Remove Seasonal”), passed translated. */\n tagRemoveLabel?: (label: string) => string;\n /** Classes merged last, on the header. */\n className?: string;\n};\n\ntype EditableProps = EditableBase & { className: string; inputClassName: string; multiline?: boolean };\n\n/** Text that reads as text and edits in place: Enter saves, Escape gives it back, leaving the field saves. */\nfunction Editable({ value, label, placeholder, onCommit, onRefusal, className, inputClassName, required, multiline }: EditableProps) {\n const { editing, draft, setDraft, pending, open, stop, commit } = useEditable(value, onCommit, onRefusal, required);\n const input = React.useRef<HTMLInputElement | HTMLTextAreaElement>(null);\n React.useEffect(() => {\n if (editing) input.current?.focus();\n }, [editing, pending]);\n if (!onCommit) return value ? <p className={className}>{value}</p> : null;\n\n if (!editing) {\n return (\n <button\n type=\"button\"\n aria-label={editName(value, placeholder, label)}\n onClick={open}\n className={cn(className, \"group/edit -mx-1 inline-flex max-w-full items-center gap-2 rounded-md px-1 text-start hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\")}\n >\n <span className={cn(\"min-w-0 truncate\", !value && \"text-fg-muted\")}>{value || placeholder}</span>\n <PencilGlyph aria-hidden className=\"h-3.5 w-3.5 shrink-0 text-fg-muted opacity-0 group-hover/edit:opacity-100 group-focus-visible/edit:opacity-100 [@media(hover:none)]:opacity-100\" />\n </button>\n );\n }\n const shared = {\n ref: input as never,\n value: draft,\n \"aria-label\": label,\n disabled: pending,\n onChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => setDraft(event.target.value),\n onBlur: () => void commit(),\n onKeyDown: (event: React.KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n stop();\n } else if (event.key === \"Enter\" && !(multiline && event.shiftKey)) {\n event.preventDefault();\n void commit();\n }\n },\n className: cn(inputClassName, \"w-full rounded-md border border-border-control bg-surface-1 px-2 py-1 outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring\"),\n };\n return multiline ? <textarea rows={2} {...shared} /> : <input type=\"text\" {...shared} />;\n}\n\n/** The head of an entity: picture, name and description editable in place, tags, a refusal said in words, actions. */\nexport function EntityHeader({\n name,\n onNameChange,\n nameLabel = name,\n description,\n onDescriptionChange,\n descriptionLabel = \"Description\",\n descriptionPlaceholder,\n avatar,\n avatarPicker,\n tags,\n tagsLabel,\n onTagRemove,\n tagRemoveLabel,\n refusal,\n refusals,\n actions,\n className,\n}: EntityHeaderProps) {\n const { message, setLocal } = useRefusal(refusal, refusals);\n const picture = <Avatar size=\"xl\" alt=\"\" {...avatar} />;\n const errorId = React.useId();\n\n return (\n <header className={cn(\"flex flex-wrap items-start gap-4\", className)} data-entity-header>\n {avatarPicker ? (\n <Popover.Root>\n <Popover.Trigger asChild>\n <button type=\"button\" aria-label={avatarPicker.triggerLabel} className=\"shrink-0 rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\">\n {picture}\n </button>\n </Popover.Trigger>\n <Popover.Content className=\"w-80\" align=\"start\">\n <AvatarPicker {...avatarPicker} dense />\n </Popover.Content>\n </Popover.Root>\n ) : avatar ? (\n <span className=\"shrink-0\">{picture}</span>\n ) : null}\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <h1 className=\"m-0 min-w-0 text-xl font-semibold text-fg-title\">\n <Editable\n value={name}\n label={nameLabel}\n onCommit={onNameChange}\n onRefusal={setLocal}\n className=\"text-xl font-semibold text-fg-title\"\n inputClassName=\"text-xl font-semibold text-fg-title\"\n required\n />\n </h1>\n {description || onDescriptionChange ? (\n <Editable\n value={description ?? \"\"}\n label={descriptionLabel}\n placeholder={descriptionPlaceholder}\n onCommit={onDescriptionChange}\n onRefusal={setLocal}\n className=\"text-sm text-fg-secondary\"\n inputClassName=\"text-sm text-fg-secondary\"\n multiline\n />\n ) : null}\n {tags?.length ? (\n <ul aria-label={tagsLabel} className=\"m-0 mt-1 flex list-none flex-wrap gap-1.5 p-0\">\n {tags.map((tag) => (\n <li key={tag.id}>\n {onTagRemove ? (\n <TagChip marker={tag.marker} removable removeLabel={tagRemoveLabel?.(tag.label) ?? tag.label} onRemove={() => onTagRemove(tag.id)}>\n {tag.label}\n </TagChip>\n ) : (\n <span className=\"inline-flex items-center gap-1.5 rounded-full border border-border-default px-2.5 py-0.5 text-xs text-fg\">\n <TagMarker marker={tag.marker} />\n {tag.label}\n </span>\n )}\n </li>\n ))}\n </ul>\n ) : null}\n {message ? (\n <p id={errorId} role=\"alert\" className=\"m-0 text-sm text-danger-text\">\n {message}\n </p>\n ) : null}\n </div>\n {actions ? <div className=\"flex shrink-0 items-center gap-2\">{actions}</div> : null}\n </header>\n );\n}\n","// What the web and the native EntityHeader share: plain data, the refusal vocabulary, the code of a thrown refusal.\n// No component and no web import, so the native bundle never reaches the web files.\nimport type { Marker, OrganizeCode } from \"@krizaka/organize/contract\";\nimport * as React from \"react\";\n\nimport type { DefaultAvatar, DefaultAvatarEntityKind } from \"../avatar/default-avatar\";\n\n/** The refusals a header knows how to say: the product passes the words (translated) for the codes it can get. */\nexport type EntityRefusals = Partial<Record<OrganizeCode, string>>;\n\n/** The entity's picture: an address, or one of Krizaka's default pictures. */\nexport type EntityAvatar = { src?: string | null; defaultAvatar?: DefaultAvatar; fallback?: React.ReactNode };\n\n/** One picture to choose from (the shape of `AvatarPicker`'s options). */\nexport type EntityAvatarOption = {\n /** The value of the choice. */\n id: string;\n /** Its name for assistive technology, passed translated. */\n label: string;\n /** A picture's address; otherwise `defaultAvatar` draws one of the family's pictures. */\n src?: string;\n /** One of Krizaka's default pictures. */\n defaultAvatar?: DefaultAvatar;\n /** What this picture is of. */\n kind?: DefaultAvatarEntityKind;\n};\n\nexport type EntityTag = { id: string; label: string; marker: Marker };\n\n/** The refusal `code` carried by a thrown error (an `OrganizeError`, or any error with a string `code`). */\nexport function refusalCode(error: unknown): OrganizeCode | undefined {\n const code = typeof error === \"object\" && error !== null ? (error as { code?: unknown }).code : undefined;\n return typeof code === \"string\" ? (code as OrganizeCode) : undefined;\n}\n\n/** The props both platforms take: plain data, the editing callbacks, the refusals. */\nexport type EntityHeaderBase = {\n /** The entity's name. */\n name: string;\n /** Makes the name editable in place: called with the trimmed new name. Throw (or reject with) an error carrying a `code` to show its refusal. */\n onNameChange?: (name: string) => void | Promise<void>;\n /** What editing the name does (“Rename the collection”), passed translated: the field's name, and the button's after the visible name. */\n nameLabel?: string;\n /** One line under the name. */\n description?: string;\n /** Makes the description editable in place. Same contract as `onNameChange`. */\n onDescriptionChange?: (description: string) => void | Promise<void>;\n /** What editing the description does (“Edit the description”), passed translated: the field's name, and the button's after the visible text. */\n descriptionLabel?: string;\n /** Shown when there is no description and it is editable (“Add a description”), passed translated. */\n descriptionPlaceholder?: string;\n /** The picture. */\n avatar?: EntityAvatar;\n /** The entity's tags. */\n tags?: readonly EntityTag[];\n /** A refusal to say now (the last answer of the server), by its code. */\n refusal?: { code: OrganizeCode } | null;\n /** The messages by refusal code: `NAME_TAKEN`, `AVATAR_NOT_ALLOWED`, `DEFAULT_COLLECTION`, … A code with no message says nothing. */\n refusals?: EntityRefusals;\n /** After the text: the actions of the entity (a menu, a button). */\n actions?: React.ReactNode;\n};\n\n/** The text a button label reads: the visible text first, then what the button does (the accessible name contains the visible text). */\nexport const editName = (visible: string, placeholder: string | undefined, label: string) => `${visible || placeholder || \"\"} (${label})`.trim();\n\n/**\n * The state of a field edited in place: Enter or blur saves (a trimmed text, never an empty one when `required`),\n * Escape gives the text back, a thrown refusal keeps the field open and is reported by its code.\n */\nexport function useEditable(value: string, onCommit: ((value: string) => void | Promise<void>) | undefined, onRefusal: (code: OrganizeCode | undefined) => void, required?: boolean) {\n const [editing, setEditing] = React.useState(false);\n const [draft, setDraft] = React.useState(value);\n const [pending, setPending] = React.useState(false);\n const open = () => {\n setDraft(value);\n setEditing(true);\n };\n const stop = () => {\n setEditing(false);\n setDraft(value);\n };\n const commit = async () => {\n if (pending) return;\n const next = draft.trim();\n if (!onCommit || next === value || (required && next === \"\")) return stop();\n setPending(true);\n try {\n await onCommit(next);\n onRefusal(undefined);\n setEditing(false);\n } catch (error) {\n onRefusal(refusalCode(error));\n } finally {\n setPending(false);\n }\n };\n return { editing, draft, setDraft, pending, open, stop, commit };\n}\n\n/** The refusal to say: the one a save just raised, else the one the page passes, in the product's words (none when it has none). */\nexport function useRefusal(refusal: EntityHeaderBase[\"refusal\"], refusals: EntityRefusals | undefined) {\n const [local, setLocal] = React.useState<OrganizeCode | undefined>();\n const code = local ?? refusal?.code;\n return { message: code ? refusals?.[code] : undefined, setLocal };\n}\n\n/** The props of a field edited in place, on both platforms. */\nexport type EditableBase = {\n value: string;\n label: string;\n placeholder?: string;\n onCommit?: (value: string) => void | Promise<void>;\n onRefusal: (code: OrganizeCode | undefined) => void;\n required?: boolean;\n};\n"],"mappings":";;;;;;AAGA,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,SAAS,iBAAiB;AACnC,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,YAAYA,YAAW;;;ACLvB,YAAY,WAAW;AA2BhB,SAAS,YAAY,OAA0C;AACpE,QAAM,OAAO,OAAO,UAAU,YAAY,UAAU,OAAQ,MAA6B,OAAO;AAChG,SAAO,OAAO,SAAS,WAAY,OAAwB;AAC7D;AA+BO,IAAM,WAAW,CAAC,SAAiB,aAAiC,UAAkB,GAAG,WAAW,eAAe,EAAE,KAAK,KAAK,IAAI,KAAK;AAMxI,SAAS,YAAY,OAAe,UAAiE,WAAqD,UAAoB;AACnL,QAAM,CAAC,SAAS,UAAU,IAAU,eAAS,KAAK;AAClD,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAS,KAAK;AAC9C,QAAM,CAAC,SAAS,UAAU,IAAU,eAAS,KAAK;AAClD,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A,OACN;AAAA,IACC,UAAU,oBAAC,SAAI,WAAU,oCAAoC,mBAAQ,IAAS;AAAA,KACjF;AAEJ;","names":["React"]}
|
package/dist/file-upload.js
CHANGED
package/dist/filter-bar.d.ts
CHANGED
|
@@ -74,8 +74,8 @@ declare function SavedViews({ views, current, modified, onSelect, onSave, onRena
|
|
|
74
74
|
declare const filterBar: tailwind_variants.TVReturnType<{
|
|
75
75
|
[key: string]: {
|
|
76
76
|
[key: string]: tailwind_variants.ClassValue | {
|
|
77
|
-
root?: tailwind_variants.ClassValue;
|
|
78
77
|
count?: tailwind_variants.ClassValue;
|
|
78
|
+
root?: tailwind_variants.ClassValue;
|
|
79
79
|
controls?: tailwind_variants.ClassValue;
|
|
80
80
|
active?: tailwind_variants.ClassValue;
|
|
81
81
|
clear?: tailwind_variants.ClassValue;
|
|
@@ -87,8 +87,8 @@ declare const filterBar: tailwind_variants.TVReturnType<{
|
|
|
87
87
|
} | {
|
|
88
88
|
[x: string]: {
|
|
89
89
|
[x: string]: tailwind_variants.ClassValue | {
|
|
90
|
-
root?: tailwind_variants.ClassValue;
|
|
91
90
|
count?: tailwind_variants.ClassValue;
|
|
91
|
+
root?: tailwind_variants.ClassValue;
|
|
92
92
|
controls?: tailwind_variants.ClassValue;
|
|
93
93
|
active?: tailwind_variants.ClassValue;
|
|
94
94
|
clear?: tailwind_variants.ClassValue;
|
|
@@ -109,8 +109,8 @@ declare const filterBar: tailwind_variants.TVReturnType<{
|
|
|
109
109
|
}, undefined, {
|
|
110
110
|
[key: string]: {
|
|
111
111
|
[key: string]: tailwind_variants.ClassValue | {
|
|
112
|
-
root?: tailwind_variants.ClassValue;
|
|
113
112
|
count?: tailwind_variants.ClassValue;
|
|
113
|
+
root?: tailwind_variants.ClassValue;
|
|
114
114
|
controls?: tailwind_variants.ClassValue;
|
|
115
115
|
active?: tailwind_variants.ClassValue;
|
|
116
116
|
clear?: tailwind_variants.ClassValue;
|
package/dist/filter-bar.js
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
readFilterParams,
|
|
8
8
|
savedViewsLabels,
|
|
9
9
|
writeFilterParams
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-I6EOLPSH.js";
|
|
11
11
|
import "./chunk-UYGUSYIC.js";
|
|
12
12
|
import "./chunk-D3T54RSL.js";
|
|
13
13
|
import "./chunk-J3NC6ER4.js";
|
|
14
14
|
import "./chunk-NSLXEDIS.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-PGBF3UBX.js";
|
|
16
16
|
export {
|
|
17
17
|
FilterBar,
|
|
18
18
|
FilterMenu,
|