@viewkitjs/views 0.1.0 → 0.3.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/CHANGELOG.md +767 -1
- package/README.md +92 -41
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/Row.js +1 -1
- package/dist/atoms/RowMenu.d.ts +1 -1
- package/dist/atoms/RowMenu.js +20 -6
- package/dist/atoms/types.d.ts +4 -4
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +79 -8
- package/dist/contract.js +55 -8
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/format.d.ts +16 -1
- package/dist/display/format.js +10 -1
- package/dist/display/index.d.ts +2 -1
- package/dist/display/index.js +2 -1
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +12 -6
- package/dist/display/location.d.ts +4 -3
- package/dist/display/location.js +12 -5
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +8 -2
- package/dist/display/percent.js +10 -3
- package/dist/display/phone.d.ts +2 -1
- package/dist/display/phone.js +11 -2
- package/dist/display/relation.js +1 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +7 -3
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +28 -21
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +15 -10
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +7 -7
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +22 -6
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +5 -2
- package/dist/editors/ValueListEditor.js +11 -9
- package/dist/editors/edit-cores.d.ts +13 -10
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +7 -2
- package/dist/fields/binding.js +13 -6
- package/dist/fields/currency.d.ts +0 -10
- package/dist/fields/currency.js +0 -14
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +6 -0
- package/dist/fields/money.js +11 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/filters/filter-model.d.ts +0 -1
- package/dist/filters/registry.d.ts +3 -36
- package/dist/filters/registry.js +0 -38
- package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
- package/dist/grid/chrome/GridAddColumn.js +29 -0
- package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
- package/dist/grid/chrome/GridAggregateMenu.js +29 -0
- package/dist/grid/chrome/GridCellEditors.d.ts +71 -0
- package/dist/grid/chrome/GridCellEditors.js +126 -0
- package/dist/grid/chrome/GridCellOutline.d.ts +49 -0
- package/dist/grid/chrome/GridCellOutline.js +16 -0
- package/dist/grid/chrome/GridChipsEditor.d.ts +38 -0
- package/dist/grid/chrome/GridChipsEditor.js +35 -0
- package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
- package/dist/grid/chrome/GridColumnColorSection.js +40 -0
- package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
- package/dist/grid/chrome/GridColumnDateSection.js +23 -0
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
- package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
- package/dist/grid/chrome/GridColumnMenu.js +103 -0
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
- package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
- package/dist/grid/chrome/GridColumnSortSection.js +16 -0
- package/dist/grid/chrome/GridDateEditor.d.ts +34 -0
- package/dist/grid/chrome/GridDateEditor.js +19 -0
- package/dist/grid/chrome/GridFlyout.d.ts +44 -0
- package/dist/grid/chrome/GridFlyout.js +80 -0
- package/dist/grid/chrome/GridFooter.d.ts +33 -0
- package/dist/grid/chrome/GridFooter.js +85 -0
- package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
- package/dist/grid/chrome/GridGroupMenu.js +64 -0
- package/dist/grid/chrome/GridHeader.d.ts +66 -0
- package/dist/grid/chrome/GridHeader.js +42 -0
- package/dist/grid/chrome/GridLongTextEditor.d.ts +55 -0
- package/dist/grid/chrome/GridLongTextEditor.js +69 -0
- package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
- package/dist/grid/chrome/GridMenuRow.js +15 -0
- package/dist/grid/chrome/GridNameEditor.d.ts +24 -0
- package/dist/grid/chrome/GridNameEditor.js +21 -0
- package/dist/grid/chrome/GridNumberEditor.d.ts +49 -0
- package/dist/grid/chrome/GridNumberEditor.js +51 -0
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +30 -0
- package/dist/grid/chrome/GridRangeEditor.js +21 -0
- package/dist/grid/chrome/GridRelationEditor.d.ts +45 -0
- package/dist/grid/chrome/GridRelationEditor.js +92 -0
- package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
- package/dist/grid/chrome/GridResizeHandle.js +19 -0
- package/dist/grid/chrome/GridRow.d.ts +31 -0
- package/dist/grid/chrome/GridRow.js +179 -0
- package/dist/grid/chrome/GridRowActions.d.ts +32 -0
- package/dist/grid/chrome/GridRowActions.js +25 -0
- package/dist/grid/chrome/GridRowCells.d.ts +4 -0
- package/dist/grid/chrome/GridRowCells.js +128 -0
- package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
- package/dist/grid/chrome/GridRowGlyph.js +13 -0
- package/dist/grid/chrome/GridSelectEditor.d.ts +33 -0
- package/dist/grid/chrome/GridSelectEditor.js +43 -0
- package/dist/grid/chrome/GridStructure.d.ts +47 -0
- package/dist/grid/chrome/GridStructure.js +41 -0
- package/dist/grid/chrome/GridTable.d.ts +4 -0
- package/dist/grid/chrome/GridTable.js +192 -0
- package/dist/grid/chrome/GridTableSurface.d.ts +52 -0
- package/dist/grid/chrome/GridTableSurface.js +15 -0
- package/dist/grid/chrome/GridTextEditor.d.ts +45 -0
- package/dist/grid/chrome/GridTextEditor.js +38 -0
- package/dist/grid/chrome/GridValueListEditor.d.ts +30 -0
- package/dist/grid/chrome/GridValueListEditor.js +19 -0
- package/dist/grid/chrome/StuckMarker.d.ts +16 -0
- package/dist/grid/chrome/StuckMarker.js +34 -0
- package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
- package/dist/grid/chrome/cell-clipboard.js +28 -0
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.d.ts +21 -0
- package/dist/grid/chrome/cells.js +19 -0
- package/dist/grid/chrome/checks.d.ts +32 -0
- package/dist/grid/chrome/checks.js +32 -0
- package/dist/grid/chrome/column-glyph.d.ts +14 -0
- package/dist/grid/chrome/column-glyph.js +44 -0
- package/dist/grid/chrome/editors.d.ts +9 -0
- package/dist/grid/chrome/editors.js +10 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +53 -0
- package/dist/grid/chrome/grid-cell-classes.js +32 -0
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
- package/dist/grid/chrome/grid-menu-search.js +7 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +143 -0
- package/dist/grid/chrome/grid-row-props.js +1 -0
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +40 -0
- package/dist/grid/chrome/grid-styles.js +9 -0
- package/dist/grid/chrome/grid-table-props.d.ts +172 -0
- package/dist/grid/chrome/grid-table-props.js +1 -0
- package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
- package/dist/grid/chrome/useGridBatchApi.js +35 -0
- package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
- package/dist/grid/chrome/useGridColumnLayout.js +206 -0
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
- package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +64 -0
- package/dist/grid/chrome/useGridKeyboard.js +450 -0
- package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
- package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
- package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
- package/dist/grid/chrome/useGridRailReveal.js +67 -0
- package/dist/grid/chrome/useGridRangeActions.d.ts +51 -0
- package/dist/grid/chrome/useGridRangeActions.js +195 -0
- package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
- package/dist/grid/chrome/useGridRangeGestures.js +237 -0
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +37 -0
- package/dist/grid/chrome/useGridRowContextMenu.js +153 -0
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -0
- package/dist/grid/chrome/useGridScaleStyles.js +28 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +78 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +249 -0
- package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
- package/dist/grid/chrome/useGridTableSelection.js +55 -0
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
- package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
- package/dist/grid/core/clipboard-model.d.ts +83 -0
- package/dist/grid/core/clipboard-model.js +291 -0
- package/dist/grid/core/column-values.d.ts +27 -0
- package/dist/grid/core/column-values.js +76 -0
- package/dist/grid/core/commit-model.d.ts +41 -0
- package/dist/grid/core/commit-model.js +3 -0
- package/dist/grid/core/coordinates.d.ts +48 -0
- package/dist/grid/core/coordinates.js +27 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/edit-values.d.ts +9 -0
- package/dist/grid/core/edit-values.js +1 -0
- package/dist/grid/core/editing-controller.d.ts +60 -0
- package/dist/grid/core/editing-controller.js +266 -0
- package/dist/grid/core/editing-model.d.ts +87 -0
- package/dist/grid/core/editing-model.js +148 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/grid-scale.d.ts +14 -0
- package/dist/grid/core/grid-scale.js +8 -0
- package/dist/grid/core/nav.d.ts +94 -0
- package/dist/grid/core/nav.js +92 -0
- package/dist/grid/core/pending-reconciliation.d.ts +53 -0
- package/dist/grid/core/pending-reconciliation.js +51 -0
- package/dist/grid/core/range-model.d.ts +25 -0
- package/dist/grid/core/range-model.js +59 -0
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +101 -0
- package/dist/grid/core/spreadsheet-operations.js +280 -0
- package/dist/grid/core/useGridEditing.d.ts +46 -0
- package/dist/grid/core/useGridEditing.js +93 -0
- package/dist/grid/core/useGridRange.d.ts +20 -0
- package/dist/grid/core/useGridRange.js +24 -0
- package/dist/grid/core/value-equality.d.ts +54 -0
- package/dist/grid/core/value-equality.js +80 -0
- package/dist/grid/index.d.ts +18 -0
- package/dist/grid/index.js +5 -0
- package/dist/grid/useGridTablePrefs.d.ts +49 -0
- package/dist/grid/useGridTablePrefs.js +99 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/viewport.d.ts +3 -0
- package/dist/internal/viewport.js +15 -0
- package/dist/model/column-capabilities.d.ts +3 -2
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-state.d.ts +1 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/density.js +3 -3
- package/dist/model/filter-capabilities.d.ts +1 -1
- package/dist/model/filter-capabilities.js +1 -1
- package/dist/model/index.d.ts +4 -6
- package/dist/model/index.js +0 -1
- package/dist/model/preferences.d.ts +7 -7
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +6 -2
- package/dist/provider/ViewsProvider.js +12 -2
- package/dist/provider/components.d.ts +35 -9
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +8 -4
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/menu-groups.d.ts +8 -0
- package/dist/provider/menu-groups.js +38 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/provider/ports.d.ts +22 -0
- package/dist/provider/ports.js +1 -0
- package/dist/react.d.ts +3 -2
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +202 -72
- package/docs/getting-started.md +250 -0
- package/docs/guides/atoms.md +245 -0
- package/docs/guides/cells.md +302 -0
- package/docs/guides/columns.md +413 -0
- package/docs/guides/display.md +204 -0
- package/docs/guides/editors.md +462 -0
- package/docs/guides/ports.md +246 -0
- package/docs/guides/selection.md +270 -0
- package/docs/guides/the-grid.md +696 -0
- package/docs/guides/the-provider.md +448 -0
- package/docs/index.md +52 -0
- package/docs/install.md +9 -47
- package/docs/reference/cells.md +28 -0
- package/docs/reference/display.md +44 -0
- package/docs/reference/editors-chips.md +6 -0
- package/docs/reference/editors-date.md +6 -0
- package/docs/reference/editors-location.md +10 -0
- package/docs/reference/editors-name.md +6 -0
- package/docs/reference/editors-number.md +11 -0
- package/docs/reference/editors-open-values.md +10 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +6 -0
- package/docs/reference/editors-relation.md +12 -0
- package/docs/reference/editors-select.md +9 -0
- package/docs/reference/editors-session.md +11 -0
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +6 -0
- package/docs/reference/editors.md +5 -0
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +39 -0
- package/docs/reference/react.md +89 -0
- package/docs/reference/selection.md +33 -0
- package/docs/reference/views.md +622 -0
- package/package.json +27 -4
- package/skills/views/SKILL.md +20 -5
- package/dist/filters/types.d.ts +0 -27
- package/dist/filters/types.js +0 -1
- package/dist/model/filter-pushdown.d.ts +0 -106
- package/dist/model/filter-pushdown.js +0 -147
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../provider/context.js";
|
|
4
|
+
import { EndOfListSentinel, useRemotePage, } from "./relation-source.js";
|
|
5
|
+
export function RelationPanel({ candidates, query, onQueryChange, searchRef, onSearchKeyDown, before, drawsBefore = false, labels, hide, isChosen, onSelect, kindGlyph, message, creates, onCreate, startOn, }) {
|
|
6
|
+
const remote = candidates.kind === "remote";
|
|
7
|
+
const page = useRemotePage(candidates, query);
|
|
8
|
+
const rows = candidates.kind === "static" ? candidates.items : page.items;
|
|
9
|
+
const views = useViews();
|
|
10
|
+
const words = message ?? views.conventions.messages;
|
|
11
|
+
const { Command } = views.components;
|
|
12
|
+
const { List, Row, RowContent } = views.atoms;
|
|
13
|
+
const Add = views.icons.add;
|
|
14
|
+
const glyphs = kindGlyph != null || rows.some((candidate) => candidate.icon != null);
|
|
15
|
+
const glyph = (node) => node != null ? (_jsx("span", { className: "flex size-3.5 items-center justify-center [&>svg]:size-3.5", children: node })) : undefined;
|
|
16
|
+
const shown = hide ? rows.filter((candidate) => !hide(candidate.id)) : rows;
|
|
17
|
+
const status = !remote
|
|
18
|
+
? null
|
|
19
|
+
: page.failed && rows.length === 0
|
|
20
|
+
? words({ key: "editor.search-failed" })
|
|
21
|
+
: page.searching
|
|
22
|
+
? words({ key: "editor.searching" })
|
|
23
|
+
: rows.length === 0 && !page.loadingMore && !drawsBefore
|
|
24
|
+
? words({ key: "editor.nothing-matches" })
|
|
25
|
+
: null;
|
|
26
|
+
const moreStatus = !remote
|
|
27
|
+
? null
|
|
28
|
+
: page.loadingMore
|
|
29
|
+
? words({ key: "editor.loading-more" })
|
|
30
|
+
: page.failed && rows.length > 0
|
|
31
|
+
? words({ key: "editor.search-failed" })
|
|
32
|
+
: null;
|
|
33
|
+
const paging = remote && !page.exhausted && rows.length > 0;
|
|
34
|
+
return (_jsxs(Command.Root, { shouldFilter: !remote, defaultValue: startOn, filter: remote
|
|
35
|
+
? undefined
|
|
36
|
+
: (value, search) => {
|
|
37
|
+
const label = rows.find((candidate) => candidate.id === value)?.label ?? labels?.get(value) ?? "";
|
|
38
|
+
return label.toLowerCase().includes(search.toLowerCase()) ? 1 : 0;
|
|
39
|
+
}, children: [_jsx(Command.Input, { ref: searchRef, placeholder: words({ key: "editor.search" }), className: "h-9 text-[13px]", value: query, onValueChange: onQueryChange, onKeyDown: onSearchKeyDown }), _jsxs(Command.List, { className: "max-h-72 overscroll-contain scrollbar-overlay", children: [remote ? (status && (_jsx("div", { role: "status", className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: status }))) : (_jsx(Command.Empty, { className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: words({ key: "editor.nothing-matches" }) })), _jsx(Command.Group, { className: "p-0", children: _jsxs(List, { children: [before?.({ glyphs, glyph }), shown.map((candidate) => (_jsx(Command.Item, { value: candidate.id, onSelect: () => onSelect(candidate), chosen: isChosen(candidate.id), children: _jsx(RowContent, { size: "compact", leading: glyph(candidate.icon ?? kindGlyph), leadingLane: glyphs, label: candidate.label, description: candidate.sublabel, trailing: candidate.badge ? (_jsx("span", { className: "ml-2 shrink-0 rounded-sm border border-(color:--vk-border) px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-(color:--vk-fg-subtle)", children: candidate.badge })) : undefined, chosen: isChosen(candidate.id), chosenTint: false }) }, candidate.id)))] }) }), paging && _jsx(EndOfListSentinel, { onReveal: page.loadMore }), moreStatus && (_jsx("div", { role: "status", className: "py-3 text-center text-xs text-(color:--vk-fg-subtle)", children: moreStatus }))] }), creates && creates.length > 0 && (_jsx("div", { className: "border-t border-(color:--vk-border)", children: creates.map((create, index) => (_jsx(Row, { size: "compact", tone: "muted", leading: _jsx(Add, { className: "h-3.5 w-3.5 shrink-0" }), label: create.label(query.trim()), onClick: () => onCreate(create, query.trim()) }, index))) }))] }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FieldNote } from "../fields/write-target.js";
|
|
2
|
+
/**
|
|
3
|
+
* A VALUE'S NOTE — the sentence under a row's value that says why it is what
|
|
4
|
+
* it is. It wraps, because a reason is a sentence and the value column has the
|
|
5
|
+
* room.
|
|
6
|
+
*
|
|
7
|
+
* A note with a `quote` is a DISCLOSURE: a tap, a click or Enter opens the
|
|
8
|
+
* source beneath it in the app's fold, and the next one folds it away. One
|
|
9
|
+
* mechanism on every device — a hover tooltip would leave the phone without
|
|
10
|
+
* the quote. A note without one is plain text: nothing to open, no button.
|
|
11
|
+
*/
|
|
12
|
+
export declare function FieldNoteLine({ note }: {
|
|
13
|
+
note: FieldNote;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cx } from "../internal/cx.js";
|
|
5
|
+
import { useViews } from "../provider/context.js";
|
|
6
|
+
const NOTE_CLASS = "mt-0.5 text-xs leading-5 text-(color:--vk-fg-subtle) wrap-break-word";
|
|
7
|
+
export function FieldNoteLine({ note }) {
|
|
8
|
+
const { Collapse } = useViews().components;
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
10
|
+
if (!note.quote) {
|
|
11
|
+
return (_jsx("p", { "data-field-note": true, className: NOTE_CLASS, children: note.text }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsxs("div", { children: [_jsx("button", { type: "button", "data-field-note": true, "aria-expanded": open, onClick: () => setOpen((value) => !value), className: cx(NOTE_CLASS, "block text-left underline decoration-dotted underline-offset-2 transition-colors hover:text-(color:--vk-fg)"), children: note.text }), _jsx(Collapse, { open: open, children: _jsxs("p", { className: "mt-1 border-l-2 border-(color:--vk-border) pl-2 text-xs leading-5 text-(color:--vk-fg-subtle) italic wrap-break-word", children: ["\u201C", note.quote, "\u201D"] }) })] }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { DisplayOptions } from "../display/options.js";
|
|
3
|
+
import type { FieldBinding } from "../fields/binding.js";
|
|
4
|
+
import type { FieldRowMenuItem } from "../fields/menus.js";
|
|
5
|
+
import { type FieldNote, type FieldWriteAdmission } from "../fields/write-target.js";
|
|
6
|
+
export type FieldRowProps<Row> = {
|
|
7
|
+
binding: FieldBinding<Row>;
|
|
8
|
+
row: Row;
|
|
9
|
+
/** The DISPLAY value — `binding.read(row)`, or the panel's own override. */
|
|
10
|
+
value: unknown;
|
|
11
|
+
/** The STORED value the editor opens on — `binding.editRead?.(row) ?? value`. */
|
|
12
|
+
editValue: unknown;
|
|
13
|
+
writable: boolean;
|
|
14
|
+
/** Disables mutation gestures without drawing a temporary permission lock. */
|
|
15
|
+
ready?: boolean;
|
|
16
|
+
/** The row this value comes from does not hold it yet: a record painted from a list's row whose own read is
|
|
17
|
+
* on its way. Drawn blank, never as empty; the row keeps its label, lock and disabled target. */
|
|
18
|
+
unread?: boolean;
|
|
19
|
+
/** Why this row is read-only HERE, when it is — drawn as a lock. */
|
|
20
|
+
refusal?: string;
|
|
21
|
+
/** Synchronously admits/refuses the draft, then settles an accepted write. */
|
|
22
|
+
onCommit: (commit: unknown) => FieldWriteAdmission<Row>;
|
|
23
|
+
opts?: DisplayOptions;
|
|
24
|
+
/** The verbs this row offers INSTEAD of an editor (see `FieldMenus`). Present,
|
|
25
|
+
* the row is a menu trigger whatever `writable` says — a verb is not a write,
|
|
26
|
+
* and the lock that would otherwise sit here is what the menu answers. */
|
|
27
|
+
menu?: readonly FieldRowMenuItem[];
|
|
28
|
+
/** A trailing note in the value's own line — the stage a won deal froze at. */
|
|
29
|
+
meta?: ReactNode;
|
|
30
|
+
/** A sentence that explains the value — drawn under it, wrapping. */
|
|
31
|
+
note?: string | FieldNote | null;
|
|
32
|
+
/** The app's own icon name for a record kind (`AppIcon`'s name), or undefined: the glyph a
|
|
33
|
+
* relation's candidates wear in its editor. Unanswered, they wear the field type's glyph. */
|
|
34
|
+
kindIcon?: (kind: string) => string | undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* THE FIELD ROW — the third host of the shared field cores (docs/guides/editors.md), after
|
|
38
|
+
* the grid cell and the form field: one field of a record, in its panel or page.
|
|
39
|
+
*
|
|
40
|
+
* It draws a label and the field's DISPLAY core, and on click swaps the value
|
|
41
|
+
* for that type's editor in place. It never moves focus in the page behind it,
|
|
42
|
+
* never fetches, and never knows which entity it is drawing: everything it can
|
|
43
|
+
* do arrives as a binding, a value and one `onCommit`.
|
|
44
|
+
*
|
|
45
|
+
* Every editor opens through `EditorPanel` and one row session: a picker as a
|
|
46
|
+
* popover under the value on a desktop and in the sheet on a phone, a typed
|
|
47
|
+
* value in its own box on every width.
|
|
48
|
+
*
|
|
49
|
+
* The frame is glyph · `w-32` label · value, so the rows of a section, and any
|
|
50
|
+
* hand-written row an app draws on the same frame, line up down one column.
|
|
51
|
+
* Under the value it may draw a NOTE — the sentence that explains it — outside
|
|
52
|
+
* the click target, so the value stays the thing a click edits.
|
|
53
|
+
*/
|
|
54
|
+
declare function FieldRowImpl<Row>({ binding, row, value, editValue, writable, ready, unread, refusal, onCommit, opts, menu, meta, note, kindIcon, }: FieldRowProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Memoized — with an honest account of what that buys, which is less than it
|
|
57
|
+
* looks. `editing` and `pending` are the row's OWN state, so one row writing
|
|
58
|
+
* never re-renders its twenty siblings; the memo can only pay when the HOST
|
|
59
|
+
* re-renders, and then only for rows whose every prop compares equal.
|
|
60
|
+
*
|
|
61
|
+
* From a panel that builds `onCommit` as an inline closure
|
|
62
|
+
* per render, none do, and a list-valued `read` hands over a fresh array besides — so
|
|
63
|
+
* the comparison never succeeds from such a host, and this is one shallow compare
|
|
64
|
+
* that always falls through. It is kept because it costs that and nothing more,
|
|
65
|
+
* and because a host that does hold its callbacks stable gets the win without
|
|
66
|
+
* the row changing — not because any host provides that stability. Making the
|
|
67
|
+
* panel provide it means per-key memoised callbacks, i.e. a change to the row's
|
|
68
|
+
* contract for a residual too narrow to be worth it.
|
|
69
|
+
*
|
|
70
|
+
* The cast restores the generic that `memo` erases.
|
|
71
|
+
*/
|
|
72
|
+
export declare const FieldRow: typeof FieldRowImpl;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { optimisticDisplay, phoneText, presentedDef, resolveFieldMessage, } from "@viewkitjs/fields";
|
|
5
|
+
import { ConvertedFigure } from "../display/converted.js";
|
|
6
|
+
import { renderFieldValue } from "../display/display-cores.js";
|
|
7
|
+
import { cx } from "../internal/cx.js";
|
|
8
|
+
import { useViews } from "../provider/context.js";
|
|
9
|
+
import { RowEditor } from "./editors/RowEditor.js";
|
|
10
|
+
import { FieldNoteLine } from "./FieldNoteLine.js";
|
|
11
|
+
import { FieldRowLane } from "./FieldRowLane.js";
|
|
12
|
+
import { FieldWriteReconciliationRequired, } from "../fields/write-target.js";
|
|
13
|
+
import { OpenValueAction, isOpenableType } from "../editors/open-value.js";
|
|
14
|
+
import { FIELD_ROW_TARGET as TARGET, FIELD_ROW_TARGET_BESIDE as TARGET_BESIDE, FIELD_ROW_TARGET_UNDER as TARGET_UNDER, } from "./row-target.js";
|
|
15
|
+
import { settlementAttributes, useRowSettlement } from "./useRowSettlement.js";
|
|
16
|
+
function FieldRowImpl({ binding, row, value, editValue, writable, ready = true, unread = false, refusal, onCommit, opts, menu, meta, note, kindIcon, }) {
|
|
17
|
+
const { field } = binding;
|
|
18
|
+
const { atoms, components, conventions, icons } = useViews();
|
|
19
|
+
const { CommandMenu } = atoms;
|
|
20
|
+
const { AppIcon } = components;
|
|
21
|
+
const [editing, setEditing] = useState(false);
|
|
22
|
+
const [pending, setPending] = useState(null);
|
|
23
|
+
const [error, setError] = useState(null);
|
|
24
|
+
const [retryDraft, setRetryDraft] = useState(null);
|
|
25
|
+
const settlement = useRowSettlement(row);
|
|
26
|
+
const message = opts?.presentation?.message ?? resolveFieldMessage;
|
|
27
|
+
const buttonRef = useRef(null);
|
|
28
|
+
const focusBack = useRef(null);
|
|
29
|
+
const closed = (after) => {
|
|
30
|
+
focusBack.current = after.focusBack ? {} : null;
|
|
31
|
+
setEditing(false);
|
|
32
|
+
};
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const armed = focusBack.current;
|
|
35
|
+
if (!armed || editing)
|
|
36
|
+
return;
|
|
37
|
+
const button = buttonRef.current;
|
|
38
|
+
if (!button) {
|
|
39
|
+
focusBack.current = null;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (button.disabled) {
|
|
43
|
+
if (!("left" in armed))
|
|
44
|
+
armed.left = document.activeElement;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
focusBack.current = null;
|
|
48
|
+
const active = document.activeElement;
|
|
49
|
+
const moved = "left" in armed && active !== armed.left && active !== null && active !== document.body;
|
|
50
|
+
if (!moved)
|
|
51
|
+
button.focus({ preventScroll: true });
|
|
52
|
+
}, [editing, pending, ready]);
|
|
53
|
+
const shown = pending && "optimistic" in pending ? pending.optimistic : value;
|
|
54
|
+
const isEmpty = shown == null || shown === "" || (Array.isArray(shown) && shown.length === 0);
|
|
55
|
+
const attempt = (resolution) => {
|
|
56
|
+
if (resolution.kind !== "commit")
|
|
57
|
+
return { accepted: true };
|
|
58
|
+
if (!ready)
|
|
59
|
+
return { accepted: false, reason: "Wait for current data before editing" };
|
|
60
|
+
if (pending)
|
|
61
|
+
return { accepted: false, reason: message({ key: "field.already-saving" }) };
|
|
62
|
+
const admission = onCommit(resolution.payload);
|
|
63
|
+
if (!admission.accepted)
|
|
64
|
+
return admission;
|
|
65
|
+
const optimistic = optimisticDisplay(field, resolution.payload);
|
|
66
|
+
setError(null);
|
|
67
|
+
setRetryDraft(null);
|
|
68
|
+
setPending(optimistic === undefined ? {} : { optimistic });
|
|
69
|
+
void admission.completion.then((receipt) => {
|
|
70
|
+
setPending(null);
|
|
71
|
+
setRetryDraft(null);
|
|
72
|
+
setError(null);
|
|
73
|
+
settlement.settle(receipt);
|
|
74
|
+
}, (failure) => {
|
|
75
|
+
setPending(null);
|
|
76
|
+
setRetryDraft({ commit: resolution.payload });
|
|
77
|
+
setError(failure instanceof FieldWriteReconciliationRequired
|
|
78
|
+
? failure.warning
|
|
79
|
+
: failure instanceof Error && failure.name === "FieldWriteRefusal"
|
|
80
|
+
? failure.message
|
|
81
|
+
: message({ key: "field.retry-save" }));
|
|
82
|
+
});
|
|
83
|
+
return { accepted: true };
|
|
84
|
+
};
|
|
85
|
+
const shownDef = presentedDef(field);
|
|
86
|
+
const fieldOwnsCurrency = shownDef.type === "currency" && "fixed" in shownDef.code;
|
|
87
|
+
const hasMenu = !!menu && menu.length > 0 && field.edit?.mutability === "command";
|
|
88
|
+
const verbsInLane = hasMenu && (field.type === "url" || field.type === "relation");
|
|
89
|
+
const valueInButton = !unread && ((writable && shownDef.type !== "boolean" && !hasMenu) || (hasMenu && !verbsInLane));
|
|
90
|
+
const singleLink = !(Array.isArray(shown) && shown.length > 1) &&
|
|
91
|
+
(shownDef.type === "url" ||
|
|
92
|
+
shownDef.type === "email" ||
|
|
93
|
+
shownDef.type === "phone" ||
|
|
94
|
+
shownDef.type === "domain");
|
|
95
|
+
const base = {
|
|
96
|
+
wrap: (shownDef.type === "text" && shownDef.format?.long) ||
|
|
97
|
+
shownDef.type === "rich_text" ||
|
|
98
|
+
shownDef.type === "location"
|
|
99
|
+
? "full"
|
|
100
|
+
: true,
|
|
101
|
+
...opts,
|
|
102
|
+
currency: opts?.currency ?? (fieldOwnsCurrency || unread ? undefined : binding.unit?.read(row)),
|
|
103
|
+
...(valueInButton ? { slotOwnsClick: true } : {}),
|
|
104
|
+
};
|
|
105
|
+
const editsInPlace = writable && shownDef.type !== "boolean" && !hasMenu && !unread && !isEmpty;
|
|
106
|
+
const openType = editsInPlace && singleLink && isOpenableType(shownDef.type) ? shownDef.type : null;
|
|
107
|
+
const openOne = Array.isArray(shown) ? shown[0] : shown;
|
|
108
|
+
const openValue = openOne && typeof openOne === "object" && "value" in openOne ? openOne.value : openOne;
|
|
109
|
+
const openLabel = shownDef.type === "phone" ? phoneText(openValue, binding.region?.(row) ?? null) : String(openValue ?? "");
|
|
110
|
+
const valueOverButton = editsInPlace && shownDef.type === "rich_text" && base.wrap === "full";
|
|
111
|
+
const displayOpts = shownDef.type === "boolean" && writable
|
|
112
|
+
? {
|
|
113
|
+
...base,
|
|
114
|
+
onToggle: (next) => attempt({ kind: "commit", payload: next }),
|
|
115
|
+
booleanDisabled: !ready || !!pending,
|
|
116
|
+
onResolve: !ready || pending ? undefined : () => attempt({ kind: "commit", payload: false }),
|
|
117
|
+
}
|
|
118
|
+
:
|
|
119
|
+
valueOverButton
|
|
120
|
+
? { ...base, slotOwnsClick: false }
|
|
121
|
+
: base;
|
|
122
|
+
const rowCurrency = unread || fieldOwnsCurrency ? undefined : binding.unit?.read(row);
|
|
123
|
+
const convertedFrom = shownDef.type === "currency" &&
|
|
124
|
+
typeof shown === "number" &&
|
|
125
|
+
!!opts?.currency &&
|
|
126
|
+
!!rowCurrency &&
|
|
127
|
+
opts.currency !== rowCurrency
|
|
128
|
+
? rowCurrency
|
|
129
|
+
: null;
|
|
130
|
+
const drawn = () => {
|
|
131
|
+
const value = renderFieldValue(field, shown, displayOpts);
|
|
132
|
+
return convertedFrom ? _jsx(ConvertedFigure, { from: convertedFrom, children: value }) : value;
|
|
133
|
+
};
|
|
134
|
+
const body = unread ? null : isEmpty ? (shownDef.type === "boolean" ? (renderFieldValue(field, shown, displayOpts)) : writable ? null : (_jsx("span", { className: "text-(color:--vk-fg-subtle)", children: "\u2014" }))) : (drawn());
|
|
135
|
+
const TypeGlyph = icons[field.type];
|
|
136
|
+
const glyph = binding.icon ? (_jsx(AppIcon, { name: binding.icon, className: "h-3.5 w-3.5 text-(color:--vk-fg-subtlest)" })) : (_jsx(TypeGlyph, { className: "h-3.5 w-3.5 text-(color:--vk-fg-subtlest)" }));
|
|
137
|
+
const menuItems = (menu ?? []).map((item) => ({
|
|
138
|
+
...item,
|
|
139
|
+
disabled: !ready || item.disabled,
|
|
140
|
+
onClick: () => {
|
|
141
|
+
if (ready)
|
|
142
|
+
item.onClick();
|
|
143
|
+
},
|
|
144
|
+
}));
|
|
145
|
+
const valueNode = (_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { className: "min-w-0 wrap-break-word", children: body }), meta ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: meta }) : null] }));
|
|
146
|
+
const editButton = (className, children) => (_jsx("button", { ref: buttonRef, type: "button", "aria-label": field.label, disabled: !ready || !!pending, onClick: () => {
|
|
147
|
+
setError(null);
|
|
148
|
+
setEditing(true);
|
|
149
|
+
}, className: className, children: children }));
|
|
150
|
+
return (_jsxs("div", { className: "flex items-start gap-3 border-b border-(color:--vk-border) py-2.5 last:border-0", "aria-busy": pending ? "true" : undefined, children: [_jsx("span", { className: "flex h-5 w-3.5 shrink-0 items-center justify-center", children: glyph }), _jsx("span", { className: "w-32 shrink-0 text-sm leading-5 text-(color:--vk-fg-subtle)", children: field.label }), _jsxs("div", { className: cx("min-w-0 flex-1 text-sm leading-5 text-(color:--vk-fg)", settlement.requested && "italic opacity-80"), ...settlementAttributes(settlement.requested, field.provenance, conventions), children: [editing ? (_jsx("div", { children: _jsx(RowEditor, { binding: binding, row: row, initial: retryDraft ? retryDraft.commit : editValue, shown: shown, conversion: convertedFrom ? body : undefined, anchor: _jsx("span", { className: cx(TARGET, "bg-(color:--vk-neutral)"), children: valueNode }), onAttempt: attempt, onClose: closed, message: message, kindIcon: kindIcon }) })) : hasMenu && !verbsInLane ? (_jsx(CommandMenu, { trigger: _jsx("button", { type: "button", "aria-label": field.label, className: TARGET, disabled: !ready, children: valueNode }), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton ? (_jsxs("div", { className: "relative min-w-0", children: [editButton(cx(TARGET_UNDER, "disabled:pointer-events-none")), _jsx("span", { "data-slot": "vk-row-value-layer", className: cx("pointer-events-none relative block min-w-0 [&_a]:pointer-events-auto [&_button]:pointer-events-auto", pending && "opacity-70"), children: valueNode })] })) : openType ? (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [editButton(cx(TARGET_BESIDE, "disabled:pointer-events-none", pending && "opacity-70"), valueNode), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton(cx(TARGET, "disabled:pointer-events-none", pending && "opacity-70"), valueNode))) : (_jsx("span", { className: "block min-w-0", children: valueNode })), !editing && note ? (_jsx(FieldNoteLine, { note: typeof note === "string" ? { text: note } : note })) : null, !editing && error && retryDraft ? (_jsx("div", { role: "alert", className: "mt-1 text-xs text-(color:--vk-danger)", children: _jsx("button", { type: "button", onClick: () => {
|
|
151
|
+
setError(null);
|
|
152
|
+
const retried = attempt({ kind: "commit", payload: retryDraft.commit });
|
|
153
|
+
if (!retried.accepted)
|
|
154
|
+
setError(retried.reason);
|
|
155
|
+
}, className: "hover:underline", children: error }) })) : null] }), _jsx(FieldRowLane, { label: field.label, verbsInLane: verbsInLane, hasMenu: hasMenu, items: menuItems, ready: ready, writable: writable, refusal: refusal })] }));
|
|
156
|
+
}
|
|
157
|
+
export const FieldRow = memo(FieldRowImpl);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FieldRowMenuItem } from "../fields/menus.js";
|
|
2
|
+
/**
|
|
3
|
+
* A FIELD ROW'S TRAILING LANE — the mark at the row's right edge that says how
|
|
4
|
+
* its value changes: the verb menu, when the value is itself a control (a URL,
|
|
5
|
+
* a relation) and so cannot be the menu's trigger; the ellipsis, when the value
|
|
6
|
+
* IS the trigger; or the lock with its reason, when the row is read-only. It is
|
|
7
|
+
* always drawn, at one width, so every value in the section ends on the same
|
|
8
|
+
* edge whether or not its row has a mark.
|
|
9
|
+
*/
|
|
10
|
+
export declare function FieldRowLane({ label, verbsInLane, hasMenu, items, ready, writable, refusal, }: {
|
|
11
|
+
/** The FIELD's label — what the verb trigger announces. */
|
|
12
|
+
label: string;
|
|
13
|
+
verbsInLane: boolean;
|
|
14
|
+
hasMenu: boolean;
|
|
15
|
+
items: FieldRowMenuItem[];
|
|
16
|
+
ready: boolean;
|
|
17
|
+
writable: boolean;
|
|
18
|
+
refusal?: string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../provider/context.js";
|
|
4
|
+
export function FieldRowLane({ label, verbsInLane, hasMenu, items, ready, writable, refusal, }) {
|
|
5
|
+
const { atoms, icons } = useViews();
|
|
6
|
+
const { CommandMenu } = atoms;
|
|
7
|
+
const Chevron = icons.chevronDown;
|
|
8
|
+
const More = icons.more;
|
|
9
|
+
const Lock = icons.lock;
|
|
10
|
+
return (_jsx("span", { className: "flex h-5 w-3 shrink-0 items-center justify-center", children: verbsInLane ? (_jsx(CommandMenu, { trigger: _jsx("button", { type: "button", "aria-label": label, className: "group -m-1 p-1", disabled: !ready, children: _jsx(Chevron, { className: "h-3 w-3 text-(color:--vk-fg-subtlest) transition-colors group-hover:text-(color:--vk-fg-subtle)" }) }), items: items, align: "end" })) : hasMenu ? (_jsx(More, { className: "h-3 w-3 text-(color:--vk-fg-subtlest)" })) : !writable && refusal ? (_jsx("span", { title: refusal, className: "leading-none", children: _jsx(Lock, { className: "h-3 w-3 text-(color:--vk-fg-subtlest)" }) })) : null }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type RowHostProps } from "./host.js";
|
|
2
|
+
/**
|
|
3
|
+
* The FIELD ROW's host around the shared `ChipsEditor` — the set is edited as
|
|
4
|
+
* a draft in the panel and commits ONCE, as one array: a popover on a desktop,
|
|
5
|
+
* the sheet on a phone (`EditorPanel`).
|
|
6
|
+
*
|
|
7
|
+
* For a set an outside click and Escape mean OPPOSITE things: an outside click
|
|
8
|
+
* keeps what you built, Escape discards the session. That rule is the core's
|
|
9
|
+
* and the panel's; this host only hands the reasons through.
|
|
10
|
+
*/
|
|
11
|
+
export declare function RowChipsEditor<Row>({ field, initial, anchor, onAttempt, onClose, message, }: RowHostProps<Row, "multiselect">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { normalizerFor, optionFor } from "@viewkitjs/fields";
|
|
5
|
+
import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
6
|
+
import { ChipsEditor } from "../../editors/ChipsEditor.js";
|
|
7
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
8
|
+
import { offeredValues, takesNewValues, useOpenValues } from "../../editors/open-values.js";
|
|
9
|
+
import { OPTION_ROW_INSET } from "./host.js";
|
|
10
|
+
import { useRowEditSession } from "./row-session.js";
|
|
11
|
+
export function RowChipsEditor({ field, initial, anchor, onAttempt, onClose, message, }) {
|
|
12
|
+
const editorRef = useRef(null);
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
15
|
+
const known = useOpenValues(field);
|
|
16
|
+
const values = Array.isArray(initial)
|
|
17
|
+
? initial.filter((v) => typeof v === "string")
|
|
18
|
+
: [];
|
|
19
|
+
const resolve = (value) => ({
|
|
20
|
+
value,
|
|
21
|
+
label: optionFor(field, value)?.label ?? value,
|
|
22
|
+
color: resolveCategoryColor(value, field.options, undefined),
|
|
23
|
+
});
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset: -OPTION_ROW_INSET, sideOffset: 4, initialFocus: false, chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offeredValues(field, known), resolve: resolve, normalize: normalizerFor(field), creatable: takesNewValues(field), onRequestClose: close, message: message }) })] }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RowHostProps } from "./host.js";
|
|
2
|
+
/**
|
|
3
|
+
* The FIELD ROW's host around the shared `DateEditor` — the same calendar the
|
|
4
|
+
* grid cell and the form field open: a popover on a desktop, the sheet on a
|
|
5
|
+
* phone (`EditorPanel`).
|
|
6
|
+
*
|
|
7
|
+
* TWO field types, one panel. They differ in what the row HOLDS, so they differ
|
|
8
|
+
* only in what this host does with the answer: a `date` is a calendar day, so
|
|
9
|
+
* the time the panel may have collected is trimmed off the payload and the chip
|
|
10
|
+
* starts empty (`timeOptional`); a `datetime` is an instant, so the commit
|
|
11
|
+
* always carries one — the grid's mode, preserved.
|
|
12
|
+
*
|
|
13
|
+
* A date's close rule is the core's: Escape discards; every other close commits
|
|
14
|
+
* the draft when it is dirty, and is nothing otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare function RowDateEditor<Row>({ field, initial, anchor, onAttempt, onClose, message, }: RowHostProps<Row, "date" | "datetime">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { DateEditor } from "../../editors/DateEditor.js";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { useRowEditSession } from "./row-session.js";
|
|
7
|
+
export function RowDateEditor({ field, initial, anchor, onAttempt, onClose, message, }) {
|
|
8
|
+
const editorRef = useRef(null);
|
|
9
|
+
const anchorRef = useRef(null);
|
|
10
|
+
const dayOnly = field.type === "date";
|
|
11
|
+
const { session, close } = useRowEditSession({
|
|
12
|
+
editorRef,
|
|
13
|
+
onAttempt,
|
|
14
|
+
onClose,
|
|
15
|
+
mapPayload: (payload) => (payload === "" ? null : dayOnly ? payload.slice(0, 10) : payload),
|
|
16
|
+
});
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, chrome: "menu", className: "z-90 w-auto", children: (surface) => (_jsx(DateEditor, { ref: editorRef, initial: typeof initial === "string" && initial !== "" ? initial : undefined, timeOptional: dayOnly, dayOnly: dayOnly, clearable: !!field.nullable, fill: surface === "sheet", onRequestClose: close, message: message })) })] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RowEditorProps } from "./host.js";
|
|
3
|
+
import { RowChipsEditor } from "./RowChipsEditor.js";
|
|
4
|
+
import { RowDateEditor } from "./RowDateEditor.js";
|
|
5
|
+
import { RowNameEditor } from "./RowNameEditor.js";
|
|
6
|
+
import { RowNumberEditor } from "./RowNumberEditor.js";
|
|
7
|
+
import { RowPlaceEditor } from "./RowPlaceEditor.js";
|
|
8
|
+
import { RowRangeEditor } from "./RowRangeEditor.js";
|
|
9
|
+
import { RowRelationEditor } from "./RowRelationEditor.js";
|
|
10
|
+
import { RowSelectEditor } from "./RowSelectEditor.js";
|
|
11
|
+
import { RowTextEditor } from "./RowTextEditor.js";
|
|
12
|
+
import { RowListOrText } from "./RowValueListEditor.js";
|
|
13
|
+
export declare const ROW_HOSTS: {
|
|
14
|
+
select: typeof RowSelectEditor;
|
|
15
|
+
status: typeof RowSelectEditor;
|
|
16
|
+
relation: typeof RowRelationEditor;
|
|
17
|
+
user: typeof RowRelationEditor;
|
|
18
|
+
date: typeof RowDateEditor;
|
|
19
|
+
datetime: typeof RowDateEditor;
|
|
20
|
+
multiselect: typeof RowChipsEditor;
|
|
21
|
+
number: typeof RowNumberEditor;
|
|
22
|
+
percent: typeof RowNumberEditor;
|
|
23
|
+
currency: typeof RowNumberEditor;
|
|
24
|
+
range: typeof RowRangeEditor;
|
|
25
|
+
name: typeof RowNameEditor;
|
|
26
|
+
text: typeof RowTextEditor;
|
|
27
|
+
url: typeof RowListOrText;
|
|
28
|
+
domain: typeof RowListOrText;
|
|
29
|
+
phone: typeof RowListOrText;
|
|
30
|
+
rich_text: typeof RowTextEditor;
|
|
31
|
+
email: typeof RowListOrText;
|
|
32
|
+
boolean: null;
|
|
33
|
+
location: typeof RowPlaceEditor;
|
|
34
|
+
actor: null;
|
|
35
|
+
lookup: null;
|
|
36
|
+
rollup: null;
|
|
37
|
+
formula: null;
|
|
38
|
+
};
|
|
39
|
+
export declare function RowEditor<Row>(props: RowEditorProps<Row>): ReactNode;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { RowChipsEditor } from "./RowChipsEditor.js";
|
|
4
|
+
import { RowDateEditor } from "./RowDateEditor.js";
|
|
5
|
+
import { RowNameEditor } from "./RowNameEditor.js";
|
|
6
|
+
import { RowNumberEditor } from "./RowNumberEditor.js";
|
|
7
|
+
import { RowPlaceEditor } from "./RowPlaceEditor.js";
|
|
8
|
+
import { RowRangeEditor } from "./RowRangeEditor.js";
|
|
9
|
+
import { RowRelationEditor } from "./RowRelationEditor.js";
|
|
10
|
+
import { RowSelectEditor } from "./RowSelectEditor.js";
|
|
11
|
+
import { RowTextEditor } from "./RowTextEditor.js";
|
|
12
|
+
import { RowListOrText } from "./RowValueListEditor.js";
|
|
13
|
+
export const ROW_HOSTS = {
|
|
14
|
+
select: RowSelectEditor,
|
|
15
|
+
status: RowSelectEditor,
|
|
16
|
+
relation: RowRelationEditor,
|
|
17
|
+
user: RowRelationEditor,
|
|
18
|
+
date: RowDateEditor,
|
|
19
|
+
datetime: RowDateEditor,
|
|
20
|
+
multiselect: RowChipsEditor,
|
|
21
|
+
number: RowNumberEditor,
|
|
22
|
+
percent: RowNumberEditor,
|
|
23
|
+
currency: RowNumberEditor,
|
|
24
|
+
range: RowRangeEditor,
|
|
25
|
+
name: RowNameEditor,
|
|
26
|
+
text: RowTextEditor,
|
|
27
|
+
url: RowListOrText,
|
|
28
|
+
domain: RowListOrText,
|
|
29
|
+
phone: RowListOrText,
|
|
30
|
+
rich_text: RowTextEditor,
|
|
31
|
+
email: RowListOrText,
|
|
32
|
+
boolean: null,
|
|
33
|
+
location: RowPlaceEditor,
|
|
34
|
+
actor: null,
|
|
35
|
+
lookup: null,
|
|
36
|
+
rollup: null,
|
|
37
|
+
formula: null,
|
|
38
|
+
};
|
|
39
|
+
function mountsHost(field) {
|
|
40
|
+
return ROW_HOSTS[field.type] != null;
|
|
41
|
+
}
|
|
42
|
+
function hostless(field) {
|
|
43
|
+
switch (field.type) {
|
|
44
|
+
case "boolean":
|
|
45
|
+
return null;
|
|
46
|
+
case "actor":
|
|
47
|
+
return null;
|
|
48
|
+
case "lookup":
|
|
49
|
+
case "rollup":
|
|
50
|
+
case "formula":
|
|
51
|
+
return null;
|
|
52
|
+
default: {
|
|
53
|
+
const unhandled = field;
|
|
54
|
+
throw new Error(`RowEditor: field type "${String(unhandled)}" reached the drawer with no editor`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function RowEditor(props) {
|
|
59
|
+
const { field } = props.binding;
|
|
60
|
+
if (!mountsHost(field))
|
|
61
|
+
return hostless(field);
|
|
62
|
+
const Host = ROW_HOSTS[field.type];
|
|
63
|
+
return _jsx(Host, { ...props, field: field });
|
|
64
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RowHostProps } from "./host.js";
|
|
2
|
+
/** The FIELD ROW's host around the shared `NameEditor` — in place, like the
|
|
3
|
+
* range host: three boxes replace the value where it sits, on every width. */
|
|
4
|
+
export declare function RowNameEditor<Row>({ field, initial, onAttempt, onClose, }: RowHostProps<Row, "name">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { isNameValue } from "@viewkitjs/fields";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { NameEditor } from "../../editors/NameEditor.js";
|
|
7
|
+
import { useViews } from "../../provider/context.js";
|
|
8
|
+
import { RowRefusal, useRowEditSession } from "./row-session.js";
|
|
9
|
+
export function RowNameEditor({ field, initial, onAttempt, onClose, }) {
|
|
10
|
+
const { conventions } = useViews();
|
|
11
|
+
const editorRef = useRef(null);
|
|
12
|
+
const anchorRef = useRef(null);
|
|
13
|
+
const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
|
|
14
|
+
return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(NameEditor, { ref: editorRef, initial: isNameValue(initial) ? initial : null, allowEmpty: !!field.nullable, conventions: conventions, onRequestClose: close }), _jsx(RowRefusal, { text: session.refusal })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RowHostProps } from "./host.js";
|
|
2
|
+
/**
|
|
3
|
+
* The FIELD ROW's host around the shared `NumberEditor` — in place, on every
|
|
4
|
+
* width: the core replaces the row's value rather than opening a panel over it.
|
|
5
|
+
* Its close reasons are the keyboard's and the blur's, which the core names
|
|
6
|
+
* itself, and the row's session takes only the first.
|
|
7
|
+
*
|
|
8
|
+
* The commit is the core's `{ value, unit }` composite: the binding's `write`
|
|
9
|
+
* is what maps it onto the row's amount column and its currency column, which
|
|
10
|
+
* is why this host never splits it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function RowNumberEditor<Row>({ binding, row, field, initial, conversion, onAttempt, onClose, }: RowHostProps<Row, "number" | "percent" | "currency">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { ConversionLine } from "../../display/converted.js";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { NumberEditor } from "../../editors/NumberEditor.js";
|
|
7
|
+
import { durationUnitOf, numberEditCode, numberEditDecimals } from "../../fields/number-edit.js";
|
|
8
|
+
import { useViews } from "../../provider/context.js";
|
|
9
|
+
import { RowRefusal, useRowEditSession } from "./row-session.js";
|
|
10
|
+
export function RowNumberEditor({ binding, row, field, initial, conversion, onAttempt, onClose, }) {
|
|
11
|
+
const { conventions } = useViews();
|
|
12
|
+
const editorRef = useRef(null);
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
|
|
15
|
+
const decimals = numberEditDecimals(field);
|
|
16
|
+
const durationUnit = durationUnitOf(field);
|
|
17
|
+
return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(NumberEditor, { ref: editorRef, initial: typeof initial === "number" ? initial : Number.NaN, unit: binding.unit?.read(row), unitOptions: binding.unit ? [...binding.unit.options] : undefined, code: binding.unit ? undefined : numberEditCode(field), decimals: decimals, durationUnit: durationUnit, allowEmpty: !!field.nullable, align: "start", conventions: conventions, onRequestClose: close }), _jsx(RowRefusal, { text: session.refusal }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1" }) : null] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RowHostProps } from "./host.js";
|
|
2
|
+
/**
|
|
3
|
+
* The FIELD ROW's host around the shared `LocationEditor`. Anchored, as the grid's is: a country and its parts do
|
|
4
|
+
* not fit the row's line, so they open under the value, which stays on screen — a popover on a desktop, the sheet on
|
|
5
|
+
* a phone (`EditorPanel`). An emptied place always reaches the row, whose admission says so where the field can't be
|
|
6
|
+
* emptied, and the editor stays open with that sentence.
|
|
7
|
+
*/
|
|
8
|
+
export declare function RowPlaceEditor<Row>({ field, initial, anchor, onAttempt, onClose, }: RowHostProps<Row, "location">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
5
|
+
import { LocationEditor } from "../../editors/LocationEditor.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
import { useRowEditSession } from "./row-session.js";
|
|
8
|
+
export function RowPlaceEditor({ field, initial, anchor, onAttempt, onClose, }) {
|
|
9
|
+
const { conventions } = useViews();
|
|
10
|
+
const editorRef = useRef(null);
|
|
11
|
+
const anchorRef = useRef(null);
|
|
12
|
+
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
13
|
+
const place = initial && typeof initial === "object" && !Array.isArray(initial) ? initial : null;
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, chrome: "menu", className: "z-90 w-96 max-w-[calc(100vw-2rem)] p-2", children: (surface) => {
|
|
15
|
+
const editor = (_jsx(LocationEditor, { ref: editorRef, field: field, initial: place, allowEmpty: true, conventions: conventions, chrome: surface === "sheet" ? "field" : "bare", onRequestClose: close }));
|
|
16
|
+
return surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor;
|
|
17
|
+
} })] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RowHostProps } from "./host.js";
|
|
2
|
+
/** The FIELD ROW's host around the shared `RangeEditor` — in place, like the
|
|
3
|
+
* number host: two boxes replace the value where it sits, on every width. */
|
|
4
|
+
export declare function RowRangeEditor<Row>({ field, initial, onAttempt, onClose, }: RowHostProps<Row, "range">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { isRangeValue, rangeDecimals } from "@viewkitjs/fields";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { RangeEditor } from "../../editors/RangeEditor.js";
|
|
7
|
+
import { useViews } from "../../provider/context.js";
|
|
8
|
+
import { RowRefusal, useRowEditSession } from "./row-session.js";
|
|
9
|
+
export function RowRangeEditor({ field, initial, onAttempt, onClose, }) {
|
|
10
|
+
const { conventions } = useViews();
|
|
11
|
+
const editorRef = useRef(null);
|
|
12
|
+
const anchorRef = useRef(null);
|
|
13
|
+
const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
|
|
14
|
+
return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(RangeEditor, { ref: editorRef, initial: isRangeValue(initial) ? initial : null, decimals: rangeDecimals(field), allowEmpty: !!field.nullable, suffix: field.of === "percent" ? "%" : field.of === "currency" ? field.code?.fixed : undefined, align: "start", bands: field.presets, conventions: conventions, onRequestClose: close }), _jsx(RowRefusal, { text: session.refusal })] }));
|
|
15
|
+
}
|