@lattice-php/lattice 0.4.0 → 0.5.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/dist/action/components/action-form.js +3 -3
- package/dist/action/components/action-group.js +1 -1
- package/dist/action/components/action.js +10 -16
- package/dist/action/components/action.js.map +1 -1
- package/dist/action/run-action.d.ts +9 -0
- package/dist/action/run-action.js +22 -0
- package/dist/action/run-action.js.map +1 -0
- package/dist/chat/components/chat-box.js +31 -14
- package/dist/chat/components/chat-box.js.map +1 -1
- package/dist/chat/components/message.js +1 -1
- package/dist/chat/components/prompt-input.js +1 -1
- package/dist/chat/index.js +2 -0
- package/dist/chat/index.js.map +1 -1
- package/dist/core/components/badge.js +1 -1
- package/dist/core/components/button.js +17 -5
- package/dist/core/components/button.js.map +1 -1
- package/dist/core/components/card.js +2 -1
- package/dist/core/components/card.js.map +1 -1
- package/dist/core/components/chart.js +2 -1
- package/dist/core/components/chart.js.map +1 -1
- package/dist/core/components/dialog.js +1 -1
- package/dist/core/components/floating-panel.js +3 -2
- package/dist/core/components/floating-panel.js.map +1 -1
- package/dist/core/components/fragment.js +3 -6
- package/dist/core/components/fragment.js.map +1 -1
- package/dist/core/components/grid.js +2 -1
- package/dist/core/components/grid.js.map +1 -1
- package/dist/core/components/index.js +0 -2
- package/dist/core/components/index.js.map +1 -1
- package/dist/core/components/section.js +5 -9
- package/dist/core/components/section.js.map +1 -1
- package/dist/core/components/stack.js +2 -1
- package/dist/core/components/stack.js.map +1 -1
- package/dist/core/components/tabs.js +1 -1
- package/dist/core/nodes.d.ts +6 -0
- package/dist/core/nodes.js +13 -0
- package/dist/core/nodes.js.map +1 -0
- package/dist/core/renderer.js +1 -1
- package/dist/create-app.d.ts +21 -0
- package/dist/create-app.js +31 -0
- package/dist/create-app.js.map +1 -0
- package/dist/effects/registry.js +2 -1
- package/dist/effects/registry.js.map +1 -1
- package/dist/effects/use-effect-dispatcher.js +1 -1
- package/dist/effects/use-flash-effects.js +1 -1
- package/dist/events/event-names.d.ts +3 -2
- package/dist/events/event-names.js +3 -2
- package/dist/events/event-names.js.map +1 -1
- package/dist/form/components/base/input-otp.d.ts +7 -0
- package/dist/form/components/base/input-otp.js +30 -0
- package/dist/form/components/base/input-otp.js.map +1 -0
- package/dist/form/components/conditions.js +1 -1
- package/dist/form/components/conditions.js.map +1 -1
- package/dist/form/components/fields/file-upload.js +1 -1
- package/dist/form/components/fields/otp-input.d.ts +2 -0
- package/dist/form/components/fields/otp-input.js +25 -0
- package/dist/form/components/fields/otp-input.js.map +1 -0
- package/dist/form/components/fields/row-item.js +1 -1
- package/dist/form/components/fields/table-rows.js +1 -1
- package/dist/form/components/form.js +1 -1
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/components/index.js +2 -1
- package/dist/form/components/prefill-targets.d.ts +0 -1
- package/dist/form/components/prefill-targets.js +1 -4
- package/dist/form/components/prefill-targets.js.map +1 -1
- package/dist/form/components/use-form-resolver.js +2 -2
- package/dist/form/components/use-form-resolver.js.map +1 -1
- package/dist/form/index.js +1 -0
- package/dist/form/index.js.map +1 -1
- package/dist/i18n/locale-reload.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -13
- package/dist/layout/breadcrumbs.js +3 -2
- package/dist/layout/breadcrumbs.js.map +1 -1
- package/dist/layout/callouts.js +1 -1
- package/dist/layout/components.js +1 -1
- package/dist/layout/menu-item.js +2 -2
- package/dist/layout/menu.js +2 -1
- package/dist/layout/menu.js.map +1 -1
- package/dist/layout/popover.js +1 -1
- package/dist/layout/sidebar.js +69 -29
- package/dist/layout/sidebar.js.map +1 -1
- package/dist/layout/topbar.js +2 -1
- package/dist/layout/topbar.js.map +1 -1
- package/dist/registry.js +1 -1
- package/dist/remote/components/data-list.js +1 -1
- package/dist/remote/index.js +1 -5
- package/dist/remote/index.js.map +1 -1
- package/dist/table/components/bulk-bar.js +10 -15
- package/dist/table/components/bulk-bar.js.map +1 -1
- package/dist/table/components/cells/text-cell.js +37 -2
- package/dist/table/components/cells/text-cell.js.map +1 -1
- package/dist/table/components/table.js +1 -1
- package/dist/table/filter-values.d.ts +5 -0
- package/dist/table/filter-values.js +10 -3
- package/dist/table/filter-values.js.map +1 -1
- package/dist/table/query.js +5 -4
- package/dist/table/query.js.map +1 -1
- package/dist/toast/toaster.js +2 -2
- package/dist/types/generated.d.ts +47 -23
- package/dist/vite.js +32 -1
- package/dist/vite.js.map +1 -1
- package/package.json +14 -3
- package/dist/remote/components/chat-box.d.ts +0 -3
- package/dist/remote/components/chat-box.js +0 -65
- package/dist/remote/components/chat-box.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-bar.js","names":[],"sources":["../../../resources/js/table/components/bulk-bar.tsx"],"sourcesContent":["import { useHttp } from \"@inertiajs/react\";\nimport { useState } from \"react\";\nimport { ActionForm } from \"@lattice-php/lattice/action/components/action-form\";\nimport {
|
|
1
|
+
{"version":3,"file":"bulk-bar.js","names":[],"sources":["../../../resources/js/table/components/bulk-bar.tsx"],"sourcesContent":["import { useHttp } from \"@inertiajs/react\";\nimport { useState } from \"react\";\nimport { ActionForm } from \"@lattice-php/lattice/action/components/action-form\";\nimport { runAction } from \"@lattice-php/lattice/action/run-action\";\nimport { getActionEffects } from \"@lattice-php/lattice/effects/dispatch\";\nimport type { ActionResponse } from \"@lattice-php/lattice/effects/dispatch\";\nimport { useEffectDispatcher } from \"@lattice-php/lattice/effects/use-effect-dispatcher\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { Button } from \"@lattice-php/lattice/core/components/button\";\nimport { ConfirmDialog } from \"@lattice-php/lattice/core/components/confirm-dialog\";\nimport { Spinner } from \"@lattice-php/lattice/core/components/spinner\";\nimport { prefixedTestId } from \"@lattice-php/lattice/core/test-id\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { BulkAction } from \"../bulk\";\n\ntype BulkData = {\n allMatching?: boolean;\n selected?: string[];\n};\n\nexport function BulkBar({\n actions,\n selectedKeys,\n allMatching,\n total,\n query,\n canSelectAllMatching,\n onSelectAllMatching,\n onCompleted,\n}: {\n actions: BulkAction[];\n selectedKeys: string[];\n allMatching: boolean;\n total?: number;\n query: Record<string, unknown>;\n canSelectAllMatching: boolean;\n onSelectAllMatching: () => void;\n onCompleted: () => void;\n}) {\n const { t } = useT(\"lattice\");\n const http = useHttp<BulkData, ActionResponse>({});\n const dispatch = useEffectDispatcher();\n const [confirming, setConfirming] = useState<BulkAction | null>(null);\n const [filling, setFilling] = useState<BulkAction | null>(null);\n\n const selectionPayload = (): Record<string, unknown> =>\n allMatching ? { allMatching: true, ...query } : { selected: selectedKeys };\n\n async function submit(action: BulkAction): Promise<void> {\n http.transform((data) => ({ ...data, ...selectionPayload() }));\n\n const ok = await runAction(\n () => http[action.method](action.endpoint, { headers: withHeaders(action.ref ?? \"\") }),\n dispatch,\n );\n\n if (ok) {\n setConfirming(null);\n onCompleted();\n }\n }\n\n function run(action: BulkAction): void {\n if (action.form) {\n setFilling(action);\n\n return;\n }\n\n if (action.confirmation) {\n setConfirming(action);\n\n return;\n }\n\n void submit(action);\n }\n\n const count = allMatching ? (total ?? selectedKeys.length) : selectedKeys.length;\n\n return (\n <div className=\"flex flex-wrap items-center gap-3 border-b border-lt-border bg-lt-muted/50 p-4 text-sm\">\n <span className=\"font-medium\">\n {allMatching\n ? t(\"bulk.allSelected\", \"All {{count}} selected\", { count })\n : t(\"bulk.selected\", \"{{count}} selected\", { count })}\n </span>\n {canSelectAllMatching && (\n <button\n type=\"button\"\n data-test=\"bulk-select-all-matching\"\n className=\"font-medium text-lt-primary underline underline-offset-2\"\n onClick={onSelectAllMatching}\n >\n {t(\"bulk.selectAllMatching\", \"Select all {{total}} matching\", { total })}\n </button>\n )}\n <div className=\"flex flex-wrap items-center gap-2\">\n {actions.map((action) => (\n <Button\n key={action.id}\n type=\"button\"\n data-test={prefixedTestId(\"bulk-action\", action.id)}\n variant={action.variant}\n disabled={http.processing}\n onClick={() => run(action)}\n >\n {http.processing && <Spinner />}\n {action.label}\n </Button>\n ))}\n </div>\n\n {confirming?.confirmation && (\n <ConfirmDialog\n title={confirming.confirmation.title ?? confirming.label}\n description={confirming.confirmation.description ?? undefined}\n confirmLabel={confirming.confirmation.confirmLabel ?? confirming.label}\n cancelLabel={confirming.confirmation.cancelLabel ?? \"Cancel\"}\n confirmVariant={confirming.variant}\n processing={http.processing}\n onConfirm={() => void submit(confirming)}\n onCancel={() => setConfirming(null)}\n />\n )}\n\n {filling?.form && (\n <ActionForm\n cancelLabel={filling.confirmation?.cancelLabel ?? \"Cancel\"}\n componentRef={filling.ref}\n description={filling.confirmation?.description ?? undefined}\n endpoint={filling.endpoint}\n extraData={selectionPayload()}\n formNode={filling.form}\n method={filling.method}\n onClose={() => setFilling(null)}\n onSuccess={(response) => {\n dispatch(getActionEffects(response.effects));\n setFilling(null);\n onCompleted();\n }}\n submitLabel={filling.confirmation?.confirmLabel ?? filling.label}\n title={filling.confirmation?.title ?? filling.label}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,SAAgB,QAAQ,EACtB,SACA,cACA,aACA,OACA,OACA,sBACA,qBACA,eAUC;CACD,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,OAAO,QAAkC,CAAC,CAAC;CACjD,MAAM,WAAW,oBAAoB;CACrC,MAAM,CAAC,YAAY,iBAAiB,SAA4B,IAAI;CACpE,MAAM,CAAC,SAAS,cAAc,SAA4B,IAAI;CAE9D,MAAM,yBACJ,cAAc;EAAE,aAAa;EAAM,GAAG;CAAM,IAAI,EAAE,UAAU,aAAa;CAE3E,eAAe,OAAO,QAAmC;EACvD,KAAK,WAAW,UAAU;GAAE,GAAG;GAAM,GAAG,iBAAiB;EAAE,EAAE;EAO7D,IAAI,MALa,gBACT,KAAK,OAAO,QAAQ,OAAO,UAAU,EAAE,SAAS,YAAY,OAAO,OAAO,EAAE,EAAE,CAAC,GACrF,QACF,GAEQ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ClD,UAAU,QAAQ;IAClB,WAAW,iBAAiB;IAC5B,UAAU,QAAQ;IAClB,QAAQ,QAAQ;IAChB,eAAe,WAAW,IAAI;IAC9B,YAAY,aAAa;KACvB,SAAS,iBAAiB,SAAS,OAAO,CAAC;KAC3C,WAAW,IAAI;KACf,YAAY;IACd;IACA,aAAa,QAAQ,cAAc,gBAAgB,QAAQ;IAC3D,OAAO,QAAQ,cAAc,SAAS,QAAQ;GAC/C,CAAA;EAEA;;AAET"}
|
|
@@ -1,10 +1,45 @@
|
|
|
1
|
+
import { cn } from "../../../lib/utils.js";
|
|
1
2
|
import { Icon } from "../../../icons/sprite.js";
|
|
2
3
|
import { copyToClipboard } from "../../../clipboard/index.js";
|
|
3
4
|
import { formatCell, resolveLink } from "../../format.js";
|
|
4
5
|
import { useEffect, useState } from "react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
//#region resources/js/table/components/cells/text-cell.tsx
|
|
7
|
-
var TextCell = (
|
|
8
|
+
var TextCell = (args) => {
|
|
9
|
+
if (args.props.multiple) return /* @__PURE__ */ jsx(MultipleCell, { ...args });
|
|
10
|
+
if (args.props.badge) return /* @__PURE__ */ jsx(SingleBadgeCell, { ...args });
|
|
11
|
+
return /* @__PURE__ */ jsx(PlainTextCell, { ...args });
|
|
12
|
+
};
|
|
13
|
+
function Badge({ label, color }) {
|
|
14
|
+
if (label === "") return null;
|
|
15
|
+
return /* @__PURE__ */ jsx("span", {
|
|
16
|
+
className: cn("lt-cell-badge", `lt-cell-tone-${color || "gray"}`),
|
|
17
|
+
children: label
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function MultipleCell({ column, props, value }) {
|
|
21
|
+
const items = Array.isArray(value) ? value : [];
|
|
22
|
+
if (items.length === 0) return null;
|
|
23
|
+
if (!props.badge) return /* @__PURE__ */ jsx("span", { children: items.map((item) => formatCell(item, column)).join(", ") });
|
|
24
|
+
return /* @__PURE__ */ jsx("div", {
|
|
25
|
+
className: "flex flex-wrap gap-1",
|
|
26
|
+
children: items.map((item, index) => {
|
|
27
|
+
const chip = item;
|
|
28
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
29
|
+
label: formatCell(chip.value, column),
|
|
30
|
+
color: chip.color
|
|
31
|
+
}, index);
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function SingleBadgeCell({ column, props, row, value }) {
|
|
36
|
+
const colorKey = props.badge.colorKey;
|
|
37
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
38
|
+
label: formatCell(value, column),
|
|
39
|
+
color: String(row[colorKey] ?? "")
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function PlainTextCell({ column, props, row, value }) {
|
|
8
43
|
const text = formatCell(value, column);
|
|
9
44
|
const [copied, setCopied] = useState(false);
|
|
10
45
|
const href = resolveLink(column, row, value);
|
|
@@ -42,7 +77,7 @@ var TextCell = ({ column, props, row, value }) => {
|
|
|
42
77
|
}), copied ? "Copied" : "Copy"]
|
|
43
78
|
})]
|
|
44
79
|
});
|
|
45
|
-
}
|
|
80
|
+
}
|
|
46
81
|
//#endregion
|
|
47
82
|
export { TextCell };
|
|
48
83
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/text-cell.tsx"],"sourcesContent":["import { copyToClipboard } from \"@lattice-php/lattice/clipboard\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { useEffect, useState } from \"react\";\nimport { formatCell, resolveLink } from \"../../format\";\nimport type { ColumnCellComponent } from \"../../registry\";\n\nexport const TextCell: ColumnCellComponent<\"column.text\"> = ({ column, props, row, value })
|
|
1
|
+
{"version":3,"file":"text-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/text-cell.tsx"],"sourcesContent":["import { copyToClipboard } from \"@lattice-php/lattice/clipboard\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { type ReactNode, useEffect, useState } from \"react\";\nimport { formatCell, resolveLink } from \"../../format\";\nimport type { ColumnCellArgs, ColumnCellComponent } from \"../../registry\";\n\ntype TextProps = ColumnCellArgs<\"column.text\">[\"props\"];\n\nexport const TextCell: ColumnCellComponent<\"column.text\"> = (args) => {\n if (args.props.multiple) {\n return <MultipleCell {...args} />;\n }\n\n if (args.props.badge) {\n return <SingleBadgeCell {...args} />;\n }\n\n return <PlainTextCell {...args} />;\n};\n\nfunction Badge({ label, color }: { label: string; color?: string | null }): ReactNode {\n if (label === \"\") {\n return null;\n }\n\n return <span className={cn(\"lt-cell-badge\", `lt-cell-tone-${color || \"gray\"}`)}>{label}</span>;\n}\n\nfunction MultipleCell({ column, props, value }: ColumnCellArgs<\"column.text\">): ReactNode {\n const items = Array.isArray(value) ? value : [];\n\n if (items.length === 0) {\n return null;\n }\n\n if (!props.badge) {\n return <span>{items.map((item) => formatCell(item, column)).join(\", \")}</span>;\n }\n\n return (\n <div className=\"flex flex-wrap gap-1\">\n {items.map((item, index) => {\n const chip = item as { value: unknown; color?: string };\n\n return <Badge key={index} label={formatCell(chip.value, column)} color={chip.color} />;\n })}\n </div>\n );\n}\n\nfunction SingleBadgeCell({ column, props, row, value }: ColumnCellArgs<\"column.text\">): ReactNode {\n const colorKey = (props.badge as NonNullable<TextProps[\"badge\"]>).colorKey;\n\n return <Badge label={formatCell(value, column)} color={String(row[colorKey] ?? \"\")} />;\n}\n\nfunction PlainTextCell({ column, props, row, value }: ColumnCellArgs<\"column.text\">): ReactNode {\n const text = formatCell(value, column);\n const [copied, setCopied] = useState(false);\n const href = resolveLink(column, row, value);\n const content = href ? (\n <a\n className=\"underline underline-offset-2\"\n href={href}\n rel={props.link?.external ? \"noreferrer\" : undefined}\n target={props.link?.external ? \"_blank\" : undefined}\n >\n {text}\n </a>\n ) : (\n text\n );\n\n useEffect(() => {\n if (!copied) {\n return;\n }\n\n const timeout = window.setTimeout(() => setCopied(false), 1500);\n\n return () => window.clearTimeout(timeout);\n }, [copied]);\n\n function handleCopy(): void {\n void copyToClipboard(text);\n setCopied(true);\n }\n\n if (!props.copyable) {\n return content;\n }\n\n return (\n <span className=\"inline-flex items-center gap-2\">\n <span>{content}</span>\n <button\n type=\"button\"\n data-test={`copy-${column.key}`}\n className=\"inline-flex items-center gap-1 rounded-lt-sm border border-lt-border px-2 py-1 text-xs\"\n aria-label={`${copied ? \"Copied\" : \"Copy\"} ${column.label}`}\n onClick={handleCopy}\n >\n {copied ? (\n <Icon name=\"check\" className=\"size-lt-icon-xs\" />\n ) : (\n <Icon name=\"copy\" className=\"size-lt-icon-xs\" />\n )}\n {copied ? \"Copied\" : \"Copy\"}\n </button>\n </span>\n );\n}\n"],"mappings":";;;;;;;AASA,IAAa,YAAgD,SAAS;CACpE,IAAI,KAAK,MAAM,UACb,OAAO,oBAAC,cAAD,EAAc,GAAI,KAAO,CAAA;CAGlC,IAAI,KAAK,MAAM,OACb,OAAO,oBAAC,iBAAD,EAAiB,GAAI,KAAO,CAAA;CAGrC,OAAO,oBAAC,eAAD,EAAe,GAAI,KAAO,CAAA;AACnC;AAEA,SAAS,MAAM,EAAE,OAAO,SAA8D;CACpF,IAAI,UAAU,IACZ,OAAO;CAGT,OAAO,oBAAC,QAAD;EAAM,WAAW,GAAG,iBAAiB,gBAAgB,SAAS,QAAQ;YAAI;CAAY,CAAA;AAC/F;AAEA,SAAS,aAAa,EAAE,QAAQ,OAAO,SAAmD;CACxF,MAAM,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;CAE9C,IAAI,MAAM,WAAW,GACnB,OAAO;CAGT,IAAI,CAAC,MAAM,OACT,OAAO,oBAAC,QAAD,EAAA,UAAO,MAAM,KAAK,SAAS,WAAW,MAAM,MAAM,CAAC,EAAE,KAAK,IAAI,EAAQ,CAAA;CAG/E,OACE,oBAAC,OAAD;EAAK,WAAU;YACZ,MAAM,KAAK,MAAM,UAAU;GAC1B,MAAM,OAAO;GAEb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AAU;GAAmB,CAAA,GAEhD,SAAS,WAAW,MACf;IACJ;;AAEV"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../lib/utils.js";
|
|
2
|
-
import { nodeIdentity } from "../../core/test-id.js";
|
|
3
2
|
import { Icon } from "../../icons/sprite.js";
|
|
4
3
|
import { useT } from "../../i18n/instance.js";
|
|
4
|
+
import { nodeIdentity } from "../../core/test-id.js";
|
|
5
5
|
import { useColumnResizing } from "../../core/use-column-resizing.js";
|
|
6
6
|
import { alignJustifyItems, alignText } from "../align.js";
|
|
7
7
|
import { getBulkActions } from "../bulk.js";
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { FilterData, Option } from '../types/generated';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a single scalar filter member is absent — the atomic rule the
|
|
4
|
+
* filter-emptiness and query-serialization logic both build on.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isEmptyMember(value: unknown): value is null | undefined | "";
|
|
2
7
|
/**
|
|
3
8
|
* Whether a table-filter value should clear the filter rather than apply it —
|
|
4
9
|
* an empty string, empty list, or an object whose every member is empty.
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
//#region resources/js/table/filter-values.ts
|
|
2
2
|
/**
|
|
3
|
+
* Whether a single scalar filter member is absent — the atomic rule the
|
|
4
|
+
* filter-emptiness and query-serialization logic both build on.
|
|
5
|
+
*/
|
|
6
|
+
function isEmptyMember(value) {
|
|
7
|
+
return value == null || value === "";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
3
10
|
* Whether a table-filter value should clear the filter rather than apply it —
|
|
4
11
|
* an empty string, empty list, or an object whose every member is empty.
|
|
5
12
|
*/
|
|
6
13
|
function isEmptyFilterValue(value) {
|
|
7
|
-
if (value
|
|
14
|
+
if (isEmptyMember(value)) return true;
|
|
8
15
|
if (Array.isArray(value)) return value.length === 0;
|
|
9
|
-
if (typeof value === "object") return Object.values(value).every(
|
|
16
|
+
if (typeof value === "object") return Object.values(value).every(isEmptyMember);
|
|
10
17
|
return false;
|
|
11
18
|
}
|
|
12
19
|
function isActiveFilterValue(value) {
|
|
@@ -25,6 +32,6 @@ function filterOptions(filter) {
|
|
|
25
32
|
return Array.isArray(value) ? value : [];
|
|
26
33
|
}
|
|
27
34
|
//#endregion
|
|
28
|
-
export { filterOptions, isActiveFilterValue, isEmptyFilterValue, stringProp };
|
|
35
|
+
export { filterOptions, isActiveFilterValue, isEmptyFilterValue, isEmptyMember, stringProp };
|
|
29
36
|
|
|
30
37
|
//# sourceMappingURL=filter-values.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-values.js","names":[],"sources":["../../resources/js/table/filter-values.ts"],"sourcesContent":["import type { FilterData, Option } from \"@lattice-php/lattice/types/generated\";\n\n/**\n * Whether a table-filter value should clear the filter rather than apply it —\n * an empty string, empty list, or an object whose every member is empty.\n */\nexport function isEmptyFilterValue(value: unknown): boolean {\n if (value
|
|
1
|
+
{"version":3,"file":"filter-values.js","names":[],"sources":["../../resources/js/table/filter-values.ts"],"sourcesContent":["import type { FilterData, Option } from \"@lattice-php/lattice/types/generated\";\n\n/**\n * Whether a single scalar filter member is absent — the atomic rule the\n * filter-emptiness and query-serialization logic both build on.\n */\nexport function isEmptyMember(value: unknown): value is null | undefined | \"\" {\n return value == null || value === \"\";\n}\n\n/**\n * Whether a table-filter value should clear the filter rather than apply it —\n * an empty string, empty list, or an object whose every member is empty.\n */\nexport function isEmptyFilterValue(value: unknown): boolean {\n if (isEmptyMember(value)) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (typeof value === \"object\") {\n return Object.values(value).every(isEmptyMember);\n }\n\n return false;\n}\n\nexport function isActiveFilterValue(value: unknown): boolean {\n return !isEmptyFilterValue(value);\n}\n\n/**\n * Read a string entry from a filter's loose `props` bag, falling back when the\n * key is absent or not a string.\n */\nexport function stringProp(filter: FilterData, key: string, fallback: string): string {\n const value = filter.props[key];\n\n return typeof value === \"string\" ? value : fallback;\n}\n\nexport function filterOptions(filter: FilterData): Option[] {\n const value = filter.props.options;\n\n return Array.isArray(value) ? (value as Option[]) : [];\n}\n"],"mappings":";;;;;AAMA,SAAgB,cAAc,OAAgD;CAC5E,OAAO,SAAS,QAAQ,UAAU;AACpC;;;;;AAMA,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,cAAc,KAAK,GACrB,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,WAAW;CAG1B,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,OAAO,KAAK,EAAE,MAAM,aAAa;CAGjD,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAAyB;CAC3D,OAAO,CAAC,mBAAmB,KAAK;AAClC;;;;;AAMA,SAAgB,WAAW,QAAoB,KAAa,UAA0B;CACpF,MAAM,QAAQ,OAAO,MAAM;CAE3B,OAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AAEA,SAAgB,cAAc,QAA8B;CAC1D,MAAM,QAAQ,OAAO,MAAM;CAE3B,OAAO,MAAM,QAAQ,KAAK,IAAK,QAAqB,CAAC;AACvD"}
|
package/dist/table/query.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { translate } from "../i18n/instance.js";
|
|
2
2
|
import "../core/column-sizing.js";
|
|
3
|
+
import { isEmptyMember } from "./filter-values.js";
|
|
3
4
|
//#region resources/js/table/query.ts
|
|
4
5
|
function getColumnSort(state, column) {
|
|
5
6
|
return state.sorts.find((currentSort) => currentSort.key === column.key);
|
|
@@ -30,7 +31,7 @@ function appendTableFilters(url, tableFilters) {
|
|
|
30
31
|
continue;
|
|
31
32
|
}
|
|
32
33
|
if (Array.isArray(value)) {
|
|
33
|
-
for (const item of value) if (item
|
|
34
|
+
for (const item of value) if (!isEmptyMember(item)) url.searchParams.append(`tf[${key}][]`, String(item));
|
|
34
35
|
continue;
|
|
35
36
|
}
|
|
36
37
|
if (typeof value === "object" && value !== null) for (const [subKey, subValue] of Object.entries(value)) url.searchParams.set(`tf[${key}][${subKey}]`, String(subValue));
|
|
@@ -45,14 +46,14 @@ function getTableFilterParams(tableFilters) {
|
|
|
45
46
|
return params;
|
|
46
47
|
}
|
|
47
48
|
function normalizeTableFilterValue(value) {
|
|
48
|
-
if (value
|
|
49
|
+
if (isEmptyMember(value)) return;
|
|
49
50
|
if (typeof value === "string") return value;
|
|
50
51
|
if (Array.isArray(value)) {
|
|
51
|
-
const items = value.filter((item) => item
|
|
52
|
+
const items = value.filter((item) => !isEmptyMember(item)).map(String);
|
|
52
53
|
return items.length > 0 ? items : void 0;
|
|
53
54
|
}
|
|
54
55
|
if (typeof value === "object") {
|
|
55
|
-
const entries = Object.entries(value).filter(([, subValue]) => subValue
|
|
56
|
+
const entries = Object.entries(value).filter(([, subValue]) => !isEmptyMember(subValue)).map(([subKey, subValue]) => [subKey, String(subValue)]);
|
|
56
57
|
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
57
58
|
}
|
|
58
59
|
return String(value);
|
package/dist/table/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","names":[],"sources":["../../resources/js/table/query.ts"],"sourcesContent":["import { translate } from \"@lattice-php/lattice/i18n\";\nimport { DEFAULT_COLUMN_WIDTH } from \"@lattice-php/lattice/core/column-sizing\";\nimport type { ColumnWidth } from \"@lattice-php/lattice/types/generated\";\nimport type { TableColumn, TableSort, TableState } from \"./types\";\n\nexport function getColumnSort(state: TableState, column: TableColumn): TableSort | undefined {\n return state.sorts.find((currentSort) => currentSort.key === column.key);\n}\n\nexport function getColumnAriaSort(\n sort: TableSort | undefined,\n): \"ascending\" | \"descending\" | undefined {\n if (sort?.direction === \"asc\") {\n return \"ascending\";\n }\n\n if (sort?.direction === \"desc\") {\n return \"descending\";\n }\n\n return undefined;\n}\n\nexport function buildEndpoint(endpoint: string, state: TableState): string {\n const url = new URL(endpoint, window.location.origin);\n\n if (state.filters.length > 0) {\n url.searchParams.set(\"filter\", serializeFilters(state));\n }\n\n if (state.sorts.length > 0) {\n url.searchParams.set(\"sort\", serializeSorts(state));\n }\n\n appendTableFilters(url, state.tableFilters);\n\n url.searchParams.set(\"page\", String(state.page));\n url.searchParams.set(\"per_page\", String(state.perPage));\n\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * Serialize the dedicated table filters as Laravel-native bracket params:\n * `tf[key]=v`, repeated `tf[key][]=v` for multi-value, and `tf[key][sub]=v`\n * for structured values (e.g. a date range's from/until). Empty values are\n * dropped so an unset filter never reaches the server.\n */\nfunction appendTableFilters(url: URL, tableFilters: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(getTableFilterParams(tableFilters))) {\n if (typeof value === \"string\") {\n url.searchParams.set(`tf[${key}]`, value);\n\n continue;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item != null && item !== \"\") {\n url.searchParams.append(`tf[${key}][]`, String(item));\n }\n }\n\n continue;\n }\n\n if (typeof value === \"object\" && value !== null) {\n for (const [subKey, subValue] of Object.entries(value as Record<string, unknown>)) {\n url.searchParams.set(`tf[${key}][${subKey}]`, String(subValue));\n }\n }\n }\n}\n\nfunction getTableFilterParams(tableFilters: Record<string, unknown>): Record<string, unknown> {\n const params: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tableFilters)) {\n const normalized = normalizeTableFilterValue(value);\n\n if (normalized !== undefined) {\n params[key] = normalized;\n }\n }\n\n return params;\n}\n\nfunction normalizeTableFilterValue(value: unknown): unknown | undefined {\n if (value == null || value === \"\") {\n return undefined;\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (Array.isArray(value)) {\n const items = value.filter((item) => item != null && item !== \"\").map(String);\n\n return items.length > 0 ? items : undefined;\n }\n\n if (typeof value === \"object\") {\n const entries = Object.entries(value)\n .filter(([, subValue]) => subValue != null && subValue !== \"\")\n .map(([subKey, subValue]) => [subKey, String(subValue)]);\n\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n }\n\n return String(value);\n}\n\nexport function getQueryParams(state: TableState): Record<string, unknown> {\n const params: Record<string, unknown> = {};\n\n if (state.filters.length > 0) {\n params.filter = serializeFilters(state);\n }\n\n if (state.sorts.length > 0) {\n params.sort = serializeSorts(state);\n }\n\n const tableFilters = getTableFilterParams(state.tableFilters);\n\n if (Object.keys(tableFilters).length > 0) {\n params.tf = tableFilters;\n }\n\n return params;\n}\n\nfunction serializeFilters(state: TableState): string {\n return state.filters\n .map((clause) => `${clause.field}:${clause.operator}:${encodeURIComponent(clause.value)}`)\n .join(\",\");\n}\n\nfunction serializeSorts(state: TableState): string {\n return state.sorts\n .map((sort) => (sort.direction === \"desc\" ? `-${sort.key}` : sort.key))\n .join(\",\");\n}\n\nconst operatorLabels: Record<string, string> = {\n contains: \"contains\",\n starts_with: \"starts with\",\n ends_with: \"ends with\",\n eq: \"equals\",\n neq: \"not equals\",\n gt: \">\",\n gte: \"≥\",\n lt: \"<\",\n lte: \"≤\",\n in: \"in\",\n not_in: \"not in\",\n before: \"before\",\n after: \"after\",\n empty: \"is empty\",\n filled: \"is not empty\",\n};\n\nexport const VALUELESS_FILTER_OPERATORS = new Set<string>([\"empty\", \"filled\"]);\n\nexport function operatorLabel(operator: string): string {\n return translate(\"lattice\", `operators.${operator}`, operatorLabels[operator] ?? operator);\n}\n\nexport function getSortDirectionLabel(direction: string): string {\n return direction === \"desc\" ? \"descending\" : \"ascending\";\n}\n\nexport function nextSort(sorts: TableSort[], column: TableColumn): TableSort[] {\n if (!column.sortable) {\n return sorts;\n }\n\n const currentSort = sorts.find((sort) => sort.key === column.key);\n const remainingSorts = sorts.filter((sort) => sort.key !== column.key);\n\n if (!currentSort) {\n return [...sorts, { key: column.key, direction: \"asc\" }];\n }\n\n if (currentSort.direction === \"asc\") {\n return [...remainingSorts, { key: column.key, direction: \"desc\" }];\n }\n\n return remainingSorts;\n}\n\nexport function getVisiblePages(currentPage: number, lastPage: number): number[] {\n if (lastPage <= 5) {\n return Array.from({ length: lastPage }, (_, index) => index + 1);\n }\n\n const start = Math.max(1, Math.min(currentPage - 2, lastPage - 4));\n\n return Array.from({ length: 5 }, (_, index) => start + index);\n}\n\nexport function getTableSizingColumns(columns: TableColumn[]) {\n return columns.map((column) => ({\n key: column.key,\n label: column.label,\n width: columnWidthOrDefault(column),\n }));\n}\n\nfunction columnWidthOrDefault(column: TableColumn): ColumnWidth {\n return (column.width ??\n (column.type === \"column.stack\" ? \"xl\" : DEFAULT_COLUMN_WIDTH)) as ColumnWidth;\n}\n\nexport function getTableUtilityTracks(hasActions: boolean, hasSelection: boolean) {\n // Utility tracks are fixed because the independent header/filter/body grids would drift with content-sized tracks.\n return {\n leadingTracks: hasSelection ? [\"3rem\"] : [],\n trailingTracks: hasActions ? [\"10rem\"] : [],\n };\n}\n"],"mappings":";;;AAKA,SAAgB,cAAc,OAAmB,QAA4C;CAC3F,OAAO,MAAM,MAAM,MAAM,gBAAgB,YAAY,QAAQ,OAAO,GAAG;AACzE;AAEA,SAAgB,kBACd,MACwC;CACxC,IAAI,MAAM,cAAc,OACtB,OAAO;CAGT,IAAI,MAAM,cAAc,QACtB,OAAO;AAIX;AAEA,SAAgB,cAAc,UAAkB,OAA2B;CACzE,MAAM,MAAM,IAAI,IAAI,UAAU,OAAO,SAAS,MAAM;CAEpD,IAAI,MAAM,QAAQ,SAAS,GACzB,IAAI,aAAa,IAAI,UAAU,iBAAiB,KAAK,CAAC;CAGxD,IAAI,MAAM,MAAM,SAAS,GACvB,IAAI,aAAa,IAAI,QAAQ,eAAe,KAAK,CAAC;CAGpD,mBAAmB,KAAK,MAAM,YAAY;CAE1C,IAAI,aAAa,IAAI,QAAQ,OAAO,MAAM,IAAI,CAAC;CAC/C,IAAI,aAAa,IAAI,YAAY,OAAO,MAAM,OAAO,CAAC;CAEtD,OAAO,GAAG,IAAI,WAAW,IAAI;AAC/B;;;;;;;AAQA,SAAS,mBAAmB,KAAU,cAA6C;CACjF,KAAK,MAAM,CAAC,KAAK,UAAU,OAA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aACH,OAAO,CAAC,GAAG,OAAO;EAAE,KAAK,OAAO;EAAK,WAAW;CAAM,CAAC;CAGzD,IAAI,YAAY,cAAc,OAC5B,OAAO,CAAC,GAAG,gBAAgB;EAAE,KAAK,OAAO;EAAK,WAAW;CAAO,CAAC;CAGnE,OAAO;AACT;AAEA,SAAgB,gBAAgB,aAAqB,UAA4B;CAC/E,IAAI,YAAY,GACd,OAAO,MAAM,KAAK,EAAE,QAAQ,SAAS,IAAI,GAAG,UAAU,QAAQ,CAAC;CAGjE,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,cAAc,GAAG,WAAW,CAAC,CAAC;CAEjE,OAAO,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,UAAU,QAAQ,KAAK;AAC9D;AAEA,SAAgB,sBAAsB,SAAwB;CAC5D,OAAO,QAAQ,KAAK,YAAY;EAC9B,KAAK,OAAO;EACZ,OAAO,OAAO;EACd,OAAO,qBAAqB,MAAM;CACpC,EAAE;AACJ;AAEA,SAAS,qBAAqB,QAAkC;CAC9D,OAAQ,OAAO,UACZ,OAAO,SAAS,iBAAiB,OAAA;AACtC;AAEA,SAAgB,sBAAsB,YAAqB,cAAuB;CAEhF,OAAO;EACL,eAAe,eAAe,CAAC,MAAM,IAAI,CAAC;EAC1C,gBAAgB,aAAa,CAAC,OAAO,IAAI,CAAC;CAC5C;AACF"}
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"sources":["../../resources/js/table/query.ts"],"sourcesContent":["import { translate } from \"@lattice-php/lattice/i18n\";\nimport { DEFAULT_COLUMN_WIDTH } from \"@lattice-php/lattice/core/column-sizing\";\nimport type { ColumnWidth } from \"@lattice-php/lattice/types/generated\";\nimport { isEmptyMember } from \"./filter-values\";\nimport type { TableColumn, TableSort, TableState } from \"./types\";\n\nexport function getColumnSort(state: TableState, column: TableColumn): TableSort | undefined {\n return state.sorts.find((currentSort) => currentSort.key === column.key);\n}\n\nexport function getColumnAriaSort(\n sort: TableSort | undefined,\n): \"ascending\" | \"descending\" | undefined {\n if (sort?.direction === \"asc\") {\n return \"ascending\";\n }\n\n if (sort?.direction === \"desc\") {\n return \"descending\";\n }\n\n return undefined;\n}\n\nexport function buildEndpoint(endpoint: string, state: TableState): string {\n const url = new URL(endpoint, window.location.origin);\n\n if (state.filters.length > 0) {\n url.searchParams.set(\"filter\", serializeFilters(state));\n }\n\n if (state.sorts.length > 0) {\n url.searchParams.set(\"sort\", serializeSorts(state));\n }\n\n appendTableFilters(url, state.tableFilters);\n\n url.searchParams.set(\"page\", String(state.page));\n url.searchParams.set(\"per_page\", String(state.perPage));\n\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * Serialize the dedicated table filters as Laravel-native bracket params:\n * `tf[key]=v`, repeated `tf[key][]=v` for multi-value, and `tf[key][sub]=v`\n * for structured values (e.g. a date range's from/until). Empty values are\n * dropped so an unset filter never reaches the server.\n */\nfunction appendTableFilters(url: URL, tableFilters: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(getTableFilterParams(tableFilters))) {\n if (typeof value === \"string\") {\n url.searchParams.set(`tf[${key}]`, value);\n\n continue;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n if (!isEmptyMember(item)) {\n url.searchParams.append(`tf[${key}][]`, String(item));\n }\n }\n\n continue;\n }\n\n if (typeof value === \"object\" && value !== null) {\n for (const [subKey, subValue] of Object.entries(value as Record<string, unknown>)) {\n url.searchParams.set(`tf[${key}][${subKey}]`, String(subValue));\n }\n }\n }\n}\n\nfunction getTableFilterParams(tableFilters: Record<string, unknown>): Record<string, unknown> {\n const params: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tableFilters)) {\n const normalized = normalizeTableFilterValue(value);\n\n if (normalized !== undefined) {\n params[key] = normalized;\n }\n }\n\n return params;\n}\n\nfunction normalizeTableFilterValue(value: unknown): unknown | undefined {\n if (isEmptyMember(value)) {\n return undefined;\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (Array.isArray(value)) {\n const items = value.filter((item) => !isEmptyMember(item)).map(String);\n\n return items.length > 0 ? items : undefined;\n }\n\n if (typeof value === \"object\") {\n const entries = Object.entries(value)\n .filter(([, subValue]) => !isEmptyMember(subValue))\n .map(([subKey, subValue]) => [subKey, String(subValue)]);\n\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n }\n\n return String(value);\n}\n\nexport function getQueryParams(state: TableState): Record<string, unknown> {\n const params: Record<string, unknown> = {};\n\n if (state.filters.length > 0) {\n params.filter = serializeFilters(state);\n }\n\n if (state.sorts.length > 0) {\n params.sort = serializeSorts(state);\n }\n\n const tableFilters = getTableFilterParams(state.tableFilters);\n\n if (Object.keys(tableFilters).length > 0) {\n params.tf = tableFilters;\n }\n\n return params;\n}\n\nfunction serializeFilters(state: TableState): string {\n return state.filters\n .map((clause) => `${clause.field}:${clause.operator}:${encodeURIComponent(clause.value)}`)\n .join(\",\");\n}\n\nfunction serializeSorts(state: TableState): string {\n return state.sorts\n .map((sort) => (sort.direction === \"desc\" ? `-${sort.key}` : sort.key))\n .join(\",\");\n}\n\nconst operatorLabels: Record<string, string> = {\n contains: \"contains\",\n starts_with: \"starts with\",\n ends_with: \"ends with\",\n eq: \"equals\",\n neq: \"not equals\",\n gt: \">\",\n gte: \"≥\",\n lt: \"<\",\n lte: \"≤\",\n in: \"in\",\n not_in: \"not in\",\n before: \"before\",\n after: \"after\",\n empty: \"is empty\",\n filled: \"is not empty\",\n};\n\nexport const VALUELESS_FILTER_OPERATORS = new Set<string>([\"empty\", \"filled\"]);\n\nexport function operatorLabel(operator: string): string {\n return translate(\"lattice\", `operators.${operator}`, operatorLabels[operator] ?? operator);\n}\n\nexport function getSortDirectionLabel(direction: string): string {\n return direction === \"desc\" ? \"descending\" : \"ascending\";\n}\n\nexport function nextSort(sorts: TableSort[], column: TableColumn): TableSort[] {\n if (!column.sortable) {\n return sorts;\n }\n\n const currentSort = sorts.find((sort) => sort.key === column.key);\n const remainingSorts = sorts.filter((sort) => sort.key !== column.key);\n\n if (!currentSort) {\n return [...sorts, { key: column.key, direction: \"asc\" }];\n }\n\n if (currentSort.direction === \"asc\") {\n return [...remainingSorts, { key: column.key, direction: \"desc\" }];\n }\n\n return remainingSorts;\n}\n\nexport function getVisiblePages(currentPage: number, lastPage: number): number[] {\n if (lastPage <= 5) {\n return Array.from({ length: lastPage }, (_, index) => index + 1);\n }\n\n const start = Math.max(1, Math.min(currentPage - 2, lastPage - 4));\n\n return Array.from({ length: 5 }, (_, index) => start + index);\n}\n\nexport function getTableSizingColumns(columns: TableColumn[]) {\n return columns.map((column) => ({\n key: column.key,\n label: column.label,\n width: columnWidthOrDefault(column),\n }));\n}\n\nfunction columnWidthOrDefault(column: TableColumn): ColumnWidth {\n return (column.width ??\n (column.type === \"column.stack\" ? \"xl\" : DEFAULT_COLUMN_WIDTH)) as ColumnWidth;\n}\n\nexport function getTableUtilityTracks(hasActions: boolean, hasSelection: boolean) {\n // Utility tracks are fixed because the independent header/filter/body grids would drift with content-sized tracks.\n return {\n leadingTracks: hasSelection ? [\"3rem\"] : [],\n trailingTracks: hasActions ? [\"10rem\"] : [],\n };\n}\n"],"mappings":";;;;AAMA,SAAgB,cAAc,OAAmB,QAA4C;CAC3F,OAAO,MAAM,MAAM,MAAM,gBAAgB,YAAY,QAAQ,OAAO,GAAG;AACzE;AAEA,SAAgB,kBACd,MACwC;CACxC,IAAI,MAAM,cAAc,OACtB,OAAO;CAGT,IAAI,MAAM,cAAc,QACtB,OAAO;AAIX;AAEA,SAAgB,cAAc,UAAkB,OAA2B;CACzE,MAAM,MAAM,IAAI,IAAI,UAAU,OAAO,SAAS,MAAM;CAEpD,IAAI,MAAM,QAAQ,SAAS,GACzB,IAAI,aAAa,IAAI,UAAU,iBAAiB,KAAK,CAAC;CAGxD,IAAI,MAAM,MAAM,SAAS,GACvB,IAAI,aAAa,IAAI,QAAQ,eAAe,KAAK,CAAC;CAGpD,mBAAmB,KAAK,MAAM,YAAY;CAE1C,IAAI,aAAa,IAAI,QA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
|
import { resolveTranslatable } from "../i18n/translatable.js";
|
|
5
5
|
import { onToast } from "./toast.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useT } from "../i18n/instance.js";
|
|
7
7
|
import { variantStyles } from "./variant-styles.js";
|
|
8
8
|
import { useEffect, useState } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type Action = {
|
|
2
2
|
confirmation: Confirmation | null;
|
|
3
|
-
effects: Effect[];
|
|
4
3
|
endpoint: string | null;
|
|
5
4
|
form: Node | null;
|
|
6
5
|
icon: string | null;
|
|
@@ -91,7 +90,6 @@ export type Builder = {
|
|
|
91
90
|
};
|
|
92
91
|
export type BulkAction = {
|
|
93
92
|
confirmation: Confirmation | null;
|
|
94
|
-
effects: Effect[];
|
|
95
93
|
endpoint: string | null;
|
|
96
94
|
form: Node | null;
|
|
97
95
|
icon: string | null;
|
|
@@ -103,7 +101,9 @@ export type BulkAction = {
|
|
|
103
101
|
};
|
|
104
102
|
export type Button = {
|
|
105
103
|
buttonType: ButtonType;
|
|
104
|
+
effects: Effect[];
|
|
106
105
|
href: string | null;
|
|
106
|
+
icon: string | null;
|
|
107
107
|
label: string;
|
|
108
108
|
variant: ButtonVariant | null;
|
|
109
109
|
};
|
|
@@ -148,10 +148,10 @@ export type ChartSeries = {
|
|
|
148
148
|
};
|
|
149
149
|
export type ChartSeriesType = "area" | "bar" | "line" | "pie";
|
|
150
150
|
export type ChatBox = {
|
|
151
|
-
conversationId: string | null;
|
|
152
151
|
fill: boolean;
|
|
153
152
|
historyEndpoint: string | null;
|
|
154
153
|
placeholder: string | null;
|
|
154
|
+
remote: RemoteAccess | null;
|
|
155
155
|
streamEndpoint: string | null;
|
|
156
156
|
title: string | null;
|
|
157
157
|
};
|
|
@@ -161,6 +161,10 @@ export type ChatMessage = {
|
|
|
161
161
|
readonly parts: Node[];
|
|
162
162
|
};
|
|
163
163
|
export type ChatNode = {
|
|
164
|
+
type: "chat.box";
|
|
165
|
+
key?: string;
|
|
166
|
+
props: ChatBox;
|
|
167
|
+
} | {
|
|
164
168
|
type: "chat.part.text";
|
|
165
169
|
key?: string;
|
|
166
170
|
props: TextPart;
|
|
@@ -296,10 +300,6 @@ export type CoreNode = {
|
|
|
296
300
|
type: "chart";
|
|
297
301
|
key?: string;
|
|
298
302
|
props: Chart;
|
|
299
|
-
} | {
|
|
300
|
-
type: "chat.box";
|
|
301
|
-
key?: string;
|
|
302
|
-
props: ChatBox;
|
|
303
303
|
} | {
|
|
304
304
|
type: "floating-panel";
|
|
305
305
|
key?: string;
|
|
@@ -420,9 +420,10 @@ export type Effect = ({
|
|
|
420
420
|
type: "resetForm";
|
|
421
421
|
} & ResetFormEffect) | ({
|
|
422
422
|
type: "toast";
|
|
423
|
-
} & ToastEffect)
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
} & ToastEffect) | ({
|
|
424
|
+
type: "toggleSidebar";
|
|
425
|
+
} & ToggleSidebarEffect);
|
|
426
|
+
export type FieldType = "field.builder" | "field.checkbox" | "field.choice" | "field.date-input" | "field.file-upload" | "field.hidden-input" | "field.number-input" | "field.otp" | "field.password-input" | "field.repeater" | "field.rich-editor" | "field.select" | "field.textarea" | "field.text-input";
|
|
426
427
|
export type FileUpload = {
|
|
427
428
|
accept: string | null;
|
|
428
429
|
columnWidth: ColumnWidth;
|
|
@@ -522,6 +523,10 @@ export type FormFieldNode = {
|
|
|
522
523
|
type: "field.number-input";
|
|
523
524
|
key?: string;
|
|
524
525
|
props: NumberInput;
|
|
526
|
+
} | {
|
|
527
|
+
type: "field.otp";
|
|
528
|
+
key?: string;
|
|
529
|
+
props: OtpInput;
|
|
525
530
|
} | {
|
|
526
531
|
type: "field.password-input";
|
|
527
532
|
key?: string;
|
|
@@ -747,6 +752,31 @@ export type Option = {
|
|
|
747
752
|
readonly value: string;
|
|
748
753
|
};
|
|
749
754
|
export type Orientation = "horizontal" | "vertical";
|
|
755
|
+
export type OtpInput = {
|
|
756
|
+
autoFocus: boolean;
|
|
757
|
+
columnWidth: ColumnWidth;
|
|
758
|
+
conditions: {
|
|
759
|
+
visible?: Condition[];
|
|
760
|
+
required?: Condition[];
|
|
761
|
+
readOnly?: Condition[];
|
|
762
|
+
disabled?: Condition[];
|
|
763
|
+
} | null;
|
|
764
|
+
dependsOnAny: boolean;
|
|
765
|
+
dependsOnKeys: string[] | null;
|
|
766
|
+
disabled: boolean;
|
|
767
|
+
editablePrefill: boolean;
|
|
768
|
+
helperText: string | null;
|
|
769
|
+
hidden: boolean;
|
|
770
|
+
label: string | null;
|
|
771
|
+
length: number;
|
|
772
|
+
name: string;
|
|
773
|
+
prefillRefreshOn: string[] | null;
|
|
774
|
+
prefillResetOn: string[] | null;
|
|
775
|
+
readOnly: boolean;
|
|
776
|
+
required: boolean;
|
|
777
|
+
tooltip: string | null;
|
|
778
|
+
value: unknown;
|
|
779
|
+
};
|
|
750
780
|
export type Outlet = Record<string, never>;
|
|
751
781
|
export type PageContainer = "centered" | "default";
|
|
752
782
|
export type PageLayout = "app" | "auth" | "none";
|
|
@@ -811,20 +841,7 @@ export type RemoteAccess = {
|
|
|
811
841
|
readonly tokenEndpoint: string;
|
|
812
842
|
readonly ref: string;
|
|
813
843
|
};
|
|
814
|
-
export type RemoteChatBox = {
|
|
815
|
-
conversationId: string | null;
|
|
816
|
-
fill: boolean;
|
|
817
|
-
historyEndpoint: string | null;
|
|
818
|
-
placeholder: string | null;
|
|
819
|
-
remote: RemoteAccess | null;
|
|
820
|
-
streamEndpoint: string | null;
|
|
821
|
-
title: string | null;
|
|
822
|
-
};
|
|
823
844
|
export type RemoteNode = {
|
|
824
|
-
type: "remote.chat-box";
|
|
825
|
-
key?: string;
|
|
826
|
-
props: RemoteChatBox;
|
|
827
|
-
} | {
|
|
828
845
|
type: "remote.data-list";
|
|
829
846
|
key?: string;
|
|
830
847
|
props: DataList;
|
|
@@ -1025,6 +1042,9 @@ export type Text = {
|
|
|
1025
1042
|
text: string;
|
|
1026
1043
|
};
|
|
1027
1044
|
export type TextColumn = {
|
|
1045
|
+
badge: {
|
|
1046
|
+
colorKey: string;
|
|
1047
|
+
} | null;
|
|
1028
1048
|
copyable: boolean;
|
|
1029
1049
|
date: {
|
|
1030
1050
|
format: string | null;
|
|
@@ -1033,6 +1053,7 @@ export type TextColumn = {
|
|
|
1033
1053
|
href: string | null;
|
|
1034
1054
|
external: boolean;
|
|
1035
1055
|
} | null;
|
|
1056
|
+
multiple: string | null;
|
|
1036
1057
|
};
|
|
1037
1058
|
export type TextInput = {
|
|
1038
1059
|
autoComplete: string | null;
|
|
@@ -1105,6 +1126,9 @@ export type ToastMessage = {
|
|
|
1105
1126
|
variant: Variant;
|
|
1106
1127
|
message: Translatable | string;
|
|
1107
1128
|
};
|
|
1129
|
+
export type ToggleSidebarEffect = {
|
|
1130
|
+
readonly target: string | null;
|
|
1131
|
+
};
|
|
1108
1132
|
export type ToolCallPart = {
|
|
1109
1133
|
args: Record<string, unknown>;
|
|
1110
1134
|
name: string;
|
package/dist/vite.js
CHANGED
|
@@ -3,7 +3,7 @@ import { svgSprite } from "@lattice-php/vite-svg-sprite";
|
|
|
3
3
|
import { searchForWorkspaceRoot } from "vite";
|
|
4
4
|
//#region resources/js/vite.ts
|
|
5
5
|
function lattice(options = {}) {
|
|
6
|
-
const plugins = [corePlugin(options)];
|
|
6
|
+
const plugins = [corePlugin(options), optionalPeersPlugin()];
|
|
7
7
|
const iconOptions = resolveIconOptions(options);
|
|
8
8
|
if (iconOptions) plugins.push(svgSprite(iconOptions));
|
|
9
9
|
return plugins;
|
|
@@ -43,6 +43,37 @@ function corePlugin(options) {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
var OPTIONAL_PEER_STUB_PREFIX = "\0lattice-optional-peer/";
|
|
47
|
+
/**
|
|
48
|
+
* Real-time listeners statically import their optional Echo peers. A consumer
|
|
49
|
+
* that never uses real-time should still build, so stub a missing peer with
|
|
50
|
+
* hooks that throw — the `RealtimeListeners` error boundary then degrades
|
|
51
|
+
* gracefully and warns to install the peer, exactly as when it is absent.
|
|
52
|
+
*/
|
|
53
|
+
var OPTIONAL_PEER_STUBS = { "@laravel/echo-react": [
|
|
54
|
+
"const missing = () => {",
|
|
55
|
+
" throw new Error(",
|
|
56
|
+
" \"[lattice] Real-time listeners require @laravel/echo-react. Install it and call configureEcho().\",",
|
|
57
|
+
" );",
|
|
58
|
+
"};",
|
|
59
|
+
"export const useEcho = missing;",
|
|
60
|
+
"export const useEchoPublic = missing;",
|
|
61
|
+
"export const useEchoPresence = missing;"
|
|
62
|
+
].join("\n") };
|
|
63
|
+
function optionalPeersPlugin() {
|
|
64
|
+
return {
|
|
65
|
+
name: "lattice:optional-peers",
|
|
66
|
+
enforce: "pre",
|
|
67
|
+
async resolveId(id) {
|
|
68
|
+
if (!Object.prototype.hasOwnProperty.call(OPTIONAL_PEER_STUBS, id)) return null;
|
|
69
|
+
return await this.resolve(id, void 0, { skipSelf: true }) ? null : `${OPTIONAL_PEER_STUB_PREFIX}${id}`;
|
|
70
|
+
},
|
|
71
|
+
load(id) {
|
|
72
|
+
if (!id.startsWith(OPTIONAL_PEER_STUB_PREFIX)) return null;
|
|
73
|
+
return OPTIONAL_PEER_STUBS[id.slice(23)] ?? null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
46
77
|
function resolveIconOptions(options) {
|
|
47
78
|
const icons = options.icons ?? true;
|
|
48
79
|
if (icons === false) return null;
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../resources/js/vite.ts"],"sourcesContent":["import path from \"node:path\";\nimport { svgSprite } from \"@lattice-php/vite-svg-sprite\";\nimport type { SvgSpriteOptions } from \"@lattice-php/vite-svg-sprite\";\nimport { searchForWorkspaceRoot } from \"vite\";\nimport type { Plugin, PluginOption, UserConfig } from \"vite\";\n\ntype InlineDependency = string | RegExp;\n\ntype ConfigWithTest = UserConfig & {\n test?: {\n server?: {\n deps?: {\n inline?: InlineDependency[];\n };\n };\n };\n};\n\nexport type LatticeViteIconsOptions = Omit<SvgSpriteOptions, \"dts\" | \"iconDirs\"> & {\n dirs?: string[];\n dts?: SvgSpriteOptions[\"dts\"] | false;\n};\n\nexport type LatticeViteOptions = {\n appRoot?: string;\n icons?: boolean | LatticeViteIconsOptions;\n root?: string;\n source?: boolean;\n};\n\ntype Roots = {\n appRoot: string;\n root: string;\n};\n\nexport function lattice(options: LatticeViteOptions = {}): PluginOption[] {\n const plugins: PluginOption[] = [corePlugin(options)];\n const iconOptions = resolveIconOptions(options);\n\n if (iconOptions) {\n plugins.push(svgSprite(iconOptions));\n }\n\n return plugins;\n}\n\nexport function latticeConfig(options: LatticeViteOptions = {}): ConfigWithTest {\n const { appRoot, root } = resolveRoots(options);\n\n return {\n resolve: {\n alias: options.source\n ? {\n \"@lattice-php/lattice/css\": path.resolve(root, \"resources/css/lattice.css\"),\n \"@lattice-php/lattice\": path.resolve(root, \"resources/js\"),\n }\n : {\n react: path.resolve(appRoot, \"node_modules/react\"),\n \"react-dom\": path.resolve(appRoot, \"node_modules/react-dom\"),\n },\n dedupe: [\"@inertiajs/react\", \"react\", \"react-dom\"],\n },\n server: options.source\n ? {\n fs: {\n allow: [searchForWorkspaceRoot(appRoot), root],\n },\n }\n : undefined,\n test: {\n server: {\n deps: {\n inline: [\n \"@lattice-php/lattice\",\n /[/\\\\]lattice[/\\\\]dist[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@radix-ui[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@tiptap[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]react-i18next[/\\\\]/,\n ],\n },\n },\n },\n };\n}\n\nfunction corePlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice\",\n config() {\n return latticeConfig(options);\n },\n };\n}\n\nfunction resolveIconOptions(options: LatticeViteOptions): SvgSpriteOptions | null {\n const icons = options.icons ?? true;\n\n if (icons === false) {\n return null;\n }\n\n const { root } = resolveRoots(options);\n const iconOptions = icons === true ? {} : icons;\n const { dirs = [], dts, ...spriteOptions } = iconOptions;\n const defaultTypes = {\n file: \"resources/js/types/sprite-icons.ts\",\n augmentModule: \"@lattice-php/lattice\",\n augmentInterface: \"KnownIcons\",\n };\n\n return {\n ...spriteOptions,\n iconDirs: [path.resolve(root, \"resources/icons\"), ...dirs],\n ...(dts === false ? {} : { dts: dts ?? defaultTypes }),\n };\n}\n\nfunction resolveRoots(options: LatticeViteOptions): Roots {\n const appRoot = options.appRoot ?? process.cwd();\n const root = options.root ?? path.resolve(appRoot, \"vendor/lattice-php/lattice\");\n\n return { appRoot, root };\n}\n"],"mappings":";;;;AAmCA,SAAgB,QAAQ,UAA8B,CAAC,GAAmB;CACxE,MAAM,UAA0B,CAAC,WAAW,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../resources/js/vite.ts"],"sourcesContent":["import path from \"node:path\";\nimport { svgSprite } from \"@lattice-php/vite-svg-sprite\";\nimport type { SvgSpriteOptions } from \"@lattice-php/vite-svg-sprite\";\nimport { searchForWorkspaceRoot } from \"vite\";\nimport type { Plugin, PluginOption, UserConfig } from \"vite\";\n\ntype InlineDependency = string | RegExp;\n\ntype ConfigWithTest = UserConfig & {\n test?: {\n server?: {\n deps?: {\n inline?: InlineDependency[];\n };\n };\n };\n};\n\nexport type LatticeViteIconsOptions = Omit<SvgSpriteOptions, \"dts\" | \"iconDirs\"> & {\n dirs?: string[];\n dts?: SvgSpriteOptions[\"dts\"] | false;\n};\n\nexport type LatticeViteOptions = {\n appRoot?: string;\n icons?: boolean | LatticeViteIconsOptions;\n root?: string;\n source?: boolean;\n};\n\ntype Roots = {\n appRoot: string;\n root: string;\n};\n\nexport function lattice(options: LatticeViteOptions = {}): PluginOption[] {\n const plugins: PluginOption[] = [corePlugin(options), optionalPeersPlugin()];\n const iconOptions = resolveIconOptions(options);\n\n if (iconOptions) {\n plugins.push(svgSprite(iconOptions));\n }\n\n return plugins;\n}\n\nexport function latticeConfig(options: LatticeViteOptions = {}): ConfigWithTest {\n const { appRoot, root } = resolveRoots(options);\n\n return {\n resolve: {\n alias: options.source\n ? {\n \"@lattice-php/lattice/css\": path.resolve(root, \"resources/css/lattice.css\"),\n \"@lattice-php/lattice\": path.resolve(root, \"resources/js\"),\n }\n : {\n react: path.resolve(appRoot, \"node_modules/react\"),\n \"react-dom\": path.resolve(appRoot, \"node_modules/react-dom\"),\n },\n dedupe: [\"@inertiajs/react\", \"react\", \"react-dom\"],\n },\n server: options.source\n ? {\n fs: {\n allow: [searchForWorkspaceRoot(appRoot), root],\n },\n }\n : undefined,\n test: {\n server: {\n deps: {\n inline: [\n \"@lattice-php/lattice\",\n /[/\\\\]lattice[/\\\\]dist[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@radix-ui[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@tiptap[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]react-i18next[/\\\\]/,\n ],\n },\n },\n },\n };\n}\n\nfunction corePlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice\",\n config() {\n return latticeConfig(options);\n },\n };\n}\n\nconst OPTIONAL_PEER_STUB_PREFIX = \"\\0lattice-optional-peer/\";\n\n/**\n * Real-time listeners statically import their optional Echo peers. A consumer\n * that never uses real-time should still build, so stub a missing peer with\n * hooks that throw — the `RealtimeListeners` error boundary then degrades\n * gracefully and warns to install the peer, exactly as when it is absent.\n */\nconst OPTIONAL_PEER_STUBS: Record<string, string> = {\n \"@laravel/echo-react\": [\n \"const missing = () => {\",\n \" throw new Error(\",\n ' \"[lattice] Real-time listeners require @laravel/echo-react. Install it and call configureEcho().\",',\n \" );\",\n \"};\",\n \"export const useEcho = missing;\",\n \"export const useEchoPublic = missing;\",\n \"export const useEchoPresence = missing;\",\n ].join(\"\\n\"),\n};\n\nfunction optionalPeersPlugin(): Plugin {\n return {\n name: \"lattice:optional-peers\",\n enforce: \"pre\",\n async resolveId(id) {\n if (!Object.prototype.hasOwnProperty.call(OPTIONAL_PEER_STUBS, id)) {\n return null;\n }\n\n const installed = await this.resolve(id, undefined, { skipSelf: true });\n\n return installed ? null : `${OPTIONAL_PEER_STUB_PREFIX}${id}`;\n },\n load(id) {\n if (!id.startsWith(OPTIONAL_PEER_STUB_PREFIX)) {\n return null;\n }\n\n return OPTIONAL_PEER_STUBS[id.slice(OPTIONAL_PEER_STUB_PREFIX.length)] ?? null;\n },\n };\n}\n\nfunction resolveIconOptions(options: LatticeViteOptions): SvgSpriteOptions | null {\n const icons = options.icons ?? true;\n\n if (icons === false) {\n return null;\n }\n\n const { root } = resolveRoots(options);\n const iconOptions = icons === true ? {} : icons;\n const { dirs = [], dts, ...spriteOptions } = iconOptions;\n const defaultTypes = {\n file: \"resources/js/types/sprite-icons.ts\",\n augmentModule: \"@lattice-php/lattice\",\n augmentInterface: \"KnownIcons\",\n };\n\n return {\n ...spriteOptions,\n iconDirs: [path.resolve(root, \"resources/icons\"), ...dirs],\n ...(dts === false ? {} : { dts: dts ?? defaultTypes }),\n };\n}\n\nfunction resolveRoots(options: LatticeViteOptions): Roots {\n const appRoot = options.appRoot ?? process.cwd();\n const root = options.root ?? path.resolve(appRoot, \"vendor/lattice-php/lattice\");\n\n return { appRoot, root };\n}\n"],"mappings":";;;;AAmCA,SAAgB,QAAQ,UAA8B,CAAC,GAAmB;CACxE,MAAM,UAA0B,CAAC,WAAW,OAAO,GAAG,oBAAoB,CAAC;CAC3E,MAAM,cAAc,mBAAmB,OAAO;CAE9C,IAAI,aACF,QAAQ,KAAK,UAAU,WAAW,CAAC;CAGrC,OAAO;AACT;AAEA,SAAgB,cAAc,UAA8B,CAAC,GAAmB;CAC9E,MAAM,EAAE,SAAS,SAAS,aAAa,OAAO;CAE9C,OAAO;EACL,SAAS;GACP,OAA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G,kBADP,UAAU,OAAO,CAAC,IAAI;CAE1C,MAAM,eAAe;EACnB,MAAM;EACN,eAAe;EACf,kBAAkB;CACpB;CAEA,OAAO;EACL,GAAG;EACH,UAAU,CAAC,KAAK,QAAQ,MAAM,iBAAiB,GAAG,GAAG,IAAI;EACzD,GAAI,QAAQ,QAAQ,CAAC,IAAI,EAAE,KAAK,OAAO,aAAa;CACtD;AACF;AAEA,SAAS,aAAa,SAAoC;CACxD,MAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI;CAG/C,OAAO;EAAE;EAAS,MAFL,QAAQ,QAAQ,KAAK,QAAQ,SAAS,4BAA4B;CAExD;AACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lattice-php/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Server-driven React components for Laravel and Inertia.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Manuel Christlieb <manuel@christlieb.eu>",
|
|
@@ -135,6 +135,14 @@
|
|
|
135
135
|
"types": "./dist/registry.d.ts",
|
|
136
136
|
"import": "./dist/registry.js"
|
|
137
137
|
},
|
|
138
|
+
"./remote": {
|
|
139
|
+
"types": "./dist/remote/index.d.ts",
|
|
140
|
+
"import": "./dist/remote/index.js"
|
|
141
|
+
},
|
|
142
|
+
"./remote/*": {
|
|
143
|
+
"types": "./dist/remote/*.d.ts",
|
|
144
|
+
"import": "./dist/remote/*.js"
|
|
145
|
+
},
|
|
138
146
|
"./table": {
|
|
139
147
|
"types": "./dist/table/index.d.ts",
|
|
140
148
|
"import": "./dist/table/index.js"
|
|
@@ -195,8 +203,8 @@
|
|
|
195
203
|
"lint": "oxlint resources/js workbench/resources/js",
|
|
196
204
|
"lint:fix": "oxlint resources/js workbench/resources/js --fix",
|
|
197
205
|
"lint:github": "oxlint resources/js workbench/resources/js --format=github",
|
|
198
|
-
"format": "oxfmt --write \"resources/js/**/*.{ts,tsx}\" \"workbench/resources/js/**/*.{ts,tsx}\"",
|
|
199
|
-
"format:check": "oxfmt --check \"resources/js/**/*.{ts,tsx}\" \"workbench/resources/js/**/*.{ts,tsx}\"",
|
|
206
|
+
"format": "oxfmt --write \"resources/js/**/*.{ts,tsx}\" \"workbench/resources/js/**/*.{ts,tsx}\" \"docs/**/*.{ts,tsx,md,mdx}\"",
|
|
207
|
+
"format:check": "oxfmt --check \"resources/js/**/*.{ts,tsx}\" \"workbench/resources/js/**/*.{ts,tsx}\" \"docs/**/*.{ts,tsx,md,mdx}\"",
|
|
200
208
|
"analyze": "SONDA=1 vite build && mkdir -p docs/public && cp docs/generated/bundle-report.html docs/public/bundle-report.html",
|
|
201
209
|
"docs:dev": "npm run analyze && astro dev",
|
|
202
210
|
"docs:build": "npm run analyze && astro build",
|
|
@@ -222,7 +230,9 @@
|
|
|
222
230
|
"clsx": "^2.1.1",
|
|
223
231
|
"i18next": "^26.3.1",
|
|
224
232
|
"i18next-http-backend": "^4.0.0",
|
|
233
|
+
"input-otp": "^1.4.2",
|
|
225
234
|
"recharts": "^3.8.1",
|
|
235
|
+
"starlight-llms-txt": "^0.10.0",
|
|
226
236
|
"tailwind-merge": "^3.0.1"
|
|
227
237
|
},
|
|
228
238
|
"peerDependencies": {
|
|
@@ -264,6 +274,7 @@
|
|
|
264
274
|
"laravel-echo": "^2.3.7",
|
|
265
275
|
"laravel-vite-plugin": "^3.0.0",
|
|
266
276
|
"lucide-static": "^1.18.0",
|
|
277
|
+
"mermaid": "^11.15.0",
|
|
267
278
|
"oxfmt": "^0.54.0",
|
|
268
279
|
"oxlint": "^1.68.0",
|
|
269
280
|
"playwright": "^1.60.0",
|