@lattice-php/lattice 0.1.0 → 0.2.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/_virtual/_rolldown/runtime.js +8 -0
- package/dist/action/components/action-form.d.ts +24 -0
- package/dist/action/components/action-form.js +270 -0
- package/dist/action/components/action-form.js.map +1 -0
- package/dist/action/components/action-group.d.ts +1 -8
- package/dist/action/components/action-group.js +24 -66
- package/dist/action/components/action-group.js.map +1 -1
- package/dist/action/components/action.d.ts +1 -24
- package/dist/action/components/action.js +61 -46
- package/dist/action/components/action.js.map +1 -1
- package/dist/action/effects.d.ts +6 -25
- package/dist/action/effects.js +2 -2
- package/dist/action/effects.js.map +1 -1
- package/dist/action/index.d.ts +1 -1
- package/dist/core/components/badge.d.ts +1 -8
- package/dist/core/components/badge.js +2 -3
- package/dist/core/components/badge.js.map +1 -1
- package/dist/core/components/button.d.ts +4 -12
- package/dist/core/components/button.js +6 -9
- package/dist/core/components/button.js.map +1 -1
- package/dist/core/components/card.d.ts +1 -9
- package/dist/core/components/card.js +1 -3
- package/dist/core/components/card.js.map +1 -1
- package/dist/core/components/confirm-dialog.d.ts +2 -3
- package/dist/core/components/confirm-dialog.js +19 -13
- package/dist/core/components/confirm-dialog.js.map +1 -1
- package/dist/core/components/fragment.d.ts +1 -10
- package/dist/core/components/fragment.js +5 -6
- package/dist/core/components/fragment.js.map +1 -1
- package/dist/core/components/grid.d.ts +1 -8
- package/dist/core/components/grid.js +1 -2
- package/dist/core/components/grid.js.map +1 -1
- package/dist/core/components/heading.d.ts +1 -9
- package/dist/core/components/heading.js +2 -3
- package/dist/core/components/heading.js.map +1 -1
- package/dist/core/components/icon.d.ts +3 -0
- package/dist/core/components/icon.js +30 -0
- package/dist/core/components/icon.js.map +1 -0
- package/dist/core/components/index.d.ts +1 -1
- package/dist/core/components/index.js +4 -0
- package/dist/core/components/index.js.map +1 -1
- package/dist/core/components/link.d.ts +1 -12
- package/dist/core/components/link.js +4 -9
- package/dist/core/components/link.js.map +1 -1
- package/dist/core/components/modal.d.ts +1 -11
- package/dist/core/components/modal.js +27 -31
- package/dist/core/components/modal.js.map +1 -1
- package/dist/core/components/section.d.ts +3 -0
- package/dist/core/components/section.js +79 -0
- package/dist/core/components/section.js.map +1 -0
- package/dist/core/components/segmented-control.d.ts +1 -14
- package/dist/core/components/segmented-control.js +4 -7
- package/dist/core/components/segmented-control.js.map +1 -1
- package/dist/core/components/segmented-pills.d.ts +4 -2
- package/dist/core/components/segmented-pills.js +10 -1
- package/dist/core/components/segmented-pills.js.map +1 -1
- package/dist/core/components/spinner.js +8 -4
- package/dist/core/components/spinner.js.map +1 -1
- package/dist/core/components/stack.d.ts +1 -11
- package/dist/core/components/stack.js +5 -5
- package/dist/core/components/stack.js.map +1 -1
- package/dist/core/components/tabs.d.ts +1 -19
- package/dist/core/components/tabs.js +45 -21
- package/dist/core/components/tabs.js.map +1 -1
- package/dist/core/components/text.d.ts +1 -9
- package/dist/core/components/text.js +2 -3
- package/dist/core/components/text.js.map +1 -1
- package/dist/core/registry.d.ts +9 -3
- package/dist/core/registry.js +21 -5
- package/dist/core/registry.js.map +1 -1
- package/dist/core/renderer.js +7 -13
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/types.d.ts +54 -26
- package/dist/form/components/base/checkbox.js +5 -2
- package/dist/form/components/base/checkbox.js.map +1 -1
- package/dist/form/components/base/field.d.ts +2 -1
- package/dist/form/components/base/field.js +5 -1
- package/dist/form/components/base/field.js.map +1 -1
- package/dist/form/components/base/password-input.js +9 -2
- package/dist/form/components/base/password-input.js.map +1 -1
- package/dist/form/components/base/submit-button.d.ts +4 -4
- package/dist/form/components/base/submit-button.js +2 -2
- package/dist/form/components/base/submit-button.js.map +1 -1
- package/dist/form/components/conditions.d.ts +6 -9
- package/dist/form/components/conditions.js +10 -2
- package/dist/form/components/conditions.js.map +1 -1
- package/dist/form/components/context.d.ts +0 -4
- package/dist/form/components/context.js +1 -5
- package/dist/form/components/context.js.map +1 -1
- package/dist/form/components/field-props.d.ts +24 -0
- package/dist/form/components/field-props.js +15 -0
- package/dist/form/components/field-props.js.map +1 -0
- package/dist/form/components/fields/checkbox.d.ts +1 -15
- package/dist/form/components/fields/checkbox.js +16 -21
- package/dist/form/components/fields/checkbox.js.map +1 -1
- package/dist/form/components/fields/choice.d.ts +1 -13
- package/dist/form/components/fields/choice.js +13 -20
- package/dist/form/components/fields/choice.js.map +1 -1
- package/dist/form/components/fields/date-input.d.ts +1 -19
- package/dist/form/components/fields/date-input.js +11 -16
- package/dist/form/components/fields/date-input.js.map +1 -1
- package/dist/form/components/fields/hidden-input.d.ts +1 -9
- package/dist/form/components/fields/hidden-input.js +2 -3
- package/dist/form/components/fields/hidden-input.js.map +1 -1
- package/dist/form/components/fields/number-input.d.ts +1 -22
- package/dist/form/components/fields/number-input.js +38 -41
- package/dist/form/components/fields/number-input.js.map +1 -1
- package/dist/form/components/fields/password-input.d.ts +1 -28
- package/dist/form/components/fields/password-input.js +15 -24
- package/dist/form/components/fields/password-input.js.map +1 -1
- package/dist/form/components/fields/rich-editor.d.ts +1 -16
- package/dist/form/components/fields/rich-editor.js +57 -47
- package/dist/form/components/fields/rich-editor.js.map +1 -1
- package/dist/form/components/fields/select.d.ts +1 -22
- package/dist/form/components/fields/select.js +85 -74
- package/dist/form/components/fields/select.js.map +1 -1
- package/dist/form/components/fields/simple-field.d.ts +9 -0
- package/dist/form/components/fields/simple-field.js +22 -0
- package/dist/form/components/fields/simple-field.js.map +1 -0
- package/dist/form/components/fields/text-input.d.ts +1 -20
- package/dist/form/components/fields/text-input.js +12 -17
- package/dist/form/components/fields/text-input.js.map +1 -1
- package/dist/form/components/fields/textarea.d.ts +1 -19
- package/dist/form/components/fields/textarea.js +11 -16
- package/dist/form/components/fields/textarea.js.map +1 -1
- package/dist/form/components/form.d.ts +1 -20
- package/dist/form/components/form.js +29 -36
- package/dist/form/components/form.js.map +1 -1
- package/dist/form/components/index.d.ts +0 -1
- package/dist/form/components/index.js +1 -2
- package/dist/form/components/resolved-nodes.d.ts +1 -1
- package/dist/form/components/resolved-nodes.js +2 -2
- package/dist/form/components/resolved-nodes.js.map +1 -1
- package/dist/form/components/types.d.ts +1 -0
- package/dist/form/components/use-controlled-field.d.ts +3 -9
- package/dist/form/components/use-controlled-field.js +5 -9
- package/dist/form/components/use-controlled-field.js.map +1 -1
- package/dist/form/components/use-dependent-field.d.ts +1 -1
- package/dist/form/components/use-dependent-field.js +8 -8
- package/dist/form/components/use-dependent-field.js.map +1 -1
- package/dist/form/components/use-form-resolver.d.ts +1 -1
- package/dist/form/components/use-form-resolver.js +8 -13
- package/dist/form/components/use-form-resolver.js.map +1 -1
- package/dist/form/components/use-seed-default.d.ts +5 -0
- package/dist/form/components/use-seed-default.js +23 -0
- package/dist/form/components/use-seed-default.js.map +1 -0
- package/dist/form/index.d.ts +1 -1
- package/dist/form/index.js +0 -1
- package/dist/form/index.js.map +1 -1
- package/dist/form/skeleton.d.ts +1 -1
- package/dist/form/skeleton.js +1 -1
- package/dist/form/skeleton.js.map +1 -1
- package/dist/i18n/backend.d.ts +24 -0
- package/dist/i18n/backend.js +39 -0
- package/dist/i18n/backend.js.map +1 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/instance.js +48 -0
- package/dist/i18n/instance.js.map +1 -0
- package/dist/icons/icon-renderer.js +30 -5
- package/dist/icons/icon-renderer.js.map +1 -1
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +2 -1
- package/dist/icons/sprite.d.ts +30 -0
- package/dist/icons/sprite.js +40 -0
- package/dist/icons/sprite.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +7 -3
- package/dist/inertia.d.ts +1 -6
- package/dist/inertia.js +4 -8
- package/dist/inertia.js.map +1 -1
- package/dist/lattice.css +129 -5
- package/dist/layout/components.d.ts +1 -0
- package/dist/layout/components.js +19 -0
- package/dist/layout/components.js.map +1 -0
- package/dist/layout/context.d.ts +12 -0
- package/dist/layout/context.js +19 -0
- package/dist/layout/context.js.map +1 -0
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/menu-item.d.ts +3 -0
- package/dist/layout/menu-item.js +130 -0
- package/dist/layout/menu-item.js.map +1 -0
- package/dist/layout/menu.d.ts +3 -0
- package/dist/layout/menu.js +13 -0
- package/dist/layout/menu.js.map +1 -0
- package/dist/layout/outlet.d.ts +6 -0
- package/dist/layout/outlet.js +14 -0
- package/dist/layout/outlet.js.map +1 -0
- package/dist/layout/schema-layout.d.ts +10 -0
- package/dist/layout/schema-layout.js +30 -0
- package/dist/layout/schema-layout.js.map +1 -0
- package/dist/layout/sidebar.d.ts +3 -0
- package/dist/layout/sidebar.js +48 -0
- package/dist/layout/sidebar.js.map +1 -0
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.js +1 -4
- package/dist/lib/utils.js.map +1 -1
- package/dist/node_modules/i18next/dist/esm/i18next.js +1982 -0
- package/dist/node_modules/i18next/dist/esm/i18next.js.map +1 -0
- package/dist/node_modules/i18next-http-backend/esm/index.js +352 -0
- package/dist/node_modules/i18next-http-backend/esm/index.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/context.js +23 -0
- package/dist/node_modules/react-i18next/dist/es/context.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/defaults.js +29 -0
- package/dist/node_modules/react-i18next/dist/es/defaults.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/i18nInstance.js +10 -0
- package/dist/node_modules/react-i18next/dist/es/i18nInstance.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/initReactI18next.js +14 -0
- package/dist/node_modules/react-i18next/dist/es/initReactI18next.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/unescape.js +30 -0
- package/dist/node_modules/react-i18next/dist/es/unescape.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/useTranslation.js +157 -0
- package/dist/node_modules/react-i18next/dist/es/useTranslation.js.map +1 -0
- package/dist/node_modules/react-i18next/dist/es/utils.js +58 -0
- package/dist/node_modules/react-i18next/dist/es/utils.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +70 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +61 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +13 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/page.d.ts +1 -1
- package/dist/page.js +2 -2
- package/dist/page.js.map +1 -1
- package/dist/provider.d.ts +8 -3
- package/dist/provider.js +17 -9
- package/dist/provider.js.map +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +2 -1
- package/dist/registry.js.map +1 -1
- package/dist/table/bulk.d.ts +6 -10
- package/dist/table/bulk.js +13 -35
- package/dist/table/bulk.js.map +1 -1
- package/dist/table/column-registry.d.ts +9 -0
- package/dist/table/components/bulk-bar.js +34 -3
- package/dist/table/components/bulk-bar.js.map +1 -1
- package/dist/table/components/cells/badge-cell.d.ts +5 -0
- package/dist/table/components/cells/badge-cell.js +16 -0
- package/dist/table/components/cells/badge-cell.js.map +1 -0
- package/dist/table/components/cells/icon-cell.d.ts +5 -0
- package/dist/table/components/cells/icon-cell.js +22 -0
- package/dist/table/components/cells/icon-cell.js.map +1 -0
- package/dist/table/components/cells/image-cell.d.ts +5 -0
- package/dist/table/components/cells/image-cell.js +24 -0
- package/dist/table/components/cells/image-cell.js.map +1 -0
- package/dist/table/components/cells/text-cell.d.ts +6 -0
- package/dist/table/components/cells/text-cell.js +50 -0
- package/dist/table/components/cells/text-cell.js.map +1 -0
- package/dist/table/components/column-filter-control.js +59 -96
- package/dist/table/components/column-filter-control.js.map +1 -1
- package/dist/table/components/column-header.js +22 -11
- package/dist/table/components/column-header.js.map +1 -1
- package/dist/table/components/filter-stack-bar.d.ts +2 -2
- package/dist/table/components/filter-stack-bar.js +10 -8
- package/dist/table/components/filter-stack-bar.js.map +1 -1
- package/dist/table/components/filter-value-input.d.ts +5 -3
- package/dist/table/components/filter-value-input.js +25 -16
- package/dist/table/components/filter-value-input.js.map +1 -1
- package/dist/table/components/pagination.d.ts +1 -1
- package/dist/table/components/pagination.js +20 -8
- package/dist/table/components/pagination.js.map +1 -1
- package/dist/table/components/sort-bar.d.ts +2 -2
- package/dist/table/components/sort-bar.js +12 -10
- package/dist/table/components/sort-bar.js.map +1 -1
- package/dist/table/components/table-action-node.d.ts +1 -1
- package/dist/table/components/table-action-node.js +1 -1
- package/dist/table/components/table-action-node.js.map +1 -1
- package/dist/table/components/table-cell.d.ts +1 -1
- package/dist/table/components/table-cell.js +24 -43
- package/dist/table/components/table-cell.js.map +1 -1
- package/dist/table/components/table.d.ts +6 -2
- package/dist/table/components/table.js +40 -17
- package/dist/table/components/table.js.map +1 -1
- package/dist/table/format.js +5 -3
- package/dist/table/format.js.map +1 -1
- package/dist/table/index.d.ts +1 -1
- package/dist/table/index.js.map +1 -1
- package/dist/table/payload.d.ts +1 -1
- package/dist/table/query.d.ts +0 -1
- package/dist/table/query.js +8 -9
- package/dist/table/query.js.map +1 -1
- package/dist/table/types.d.ts +38 -42
- package/dist/table/use-table.d.ts +3 -4
- package/dist/table/use-table.js +12 -23
- package/dist/table/use-table.js.map +1 -1
- package/dist/test-support.d.ts +14 -0
- package/dist/test-support.js +14 -0
- package/dist/test-support.js.map +1 -0
- package/dist/toast/index.d.ts +1 -0
- package/dist/toast/index.js +2 -0
- package/dist/toast/toaster.d.ts +3 -0
- package/dist/toast/toaster.js +126 -0
- package/dist/toast/toaster.js.map +1 -0
- package/dist/types/generated.d.ts +677 -0
- package/dist/types/generated.js +0 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +18 -3
- package/resources/icons/align-center.svg +17 -0
- package/resources/icons/align-justify.svg +17 -0
- package/resources/icons/align-left.svg +17 -0
- package/resources/icons/align-right.svg +17 -0
- package/resources/icons/arrow-down.svg +16 -0
- package/resources/icons/arrow-up.svg +16 -0
- package/resources/icons/bold.svg +15 -0
- package/resources/icons/check.svg +15 -0
- package/resources/icons/chevron-down.svg +15 -0
- package/resources/icons/chevron-right.svg +15 -0
- package/resources/icons/chevrons-up-down.svg +16 -0
- package/resources/icons/circle-alert.svg +17 -0
- package/resources/icons/circle-check.svg +16 -0
- package/resources/icons/circle-help.svg +17 -0
- package/resources/icons/circle-x.svg +17 -0
- package/resources/icons/code.svg +16 -0
- package/resources/icons/columns-3.svg +17 -0
- package/resources/icons/copy.svg +16 -0
- package/resources/icons/external-link.svg +17 -0
- package/resources/icons/eye-off.svg +18 -0
- package/resources/icons/eye.svg +16 -0
- package/resources/icons/filter.svg +15 -0
- package/resources/icons/heading-1.svg +18 -0
- package/resources/icons/heading-2.svg +18 -0
- package/resources/icons/heading-3.svg +19 -0
- package/resources/icons/highlighter.svg +16 -0
- package/resources/icons/info.svg +17 -0
- package/resources/icons/italic.svg +17 -0
- package/resources/icons/layout-dashboard.svg +18 -0
- package/resources/icons/link.svg +16 -0
- package/resources/icons/list-ordered.svg +20 -0
- package/resources/icons/list.svg +20 -0
- package/resources/icons/loader-2.svg +15 -0
- package/resources/icons/minus.svg +15 -0
- package/resources/icons/more-horizontal.svg +17 -0
- package/resources/icons/panel-left.svg +16 -0
- package/resources/icons/pencil-line.svg +17 -0
- package/resources/icons/pencil.svg +16 -0
- package/resources/icons/plus.svg +16 -0
- package/resources/icons/quote.svg +16 -0
- package/resources/icons/rows-3.svg +17 -0
- package/resources/icons/search.svg +16 -0
- package/resources/icons/send.svg +16 -0
- package/resources/icons/settings.svg +16 -0
- package/resources/icons/smile.svg +18 -0
- package/resources/icons/strikethrough.svg +17 -0
- package/resources/icons/table.svg +18 -0
- package/resources/icons/trash-2.svg +19 -0
- package/resources/icons/underline.svg +16 -0
- package/resources/icons/x.svg +16 -0
- package/dist/core/props.d.ts +0 -14
- package/dist/core/props.js +0 -30
- package/dist/core/props.js.map +0 -1
- package/dist/form/components/fields/submit-button.d.ts +0 -10
- package/dist/form/components/fields/submit-button.js +0 -14
- package/dist/form/components/fields/submit-button.js.map +0 -1
- package/dist/generated/types.d.ts +0 -17
- package/dist/icons/default-icons.d.ts +0 -3
- package/dist/icons/default-icons.js +0 -44
- package/dist/icons/default-icons.js.map +0 -1
- package/dist/icons/dynamic-lucide-renderer.d.ts +0 -2
- package/dist/icons/dynamic-lucide-renderer.js +0 -18
- package/dist/icons/dynamic-lucide-renderer.js.map +0 -1
- package/dist/menu/index.d.ts +0 -1
- package/dist/menu/index.js +0 -2
- package/dist/menu/use-menu.d.ts +0 -2
- package/dist/menu/use-menu.js +0 -9
- package/dist/menu/use-menu.js.map +0 -1
- /package/dist/{generated/types.js → table/column-registry.js} +0 -0
|
@@ -1,52 +1,49 @@
|
|
|
1
|
-
import { getBooleanProp, getOptionalNumberProp, getStringProp } from "../../../core/props.js";
|
|
2
|
-
import { FormFieldFrame } from "../base/field.js";
|
|
3
|
-
import { useControlledField } from "../use-controlled-field.js";
|
|
4
1
|
import { Input } from "../base/input.js";
|
|
2
|
+
import { SimpleField } from "./simple-field.js";
|
|
5
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
4
|
//#region resources/js/form/components/fields/number-input.tsx
|
|
7
5
|
var NumberInputComponent = ({ node }) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const props = node.props;
|
|
7
|
+
return /* @__PURE__ */ jsx(SimpleField, {
|
|
8
|
+
node,
|
|
9
|
+
label: props.label ?? "",
|
|
10
|
+
children: ({ name, value, readOnly, disabled, commit }) => {
|
|
11
|
+
const onChange = (event) => commit(event.target.value);
|
|
12
|
+
return props.slider ? /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "flex items-center gap-3",
|
|
14
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
15
|
+
"aria-label": props.label ?? "",
|
|
16
|
+
className: "h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
17
|
+
disabled: disabled || readOnly,
|
|
18
|
+
id: name,
|
|
19
|
+
max: props.max ?? void 0,
|
|
20
|
+
min: props.min ?? void 0,
|
|
21
|
+
name,
|
|
22
|
+
onChange,
|
|
23
|
+
step: props.step ?? void 0,
|
|
24
|
+
tabIndex: props.tabIndex ?? void 0,
|
|
25
|
+
type: "range",
|
|
26
|
+
value
|
|
27
|
+
}), /* @__PURE__ */ jsx("output", {
|
|
28
|
+
className: "w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg",
|
|
29
|
+
children: value
|
|
30
|
+
})]
|
|
31
|
+
}) : /* @__PURE__ */ jsx(Input, {
|
|
32
|
+
autoFocus: props.autoFocus ?? false,
|
|
33
|
+
disabled,
|
|
22
34
|
id: name,
|
|
23
|
-
max:
|
|
24
|
-
min:
|
|
35
|
+
max: props.max ?? void 0,
|
|
36
|
+
min: props.min ?? void 0,
|
|
25
37
|
name,
|
|
26
38
|
onChange,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
placeholder: props.placeholder ?? "",
|
|
40
|
+
readOnly,
|
|
41
|
+
step: props.step ?? void 0,
|
|
42
|
+
tabIndex: props.tabIndex ?? void 0,
|
|
43
|
+
type: "number",
|
|
30
44
|
value
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
children: value
|
|
34
|
-
})]
|
|
35
|
-
}) : /* @__PURE__ */ jsx(Input, {
|
|
36
|
-
autoFocus: getBooleanProp(node.props, "autoFocus"),
|
|
37
|
-
disabled,
|
|
38
|
-
id: name,
|
|
39
|
-
max: getOptionalNumberProp(node.props, "max"),
|
|
40
|
-
min: getOptionalNumberProp(node.props, "min"),
|
|
41
|
-
name,
|
|
42
|
-
onChange,
|
|
43
|
-
placeholder: getStringProp(node.props, "placeholder"),
|
|
44
|
-
readOnly: readonly,
|
|
45
|
-
step: getOptionalNumberProp(node.props, "step"),
|
|
46
|
-
tabIndex: getOptionalNumberProp(node.props, "tabIndex"),
|
|
47
|
-
type: "number",
|
|
48
|
-
value
|
|
49
|
-
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
50
47
|
});
|
|
51
48
|
};
|
|
52
49
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-input.js","names":[],"sources":["../../../../resources/js/form/components/fields/number-input.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"number-input.js","names":[],"sources":["../../../../resources/js/form/components/fields/number-input.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice/lattice/core/types\";\nimport { Input } from \"../base/input\";\nimport { SimpleField } from \"./simple-field\";\n\nexport const NumberInputComponent: RendererComponent<\"form.number-input\"> = ({ node }) => {\n const props = node.props;\n\n return (\n <SimpleField node={node} label={props.label ?? \"\"}>\n {({ name, value, readOnly, disabled, commit }) => {\n const onChange = (event: React.ChangeEvent<HTMLInputElement>): void =>\n commit(event.target.value);\n\n return props.slider ? (\n <div className=\"flex items-center gap-3\">\n <input\n aria-label={props.label ?? \"\"}\n className=\"h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:opacity-50\"\n disabled={disabled || readOnly}\n id={name}\n max={props.max ?? undefined}\n min={props.min ?? undefined}\n name={name}\n onChange={onChange}\n step={props.step ?? undefined}\n tabIndex={props.tabIndex ?? undefined}\n type=\"range\"\n value={value}\n />\n <output className=\"w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg\">\n {value}\n </output>\n </div>\n ) : (\n <Input\n autoFocus={props.autoFocus ?? false}\n disabled={disabled}\n id={name}\n max={props.max ?? undefined}\n min={props.min ?? undefined}\n name={name}\n onChange={onChange}\n placeholder={props.placeholder ?? \"\"}\n readOnly={readOnly}\n step={props.step ?? undefined}\n tabIndex={props.tabIndex ?? undefined}\n type=\"number\"\n value={value}\n />\n );\n }}\n </SimpleField>\n );\n};\n"],"mappings":";;;;AAIA,IAAa,wBAAgE,EAAE,WAAW;CACxF,MAAM,QAAQ,KAAK;CAEnB,OACE,oBAAC,aAAD;EAAmB;EAAM,OAAO,MAAM,SAAS;aAC3C,EAAE,MAAM,OAAO,UAAU,UAAU,aAAa;GAChD,MAAM,YAAY,UAChB,OAAO,MAAM,OAAO,KAAK;GAE3B,OAAO,MAAM,SACX,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,oBAAC,SAAD;KACE,cAAY,MAAM,SAAS;KAC3B,WAAU;KACV,UAAU,YAAY;KACtB,IAAI;KACJ,KAAK,MAAM,OAAO,KAAA;KAClB,KAAK,MAAM,OAAO,KAAA;KACZ;KACI;KACV,MAAM,MAAM,QAAQ,KAAA;KACpB,UAAU,MAAM,YAAY,KAAA;KAC5B,MAAK;KACE;IACR,CAAA,GACD,oBAAC,UAAD;KAAQ,WAAU;eACf;IACK,CAAA,CACL;QAEL,oBAAC,OAAD;IACE,WAAW,MAAM,aAAa;IACpB;IACV,IAAI;IACJ,KAAK,MAAM,OAAO,KAAA;IAClB,KAAK,MAAM,OAAO,KAAA;IACZ;IACI;IACV,aAAa,MAAM,eAAe;IACxB;IACV,MAAM,MAAM,QAAQ,KAAA;IACpB,UAAU,MAAM,YAAY,KAAA;IAC5B,MAAK;IACE;GACR,CAAA;EAEL;CACW,CAAA;AAEjB"}
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
import { RendererComponent } from '
|
|
2
|
-
import { FormLabelAction } from '../types';
|
|
3
|
-
type PasswordConfirmation = {
|
|
4
|
-
label?: string;
|
|
5
|
-
name?: string;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
};
|
|
8
|
-
declare module '../../../../../core/types' {
|
|
9
|
-
interface ComponentProps {
|
|
10
|
-
"form.password-input": {
|
|
11
|
-
autoComplete?: string;
|
|
12
|
-
autoFocus?: boolean;
|
|
13
|
-
conditions?: unknown;
|
|
14
|
-
confirmation?: PasswordConfirmation;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
hidden?: boolean;
|
|
17
|
-
label?: string;
|
|
18
|
-
labelAction?: FormLabelAction;
|
|
19
|
-
name?: string;
|
|
20
|
-
passwordRules?: string;
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
readonly?: boolean;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
tabIndex?: number;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import { RendererComponent } from '../../../core/types';
|
|
28
2
|
export declare const PasswordInputComponent: RendererComponent<"form.password-input">;
|
|
29
|
-
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getBooleanProp, getOptionalNumberProp, getStringProp } from "../../../core/props.js";
|
|
2
1
|
import { useFormContext } from "../context.js";
|
|
3
2
|
import { useDependentField } from "../use-dependent-field.js";
|
|
4
3
|
import { FormFieldFrame } from "../base/field.js";
|
|
@@ -6,24 +5,15 @@ import { useFieldCommit } from "../use-field-commit.js";
|
|
|
6
5
|
import PasswordInput from "../base/password-input.js";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
//#region resources/js/form/components/fields/password-input.tsx
|
|
9
|
-
function getPasswordConfirmation(props) {
|
|
10
|
-
const value = props?.confirmation;
|
|
11
|
-
if (typeof value !== "object" || value === null) return;
|
|
12
|
-
const confirmation = value;
|
|
13
|
-
return {
|
|
14
|
-
label: typeof confirmation.label === "string" ? confirmation.label : void 0,
|
|
15
|
-
name: typeof confirmation.name === "string" ? confirmation.name : void 0,
|
|
16
|
-
placeholder: typeof confirmation.placeholder === "string" ? confirmation.placeholder : void 0
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
8
|
var PasswordInputComponent = ({ node }) => {
|
|
9
|
+
const props = node.props;
|
|
20
10
|
const { errors } = useFormContext();
|
|
21
|
-
const { hidden, required,
|
|
11
|
+
const { hidden, required, readOnly, disabled } = useDependentField(node);
|
|
22
12
|
const { commit } = useFieldCommit();
|
|
23
|
-
const name =
|
|
24
|
-
const confirmation =
|
|
13
|
+
const name = props.name ?? "";
|
|
14
|
+
const confirmation = props.confirmation;
|
|
25
15
|
const confirmationName = confirmation?.name ?? `${name}_confirmation`;
|
|
26
|
-
const passwordRules =
|
|
16
|
+
const passwordRules = (props.passwordRules ?? "") || void 0;
|
|
27
17
|
if (hidden) return null;
|
|
28
18
|
const onChange = (field) => (event) => {
|
|
29
19
|
commit(field, event.target.value);
|
|
@@ -32,21 +22,22 @@ var PasswordInputComponent = ({ node }) => {
|
|
|
32
22
|
className: "grid gap-6",
|
|
33
23
|
children: [/* @__PURE__ */ jsx(FormFieldFrame, {
|
|
34
24
|
error: errors[name],
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
helperText: props.helperText ?? void 0,
|
|
26
|
+
label: props.label ?? "",
|
|
27
|
+
labelAction: props.labelAction ?? void 0,
|
|
37
28
|
name,
|
|
38
29
|
required,
|
|
39
30
|
children: /* @__PURE__ */ jsx(PasswordInput, {
|
|
40
|
-
autoComplete:
|
|
41
|
-
autoFocus:
|
|
31
|
+
autoComplete: props.autoComplete ?? "",
|
|
32
|
+
autoFocus: props.autoFocus ?? false,
|
|
42
33
|
disabled,
|
|
43
34
|
id: name,
|
|
44
35
|
name,
|
|
45
36
|
onChange: onChange(name),
|
|
46
|
-
placeholder:
|
|
37
|
+
placeholder: props.placeholder ?? "",
|
|
47
38
|
passwordrules: passwordRules,
|
|
48
|
-
readOnly
|
|
49
|
-
tabIndex:
|
|
39
|
+
readOnly,
|
|
40
|
+
tabIndex: props.tabIndex ?? void 0
|
|
50
41
|
})
|
|
51
42
|
}), confirmation && /* @__PURE__ */ jsx(FormFieldFrame, {
|
|
52
43
|
error: errors[confirmationName],
|
|
@@ -61,8 +52,8 @@ var PasswordInputComponent = ({ node }) => {
|
|
|
61
52
|
onChange: onChange(confirmationName),
|
|
62
53
|
placeholder: confirmation.placeholder ?? confirmation.label ?? "Confirm password",
|
|
63
54
|
passwordrules: passwordRules,
|
|
64
|
-
readOnly
|
|
65
|
-
tabIndex:
|
|
55
|
+
readOnly,
|
|
56
|
+
tabIndex: props.tabIndex ?? void 0
|
|
66
57
|
})
|
|
67
58
|
})]
|
|
68
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-input.js","names":[],"sources":["../../../../resources/js/form/components/fields/password-input.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"password-input.js","names":[],"sources":["../../../../resources/js/form/components/fields/password-input.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice/lattice/core/types\";\nimport { FormFieldFrame } from \"../base/field\";\nimport PasswordInput from \"../base/password-input\";\nimport { useDependentField } from \"../use-dependent-field\";\nimport { useFieldCommit } from \"../use-field-commit\";\nimport { useFormContext } from \"../context\";\n\nexport const PasswordInputComponent: RendererComponent<\"form.password-input\"> = ({ node }) => {\n const props = node.props;\n const { errors } = useFormContext();\n const { hidden, required, readOnly, disabled } = useDependentField(node);\n const { commit } = useFieldCommit();\n const name = props.name ?? \"\";\n const confirmation = props.confirmation;\n const confirmationName = confirmation?.name ?? `${name}_confirmation`;\n const passwordRules = (props.passwordRules ?? \"\") || undefined;\n\n if (hidden) {\n return null;\n }\n\n const onChange =\n (field: string) =>\n (event: React.ChangeEvent<HTMLInputElement>): void => {\n commit(field, event.target.value);\n };\n\n return (\n <div className=\"grid gap-6\">\n <FormFieldFrame\n error={errors[name]}\n helperText={props.helperText ?? undefined}\n label={props.label ?? \"\"}\n labelAction={props.labelAction ?? undefined}\n name={name}\n required={required}\n >\n <PasswordInput\n autoComplete={props.autoComplete ?? \"\"}\n autoFocus={props.autoFocus ?? false}\n disabled={disabled}\n id={name}\n name={name}\n onChange={onChange(name)}\n placeholder={props.placeholder ?? \"\"}\n passwordrules={passwordRules}\n readOnly={readOnly}\n tabIndex={props.tabIndex ?? undefined}\n />\n </FormFieldFrame>\n\n {confirmation && (\n <FormFieldFrame\n error={errors[confirmationName]}\n label={confirmation.label ?? \"Confirm password\"}\n name={confirmationName}\n required={required}\n >\n <PasswordInput\n autoComplete=\"new-password\"\n disabled={disabled}\n id={confirmationName}\n name={confirmationName}\n onChange={onChange(confirmationName)}\n placeholder={confirmation.placeholder ?? confirmation.label ?? \"Confirm password\"}\n passwordrules={passwordRules}\n readOnly={readOnly}\n tabIndex={props.tabIndex ?? undefined}\n />\n </FormFieldFrame>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAOA,IAAa,0BAAoE,EAAE,WAAW;CAC5F,MAAM,QAAQ,KAAK;CACnB,MAAM,EAAE,WAAW,eAAe;CAClC,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,kBAAkB,IAAI;CACvE,MAAM,EAAE,WAAW,eAAe;CAClC,MAAM,OAAO,MAAM,QAAQ;CAC3B,MAAM,eAAe,MAAM;CAC3B,MAAM,mBAAmB,cAAc,QAAQ,GAAG,KAAK;CACvD,MAAM,iBAAiB,MAAM,iBAAiB,OAAO,KAAA;CAErD,IAAI,QACF,OAAO;CAGT,MAAM,YACH,WACA,UAAqD;EACpD,OAAO,OAAO,MAAM,OAAO,KAAK;CAClC;CAEF,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,oBAAC,gBAAD;GACE,OAAO,OAAO;GACd,YAAY,MAAM,cAAc,KAAA;GAChC,OAAO,MAAM,SAAS;GACtB,aAAa,MAAM,eAAe,KAAA;GAC5B;GACI;aAEV,oBAAC,eAAD;IACE,cAAc,MAAM,gBAAgB;IACpC,WAAW,MAAM,aAAa;IACpB;IACV,IAAI;IACE;IACN,UAAU,SAAS,IAAI;IACvB,aAAa,MAAM,eAAe;IAClC,eAAe;IACL;IACV,UAAU,MAAM,YAAY,KAAA;GAC7B,CAAA;EACa,CAAA,GAEf,gBACC,oBAAC,gBAAD;GACE,OAAO,OAAO;GACd,OAAO,aAAa,SAAS;GAC7B,MAAM;GACI;aAEV,oBAAC,eAAD;IACE,cAAa;IACH;IACV,IAAI;IACJ,MAAM;IACN,UAAU,SAAS,gBAAgB;IACnC,aAAa,aAAa,eAAe,aAAa,SAAS;IAC/D,eAAe;IACL;IACV,UAAU,MAAM,YAAY,KAAA;GAC7B,CAAA;EACa,CAAA,CAEf;;AAET"}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import { RendererComponent } from '
|
|
2
|
-
declare module '../../../../../core/types' {
|
|
3
|
-
interface ComponentProps {
|
|
4
|
-
"form.rich-editor": {
|
|
5
|
-
conditions?: unknown;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
hidden?: boolean;
|
|
8
|
-
label?: string;
|
|
9
|
-
name?: string;
|
|
10
|
-
placeholder?: string;
|
|
11
|
-
readonly?: boolean;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
value?: unknown;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { RendererComponent } from '../../../core/types';
|
|
17
2
|
export declare const RichEditorComponent: RendererComponent<"form.rich-editor">;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Icon } from "../../../icons/sprite.js";
|
|
3
|
+
import { useT } from "../../../i18n/instance.js";
|
|
3
4
|
import { useFormContext } from "../context.js";
|
|
4
5
|
import { useFormValue } from "../values.js";
|
|
5
6
|
import { useDependentField } from "../use-dependent-field.js";
|
|
@@ -7,10 +8,9 @@ import { FormFieldFrame } from "../base/field.js";
|
|
|
7
8
|
import { useFieldCommit } from "../use-field-commit.js";
|
|
8
9
|
import { useEffect, useState } from "react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { AlignCenter, AlignJustify, AlignLeft, AlignRight, Bold, ChevronRight, Code, Columns3, Heading1, Heading2, Heading3, Highlighter, Italic, Link, List, ListOrdered, Minus, Quote, Rows3, Smile, Strikethrough, Table, Trash2, Underline } from "lucide-react";
|
|
11
11
|
import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details";
|
|
12
12
|
import { Highlight } from "@tiptap/extension-highlight";
|
|
13
|
-
import { Link
|
|
13
|
+
import { Link } from "@tiptap/extension-link";
|
|
14
14
|
import { TableKit } from "@tiptap/extension-table";
|
|
15
15
|
import { TextAlign } from "@tiptap/extension-text-align";
|
|
16
16
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
@@ -18,113 +18,113 @@ import { StarterKit } from "@tiptap/starter-kit";
|
|
|
18
18
|
//#region resources/js/form/components/fields/rich-editor.tsx
|
|
19
19
|
var toolbar = [
|
|
20
20
|
{
|
|
21
|
-
icon:
|
|
21
|
+
icon: "bold",
|
|
22
22
|
label: "Bold",
|
|
23
23
|
isActive: (e) => e.isActive("bold"),
|
|
24
24
|
run: (e) => e.chain().focus().toggleBold().run()
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
icon:
|
|
27
|
+
icon: "italic",
|
|
28
28
|
label: "Italic",
|
|
29
29
|
isActive: (e) => e.isActive("italic"),
|
|
30
30
|
run: (e) => e.chain().focus().toggleItalic().run()
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
icon:
|
|
33
|
+
icon: "strikethrough",
|
|
34
34
|
label: "Strikethrough",
|
|
35
35
|
isActive: (e) => e.isActive("strike"),
|
|
36
36
|
run: (e) => e.chain().focus().toggleStrike().run()
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
icon:
|
|
39
|
+
icon: "underline",
|
|
40
40
|
label: "Underline",
|
|
41
41
|
isActive: (e) => e.isActive("underline"),
|
|
42
42
|
run: (e) => e.chain().focus().toggleUnderline().run()
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
icon:
|
|
45
|
+
icon: "highlighter",
|
|
46
46
|
label: "Highlight",
|
|
47
47
|
isActive: (e) => e.isActive("highlight"),
|
|
48
48
|
run: (e) => e.chain().focus().toggleHighlight().run()
|
|
49
49
|
},
|
|
50
50
|
"separator",
|
|
51
51
|
{
|
|
52
|
-
icon:
|
|
52
|
+
icon: "heading-1",
|
|
53
53
|
label: "Heading 1",
|
|
54
54
|
isActive: (e) => e.isActive("heading", { level: 1 }),
|
|
55
55
|
run: (e) => e.chain().focus().toggleHeading({ level: 1 }).run()
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
|
-
icon:
|
|
58
|
+
icon: "heading-2",
|
|
59
59
|
label: "Heading 2",
|
|
60
60
|
isActive: (e) => e.isActive("heading", { level: 2 }),
|
|
61
61
|
run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run()
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
|
-
icon:
|
|
64
|
+
icon: "heading-3",
|
|
65
65
|
label: "Heading 3",
|
|
66
66
|
isActive: (e) => e.isActive("heading", { level: 3 }),
|
|
67
67
|
run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run()
|
|
68
68
|
},
|
|
69
69
|
"separator",
|
|
70
70
|
{
|
|
71
|
-
icon:
|
|
71
|
+
icon: "list",
|
|
72
72
|
label: "Bullet list",
|
|
73
73
|
isActive: (e) => e.isActive("bulletList"),
|
|
74
74
|
run: (e) => e.chain().focus().toggleBulletList().run()
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
|
-
icon:
|
|
77
|
+
icon: "list-ordered",
|
|
78
78
|
label: "Ordered list",
|
|
79
79
|
isActive: (e) => e.isActive("orderedList"),
|
|
80
80
|
run: (e) => e.chain().focus().toggleOrderedList().run()
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
|
-
icon:
|
|
83
|
+
icon: "quote",
|
|
84
84
|
label: "Blockquote",
|
|
85
85
|
isActive: (e) => e.isActive("blockquote"),
|
|
86
86
|
run: (e) => e.chain().focus().toggleBlockquote().run()
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
icon:
|
|
89
|
+
icon: "code",
|
|
90
90
|
label: "Code block",
|
|
91
91
|
isActive: (e) => e.isActive("codeBlock"),
|
|
92
92
|
run: (e) => e.chain().focus().toggleCodeBlock().run()
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
icon:
|
|
95
|
+
icon: "minus",
|
|
96
96
|
label: "Horizontal rule",
|
|
97
97
|
isActive: () => false,
|
|
98
98
|
run: (e) => e.chain().focus().setHorizontalRule().run()
|
|
99
99
|
},
|
|
100
100
|
"separator",
|
|
101
101
|
{
|
|
102
|
-
icon:
|
|
102
|
+
icon: "align-left",
|
|
103
103
|
label: "Align left",
|
|
104
104
|
isActive: (e) => e.isActive({ textAlign: "left" }),
|
|
105
105
|
run: (e) => e.chain().focus().setTextAlign("left").run()
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
|
-
icon:
|
|
108
|
+
icon: "align-center",
|
|
109
109
|
label: "Align center",
|
|
110
110
|
isActive: (e) => e.isActive({ textAlign: "center" }),
|
|
111
111
|
run: (e) => e.chain().focus().setTextAlign("center").run()
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
|
-
icon:
|
|
114
|
+
icon: "align-right",
|
|
115
115
|
label: "Align right",
|
|
116
116
|
isActive: (e) => e.isActive({ textAlign: "right" }),
|
|
117
117
|
run: (e) => e.chain().focus().setTextAlign("right").run()
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
|
-
icon:
|
|
120
|
+
icon: "align-justify",
|
|
121
121
|
label: "Justify",
|
|
122
122
|
isActive: (e) => e.isActive({ textAlign: "justify" }),
|
|
123
123
|
run: (e) => e.chain().focus().setTextAlign("justify").run()
|
|
124
124
|
},
|
|
125
125
|
"separator",
|
|
126
126
|
{
|
|
127
|
-
icon:
|
|
127
|
+
icon: "link",
|
|
128
128
|
label: "Link",
|
|
129
129
|
isActive: (e) => e.isActive("link"),
|
|
130
130
|
run: (e) => {
|
|
@@ -138,7 +138,7 @@ var toolbar = [
|
|
|
138
138
|
},
|
|
139
139
|
"separator",
|
|
140
140
|
{
|
|
141
|
-
icon:
|
|
141
|
+
icon: "table",
|
|
142
142
|
label: "Insert table",
|
|
143
143
|
isActive: (e) => e.isActive("table"),
|
|
144
144
|
run: (e) => e.chain().focus().insertTable({
|
|
@@ -148,28 +148,28 @@ var toolbar = [
|
|
|
148
148
|
}).run()
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
|
-
icon:
|
|
151
|
+
icon: "columns-3",
|
|
152
152
|
label: "Add column",
|
|
153
153
|
isActive: () => false,
|
|
154
154
|
isDisabled: (e) => !e.can().addColumnAfter(),
|
|
155
155
|
run: (e) => e.chain().focus().addColumnAfter().run()
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
icon:
|
|
158
|
+
icon: "rows-3",
|
|
159
159
|
label: "Add row",
|
|
160
160
|
isActive: () => false,
|
|
161
161
|
isDisabled: (e) => !e.can().addRowAfter(),
|
|
162
162
|
run: (e) => e.chain().focus().addRowAfter().run()
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
|
-
icon:
|
|
165
|
+
icon: "trash-2",
|
|
166
166
|
label: "Delete table",
|
|
167
167
|
isActive: () => false,
|
|
168
168
|
isDisabled: (e) => !e.can().deleteTable(),
|
|
169
169
|
run: (e) => e.chain().focus().deleteTable().run()
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
|
-
icon:
|
|
172
|
+
icon: "chevron-right",
|
|
173
173
|
label: "Details",
|
|
174
174
|
isActive: (e) => e.isActive("details"),
|
|
175
175
|
run: (e) => {
|
|
@@ -200,17 +200,19 @@ var emojis = [
|
|
|
200
200
|
"❤️"
|
|
201
201
|
];
|
|
202
202
|
function EmojiPicker({ editor }) {
|
|
203
|
+
const { t } = useT("lattice");
|
|
203
204
|
const [open, setOpen] = useState(false);
|
|
204
205
|
return /* @__PURE__ */ jsxs("div", {
|
|
205
206
|
className: "relative",
|
|
206
207
|
children: [/* @__PURE__ */ jsx("button", {
|
|
207
|
-
"aria-label": "Insert emoji",
|
|
208
|
-
|
|
208
|
+
"aria-label": t("editor.insert-emoji", "Insert emoji"),
|
|
209
|
+
"data-test": "editor-emoji",
|
|
210
|
+
className: "inline-flex size-7 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg [&_svg]:size-lt-icon-md",
|
|
209
211
|
onClick: () => setOpen((value) => !value),
|
|
210
212
|
onMouseDown: (event) => event.preventDefault(),
|
|
211
|
-
title: "Insert emoji",
|
|
213
|
+
title: t("editor.insert-emoji", "Insert emoji"),
|
|
212
214
|
type: "button",
|
|
213
|
-
children: /* @__PURE__ */ jsx(
|
|
215
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "smile" })
|
|
214
216
|
}), open && /* @__PURE__ */ jsx("div", {
|
|
215
217
|
className: "absolute z-10 mt-1 grid grid-cols-8 gap-0.5 rounded-lt-sm border border-lt-border bg-lt-bg p-1 shadow-md",
|
|
216
218
|
children: emojis.map((emoji) => /* @__PURE__ */ jsx("button", {
|
|
@@ -227,20 +229,27 @@ function EmojiPicker({ editor }) {
|
|
|
227
229
|
});
|
|
228
230
|
}
|
|
229
231
|
function Toolbar({ editor }) {
|
|
232
|
+
const { t } = useT("lattice");
|
|
230
233
|
return /* @__PURE__ */ jsxs("div", {
|
|
231
234
|
className: "flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1",
|
|
232
235
|
children: [
|
|
233
|
-
toolbar.map((item, index) =>
|
|
234
|
-
"
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
toolbar.map((item, index) => {
|
|
237
|
+
if (item === "separator") return /* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-lt-border" }, `sep-${index}`);
|
|
238
|
+
const key = item.label.toLowerCase().replace(/\s+/g, "-");
|
|
239
|
+
const label = t(`editor.${key}`, item.label);
|
|
240
|
+
return /* @__PURE__ */ jsx("button", {
|
|
241
|
+
"aria-label": label,
|
|
242
|
+
"aria-pressed": item.isActive(editor),
|
|
243
|
+
"data-test": `editor-${key}`,
|
|
244
|
+
className: cn("inline-flex size-7 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-lt-icon-md", item.isActive(editor) && "bg-lt-accent text-lt-accent-fg"),
|
|
245
|
+
disabled: item.isDisabled?.(editor) ?? false,
|
|
246
|
+
onClick: () => item.run(editor),
|
|
247
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
248
|
+
title: label,
|
|
249
|
+
type: "button",
|
|
250
|
+
children: /* @__PURE__ */ jsx(Icon, { name: item.icon })
|
|
251
|
+
}, item.label);
|
|
252
|
+
}),
|
|
244
253
|
/* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-lt-border" }),
|
|
245
254
|
/* @__PURE__ */ jsx(EmojiPicker, { editor })
|
|
246
255
|
]
|
|
@@ -248,18 +257,18 @@ function Toolbar({ editor }) {
|
|
|
248
257
|
}
|
|
249
258
|
var RichEditorComponent = ({ node }) => {
|
|
250
259
|
const { errors } = useFormContext();
|
|
251
|
-
const { hidden, required,
|
|
260
|
+
const { hidden, required, readOnly, disabled } = useDependentField(node);
|
|
252
261
|
const { change, blur } = useFieldCommit();
|
|
253
|
-
const name =
|
|
262
|
+
const name = node.props.name;
|
|
254
263
|
const storedValue = useFormValue(name);
|
|
255
|
-
const locked =
|
|
256
|
-
const initialContent = typeof storedValue === "object" && storedValue !== null ? storedValue : node.props
|
|
264
|
+
const locked = readOnly || disabled;
|
|
265
|
+
const initialContent = typeof storedValue === "object" && storedValue !== null ? storedValue : node.props.value ?? "";
|
|
257
266
|
const editor = useEditor({
|
|
258
267
|
extensions: [
|
|
259
268
|
StarterKit,
|
|
260
269
|
Highlight,
|
|
261
270
|
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
262
|
-
Link
|
|
271
|
+
Link.configure({ openOnClick: false }),
|
|
263
272
|
TableKit.configure({ table: { resizable: false } }),
|
|
264
273
|
Details,
|
|
265
274
|
DetailsSummary,
|
|
@@ -283,7 +292,8 @@ var RichEditorComponent = ({ node }) => {
|
|
|
283
292
|
const submittedValue = storedValue ? JSON.stringify(storedValue) : "";
|
|
284
293
|
return /* @__PURE__ */ jsxs(FormFieldFrame, {
|
|
285
294
|
error: errors[name],
|
|
286
|
-
|
|
295
|
+
helperText: node.props.helperText ?? void 0,
|
|
296
|
+
label: node.props.label ?? "",
|
|
287
297
|
name,
|
|
288
298
|
required,
|
|
289
299
|
children: [/* @__PURE__ */ jsxs("div", {
|