@viewkitjs/views 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -0
- package/README.md +3 -3
- package/dist/atoms/DrillRows.d.ts +3 -0
- package/dist/atoms/DrillRows.js +25 -0
- package/dist/atoms/PanelRows.d.ts +5 -0
- package/dist/atoms/PanelRows.js +40 -0
- package/dist/atoms/PanelSearch.d.ts +2 -0
- package/dist/atoms/PanelSearch.js +21 -0
- package/dist/atoms/SelectionSheet.d.ts +3 -0
- package/dist/atoms/SelectionSheet.js +30 -0
- package/dist/atoms/defaults.js +12 -0
- package/dist/atoms/types.d.ts +117 -1
- package/dist/contract.d.ts +170 -9
- package/dist/contract.js +179 -2
- package/dist/figures.d.ts +5 -48
- package/dist/figures.js +1 -63
- package/dist/grid/chrome/GridColumnMenu.d.ts +3 -3
- package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
- package/dist/grid/chrome/GridGroupMenu.d.ts +2 -2
- package/dist/grid/chrome/GridTable.js +1 -1
- package/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/dist/grouping/sort-groups.d.ts +6 -7
- package/dist/model/aggregates.d.ts +3 -3
- package/dist/model/aggregates.js +17 -71
- package/dist/model/column-order.d.ts +2 -2
- package/dist/model/column-schema.d.ts +6 -7
- package/dist/model/column-state.d.ts +3 -20
- package/dist/model/column-state.js +1 -4
- package/dist/model/column-types.d.ts +1 -15
- package/dist/model/column-types.js +1 -1
- package/dist/model/part-columns.d.ts +1 -6
- package/dist/model/part-columns.js +1 -1
- package/dist/model/part-rows.d.ts +2 -9
- package/dist/model/part-rows.js +1 -10
- package/dist/model/preferences.d.ts +3 -23
- package/dist/model/preferences.js +1 -17
- package/dist/model/prefs-buckets.d.ts +0 -27
- package/dist/model/prefs-buckets.js +1 -1
- package/dist/model/relation-filters.d.ts +0 -1
- package/dist/model/relation-filters.js +1 -1
- package/dist/model/row-icon.d.ts +5 -9
- package/dist/model/view-rules.d.ts +32 -6
- package/dist/model/view-rules.js +94 -22
- package/dist/provider/ViewsProvider.d.ts +6 -2
- package/dist/provider/ViewsProvider.js +3 -2
- package/dist/provider/components.d.ts +16 -0
- package/dist/provider/context.d.ts +3 -1
- package/dist/provider/desktop.d.ts +3 -0
- package/dist/provider/desktop.js +7 -4
- package/dist/react.d.ts +2 -2
- package/dist/selection/SelectionBar.d.ts +18 -0
- package/dist/selection/SelectionBar.js +92 -0
- package/dist/selection/SelectionBarPhone.d.ts +3 -0
- package/dist/selection/SelectionBarPhone.js +14 -0
- package/dist/selection/bar-overflow.d.ts +12 -0
- package/dist/selection/bar-overflow.js +42 -0
- package/dist/selection/bar-parts.d.ts +15 -0
- package/dist/selection/bar-parts.js +17 -0
- package/dist/selection/index.d.ts +2 -0
- package/dist/selection/index.js +1 -0
- package/dist/selection/types.d.ts +3 -2
- package/dist/selection/verbs.d.ts +34 -0
- package/dist/selection/verbs.js +1 -0
- package/docs/contract.md +62 -8
- package/docs/getting-started.md +1 -1
- package/docs/guides/atoms.md +2 -1
- package/docs/guides/selection.md +32 -20
- package/docs/guides/the-grid.md +3 -2
- package/docs/guides/the-provider.md +4 -2
- package/docs/index.md +2 -0
- package/docs/install.md +4 -1
- package/docs/reference/grid.md +2 -2
- package/docs/reference/react.md +13 -3
- package/docs/reference/selection.md +10 -2
- package/docs/reference/views.md +25 -27
- package/package.json +22 -3
- package/skills/views/SKILL.md +1 -1
package/dist/contract.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CityWord, PercentDisplay, PostalWord, RegionWord } from "@viewkitjs/fields";
|
|
2
|
-
type FigureKind
|
|
2
|
+
import type { FigureKind } from "@viewkitjs/fields/query";
|
|
3
3
|
type OptionColour = "gray" | "blue" | "green" | "amber" | "red" | "purple" | "pink" | "teal";
|
|
4
4
|
type DateStyle = "short" | "long" | "numeric" | "relative";
|
|
5
5
|
type DurationStyle = "adaptive" | "clock" | "units";
|
|
@@ -27,8 +27,10 @@ export type VkToken = (typeof VK_TOKENS)[number];
|
|
|
27
27
|
export declare const VK_COLOURS: readonly ["--vk-fg", "--vk-fg-subtle", "--vk-fg-subtlest", "--vk-fg-brand", "--vk-fg-selected", "--vk-fg-on-brand", "--vk-ground", "--vk-overlay", "--vk-hovered", "--vk-pressed", "--vk-neutral", "--vk-neutral-hovered", "--vk-brand", "--vk-brand-subtlest", "--vk-danger", "--vk-danger-subtlest", "--vk-border", "--vk-border-subtle", "--vk-border-bold", "--vk-border-brand"];
|
|
28
28
|
export type VkColour = (typeof VK_COLOURS)[number];
|
|
29
29
|
/** Colours the default atoms and the display read with a built-in fallback — the status
|
|
30
|
-
* hues and the category hues — so an app that declares none of them still reads right.
|
|
31
|
-
|
|
30
|
+
* hues and the category hues — so an app that declares none of them still reads right.
|
|
31
|
+
* `--vk-float-shadow` is a whole `box-shadow` value: the drop under what floats over a list
|
|
32
|
+
* (the selection bar). */
|
|
33
|
+
export declare const VK_OPTIONAL_COLOURS: readonly ["--vk-success", "--vk-warning", "--vk-info", "--vk-label-blue", "--vk-label-green", "--vk-label-amber", "--vk-label-red", "--vk-label-purple", "--vk-label-pink", "--vk-label-teal", "--vk-float-shadow"];
|
|
32
34
|
export type VkOptionalColour = (typeof VK_OPTIONAL_COLOURS)[number];
|
|
33
35
|
/** Layout the APP may declare, read with a built-in fallback. `--vk-gutter` is the side padding the
|
|
34
36
|
* page gives its content: the grid's rows run edge to edge and line their content up with it.
|
|
@@ -59,12 +61,16 @@ export type ComponentName = (typeof COMPONENT_NAMES)[number];
|
|
|
59
61
|
* around `Calendar`. */
|
|
60
62
|
export declare const OPTIONAL_COMPONENT_NAMES: readonly ["Input", "Command", "Picker", "Calendar", "DateBody"];
|
|
61
63
|
export type OptionalComponentName = (typeof OPTIONAL_COMPONENT_NAMES)[number];
|
|
62
|
-
/** The pieces the rendering is built from, and the app's own pieces it cannot draw itself (a command cell's verb menu, the row's right-click menu, where a relation goes, a wait, how a list asks for more). Each ships as a default; an app swaps any of them through the provider's `atoms`. */
|
|
63
|
-
export declare const ATOM_NAMES: readonly ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "RelationRoles", "Loading", "LoadMore", "PlatformMark", "RowMenu"];
|
|
64
|
+
/** The pieces the rendering is built from, and the app's own pieces it cannot draw itself (a command cell's verb menu, the row's right-click menu, where a relation goes, a wait, how a list asks for more), and the rows the panels draw with. Each ships as a default; an app swaps any of them through the provider's `atoms`. */
|
|
65
|
+
export declare const ATOM_NAMES: readonly ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "RelationRoles", "Loading", "LoadMore", "PlatformMark", "RowMenu", "SelectionSheet", "ChoiceRow", "CheckRow", "RadioRow", "DirectionButton", "MenuRow", "ToggleRow", "PanelSearch"];
|
|
64
66
|
export type AtomName = (typeof ATOM_NAMES)[number];
|
|
65
67
|
/** The default atoms' `data-slot` values: prefixed, like the grid's. */
|
|
66
|
-
export declare const ATOM_SLOTS: readonly ["vk-row", "vk-row-content", "vk-tick", "vk-status", "vk-marker", "vk-tag", "vk-list", "vk-command-menu", "vk-relation-link", "vk-relation-roles", "vk-loading", "vk-load-more", "vk-platform", "vk-row-menu"];
|
|
68
|
+
export declare const ATOM_SLOTS: readonly ["vk-row", "vk-row-content", "vk-tick", "vk-status", "vk-marker", "vk-tag", "vk-list", "vk-command-menu", "vk-relation-link", "vk-relation-roles", "vk-loading", "vk-load-more", "vk-platform", "vk-row-menu", "vk-choice-row", "vk-check-row", "vk-radio-row", "vk-direction", "vk-menu-row", "vk-toggle-row", "vk-panel-search", "vk-selection-sheet"];
|
|
67
69
|
export type AtomSlot = (typeof ATOM_SLOTS)[number];
|
|
70
|
+
/** The selection bar's `data-slot` values: prefixed, like the grid's. The fixed box the app places,
|
|
71
|
+
* the pill inside it, and the count that clears the selection. */
|
|
72
|
+
export declare const SELECTION_SLOTS: readonly ["vk-selection-bar", "vk-selection-pill", "vk-selection-chip"];
|
|
73
|
+
export type SelectionSlot = (typeof SELECTION_SLOTS)[number];
|
|
68
74
|
/** The editor panel's `data-slot` values: prefixed, like the grid's. */
|
|
69
75
|
export declare const EDITOR_SLOTS: readonly ["vk-editor-panel", "vk-editor-bar", "vk-editor-refusal", "vk-text-editor"];
|
|
70
76
|
export type EditorSlot = (typeof EDITOR_SLOTS)[number];
|
|
@@ -77,10 +83,10 @@ export declare const PORT_NAMES: readonly ["toast", "haptics", "clipboard", "vie
|
|
|
77
83
|
export type PortName = (typeof PORT_NAMES)[number];
|
|
78
84
|
/** The glyphs the rendering asks the app for, by what they mean, never by a
|
|
79
85
|
* library's name. The app maps each to its own icon component. */
|
|
80
|
-
export declare const ICON_NAMES: readonly ["text", "longText", "number", "percent", "currency", "date", "datetime", "duration", "boolean", "select", "status", "multiselect", "relation", "user", "url", "domain", "email", "phone", "location", "name", "actor", "rich_text", "range", "lookup", "rollup", "formula", "computed", "automation", "apiKey", "system", "add", "edit", "delete", "copy", "cut", "paste", "clear", "hide", "show", "lock", "pin", "wrap", "more", "close", "check", "warning", "drag", "resize", "open", "selectRow", "chevronDown", "chevronRight", "caretDown", "caretRight", "sortAsc", "sortDesc", "enter", "calendar", "time", "progress", "moveLeft", "moveRight", "group", "clearSort", "sortRowsUp", "sortRowsDown"];
|
|
86
|
+
export declare const ICON_NAMES: readonly ["text", "longText", "number", "percent", "currency", "date", "datetime", "duration", "boolean", "select", "status", "multiselect", "relation", "user", "url", "domain", "email", "phone", "location", "name", "actor", "rich_text", "range", "lookup", "rollup", "formula", "computed", "automation", "apiKey", "system", "add", "edit", "delete", "copy", "cut", "paste", "clear", "hide", "show", "lock", "pin", "wrap", "more", "close", "check", "warning", "drag", "resize", "open", "selectRow", "chevronDown", "chevronRight", "caretDown", "caretRight", "sortAsc", "sortDesc", "enter", "calendar", "time", "progress", "moveLeft", "moveRight", "group", "clearSort", "sortRowsUp", "sortRowsDown", "search", "reset"];
|
|
81
87
|
export type ViewsIconName = (typeof ICON_NAMES)[number];
|
|
82
88
|
/** Every visible string the views package owns is a key under one of these. */
|
|
83
|
-
export declare const MESSAGE_NAMESPACES: readonly ["views.grid", "views.editors", "views.menus", "views.display"];
|
|
89
|
+
export declare const MESSAGE_NAMESPACES: readonly ["views.grid", "views.editors", "views.menus", "views.display", "views.selection", "views.panels"];
|
|
84
90
|
export type ViewsMessageNamespace = (typeof MESSAGE_NAMESPACES)[number];
|
|
85
91
|
/** A message the package emits: its key and the values a host may interpolate,
|
|
86
92
|
* never a sentence. A string `@viewkitjs/fields` already keys stays a fields
|
|
@@ -518,6 +524,161 @@ export type ViewsMessage = {
|
|
|
518
524
|
};
|
|
519
525
|
} | {
|
|
520
526
|
key: "views.display.as-shown";
|
|
527
|
+
} | {
|
|
528
|
+
key: "views.panels.for-you";
|
|
529
|
+
} | {
|
|
530
|
+
key: "views.panels.group-order-most";
|
|
531
|
+
} | {
|
|
532
|
+
key: "views.panels.group-order-fewest";
|
|
533
|
+
} | {
|
|
534
|
+
key: "views.panels.group-order-newest";
|
|
535
|
+
} | {
|
|
536
|
+
key: "views.panels.group-order-oldest";
|
|
537
|
+
} | {
|
|
538
|
+
key: "views.panels.group-order-alphabetical";
|
|
539
|
+
} | {
|
|
540
|
+
key: "views.panels.group-order-reverse-alphabetical";
|
|
541
|
+
} | {
|
|
542
|
+
key: "views.panels.group-order-reversed";
|
|
543
|
+
values: {
|
|
544
|
+
label: string;
|
|
545
|
+
};
|
|
546
|
+
} | {
|
|
547
|
+
key: "views.panels.group-order-default";
|
|
548
|
+
} | {
|
|
549
|
+
key: "views.panels.group-order-count";
|
|
550
|
+
} | {
|
|
551
|
+
key: "views.panels.group-order-name";
|
|
552
|
+
} | {
|
|
553
|
+
key: "views.panels.group-order-manual";
|
|
554
|
+
} | {
|
|
555
|
+
key: "views.panels.quantifier";
|
|
556
|
+
values: {
|
|
557
|
+
quantifier: "any" | "none" | "every";
|
|
558
|
+
};
|
|
559
|
+
} | {
|
|
560
|
+
key: "views.panels.join-or";
|
|
561
|
+
} | {
|
|
562
|
+
key: "views.panels.join-and";
|
|
563
|
+
} | {
|
|
564
|
+
key: "views.panels.relation-condition-options";
|
|
565
|
+
values: {
|
|
566
|
+
field: string;
|
|
567
|
+
options: string;
|
|
568
|
+
};
|
|
569
|
+
} | {
|
|
570
|
+
key: "views.panels.relation-condition";
|
|
571
|
+
values: {
|
|
572
|
+
field: string;
|
|
573
|
+
value: string;
|
|
574
|
+
};
|
|
575
|
+
} | {
|
|
576
|
+
key: "views.panels.relation-sentence";
|
|
577
|
+
values: {
|
|
578
|
+
rule: "all" | "any" | "none" | "every" | "every-unmatched";
|
|
579
|
+
subject: string;
|
|
580
|
+
one: string;
|
|
581
|
+
many: string;
|
|
582
|
+
/** The held conditions, joined; empty when none holds. */
|
|
583
|
+
conditions: string;
|
|
584
|
+
};
|
|
585
|
+
} | {
|
|
586
|
+
key: "views.panels.filter-unavailable";
|
|
587
|
+
} | {
|
|
588
|
+
key: "views.panels.filter-all";
|
|
589
|
+
} | {
|
|
590
|
+
key: "views.panels.relation-value-one";
|
|
591
|
+
values: {
|
|
592
|
+
quantifier: string;
|
|
593
|
+
field: string;
|
|
594
|
+
value: string;
|
|
595
|
+
};
|
|
596
|
+
} | {
|
|
597
|
+
key: "views.panels.relation-value-many";
|
|
598
|
+
values: {
|
|
599
|
+
quantifier: string;
|
|
600
|
+
count: number;
|
|
601
|
+
};
|
|
602
|
+
} | {
|
|
603
|
+
key: "views.panels.filter-all-of";
|
|
604
|
+
values: {
|
|
605
|
+
field: string;
|
|
606
|
+
};
|
|
607
|
+
} | {
|
|
608
|
+
key: "views.panels.filter-selected";
|
|
609
|
+
values: {
|
|
610
|
+
count: number;
|
|
611
|
+
};
|
|
612
|
+
} | {
|
|
613
|
+
key: "views.panels.date-range-all";
|
|
614
|
+
} | {
|
|
615
|
+
key: "views.panels.date-range-between";
|
|
616
|
+
values: {
|
|
617
|
+
from: string;
|
|
618
|
+
to: string;
|
|
619
|
+
};
|
|
620
|
+
} | {
|
|
621
|
+
key: "views.panels.date-range-from";
|
|
622
|
+
values: {
|
|
623
|
+
from: string;
|
|
624
|
+
};
|
|
625
|
+
} | {
|
|
626
|
+
key: "views.panels.date-range-until";
|
|
627
|
+
values: {
|
|
628
|
+
to: string;
|
|
629
|
+
};
|
|
630
|
+
} | {
|
|
631
|
+
key: "views.panels.time-scope-custom";
|
|
632
|
+
} | {
|
|
633
|
+
key: "views.panels.sort-value";
|
|
634
|
+
values: {
|
|
635
|
+
label: string;
|
|
636
|
+
dir: "asc" | "desc";
|
|
637
|
+
};
|
|
638
|
+
} | {
|
|
639
|
+
key: "views.panels.group-none";
|
|
640
|
+
} | {
|
|
641
|
+
key: "views.panels.filter-count";
|
|
642
|
+
values: {
|
|
643
|
+
count: number;
|
|
644
|
+
};
|
|
645
|
+
} | {
|
|
646
|
+
key: "views.panels.direction";
|
|
647
|
+
values: {
|
|
648
|
+
dir: "asc" | "desc";
|
|
649
|
+
};
|
|
650
|
+
} | {
|
|
651
|
+
key: "views.panels.toggle-reset";
|
|
652
|
+
values: {
|
|
653
|
+
label: string;
|
|
654
|
+
};
|
|
655
|
+
} | {
|
|
656
|
+
key: "views.panels.toggle-reset-hint";
|
|
657
|
+
} | {
|
|
658
|
+
key: "views.panels.search-clear";
|
|
659
|
+
} | {
|
|
660
|
+
key: "views.selection.count";
|
|
661
|
+
values: {
|
|
662
|
+
count: number;
|
|
663
|
+
};
|
|
664
|
+
} | {
|
|
665
|
+
key: "views.selection.selected";
|
|
666
|
+
} | {
|
|
667
|
+
key: "views.selection.deselect-all";
|
|
668
|
+
} | {
|
|
669
|
+
key: "views.selection.clear";
|
|
670
|
+
} | {
|
|
671
|
+
key: "views.selection.delete";
|
|
672
|
+
} | {
|
|
673
|
+
key: "views.selection.more";
|
|
674
|
+
} | {
|
|
675
|
+
key: "views.selection.more-label";
|
|
676
|
+
} | {
|
|
677
|
+
key: "views.selection.actions";
|
|
678
|
+
} | {
|
|
679
|
+
key: "views.selection.sheet-label";
|
|
680
|
+
} | {
|
|
681
|
+
key: "views.selection.escape";
|
|
521
682
|
};
|
|
522
683
|
export type ViewsMessageKey = ViewsMessage["key"];
|
|
523
684
|
/** A place's word, as a message key: the region, city or postal-code word a country's format names
|
|
@@ -527,7 +688,7 @@ export type PlaceWordKey = Extract<ViewsMessageKey, `views.editors.place-${"regi
|
|
|
527
688
|
export declare function placeWordKey(kind: "region", word: RegionWord): PlaceWordKey;
|
|
528
689
|
export declare function placeWordKey(kind: "city", word: CityWord): PlaceWordKey;
|
|
529
690
|
export declare function placeWordKey(kind: "postal", word: PostalWord): PlaceWordKey;
|
|
530
|
-
export declare const VIEWS_MESSAGE_KEYS: readonly ["views.editors.tag-remove", "views.editors.marker-resolve", "views.editors.marker-no-reason", "views.editors.range-low", "views.editors.range-high", "views.editors.name-given", "views.editors.name-family", "views.editors.name-full", "views.editors.values-add", "views.editors.values-label", "views.editors.values-main", "views.editors.values-make-main", "views.editors.values-remove", "views.editors.discard", "views.editors.save", "views.editors.open-email", "views.editors.open-phone", "views.editors.open-link", "views.editors.place-country", "views.editors.place-country-search", "views.editors.place-change-country", "views.editors.place-region-search", "views.editors.place-line1", "views.editors.place-line2", "views.editors.place-region-area", "views.editors.place-region-county", "views.editors.place-region-department", "views.editors.place-region-district", "views.editors.place-region-do-si", "views.editors.place-region-emirate", "views.editors.place-region-island", "views.editors.place-region-oblast", "views.editors.place-region-parish", "views.editors.place-region-prefecture", "views.editors.place-region-province", "views.editors.place-region-state", "views.editors.place-city-city", "views.editors.place-city-district", "views.editors.place-city-post-town", "views.editors.place-city-suburb", "views.editors.place-postal-eircode", "views.editors.place-postal-pin", "views.editors.place-postal-postal", "views.editors.place-postal-zip", "views.editors.place-required", "views.editors.place-region", "views.menus.part-row", "views.menus.sort-asc", "views.menus.sort-desc", "views.menus.sort-clear", "views.menus.group-by", "views.menus.ungroup", "views.menus.move-left", "views.menus.move-right", "views.menus.hide-column", "views.menus.format", "views.menus.date-style", "views.menus.show-time", "views.menus.duration-style", "views.menus.decimals", "views.menus.automatic", "views.menus.currency", "views.menus.percent-display", "views.menus.percent-display-option", "views.menus.colour", "views.menus.colours-reset", "views.menus.group-options", "views.menus.group-sort", "views.menus.search", "views.menus.group-show", "views.menus.group-count", "views.menus.group-hide", "views.menus.add-column-search", "views.menus.add-column-no-match", "views.menus.add-column-all-shown", "views.menus.copy", "views.menus.cut", "views.menus.paste", "views.menus.clear", "views.menus.edit", "views.menus.row-open", "views.menus.row-select", "views.menus.row-delete", "views.menus.row-delete-confirm", "views.menus.row-delete-failed", "views.menus.row-menu", "views.menus.commands", "views.menus.commands-unnamed", "views.menus.figure-menu", "views.menus.column-menu", "views.grid.figure", "views.grid.figure-pick", "views.grid.add-column", "views.grid.loading", "views.grid.select-row", "views.grid.select-group", "views.grid.select-all", "views.grid.row-menu", "views.grid.group-expand", "views.grid.group-collapse", "views.grid.change-value", "views.grid.value", "views.grid.edit-value", "views.grid.read-only", "views.grid.read-only-why", "views.grid.locked", "views.grid.not-clearable", "views.grid.computed", "views.grid.cell-read-only", "views.grid.clear-none", "views.grid.clear-required", "views.grid.write-not-list", "views.grid.write-not-boolean", "views.grid.write-marker", "views.grid.write-not-email", "views.grid.write-not-url", "views.grid.write-not-link", "views.grid.write-not-linkable", "views.grid.paste-refused", "views.grid.paste-empty", "views.grid.paste-not-number", "views.grid.paste-not-duration", "views.grid.paste-not-date", "views.grid.paste-not-option", "views.grid.paste-ambiguous-option", "views.grid.paste-other-currency", "views.grid.paste-pick", "views.grid.paste-not-linkable", "views.grid.paste-not-range", "views.grid.paste-skipped", "views.grid.fill-skipped", "views.grid.commit-refused", "views.grid.commit-refused-many", "views.grid.changed-elsewhere", "views.grid.changed-elsewhere-cells", "views.grid.saved-value", "views.grid.saved-values", "views.grid.row-left", "views.display.just-now", "views.display.in", "views.display.today", "views.display.yesterday", "views.display.tomorrow", "views.display.month", "views.display.not-an-option", "views.display.needs-attention", "views.display.boolean", "views.display.show-all", "views.display.show-more", "views.display.show-less", "views.display.phone-extension", "views.display.phone-as-typed", "views.display.converted-from", "views.display.as-shown"];
|
|
691
|
+
export declare const VIEWS_MESSAGE_KEYS: readonly ["views.editors.tag-remove", "views.editors.marker-resolve", "views.editors.marker-no-reason", "views.editors.range-low", "views.editors.range-high", "views.editors.name-given", "views.editors.name-family", "views.editors.name-full", "views.editors.values-add", "views.editors.values-label", "views.editors.values-main", "views.editors.values-make-main", "views.editors.values-remove", "views.editors.discard", "views.editors.save", "views.editors.open-email", "views.editors.open-phone", "views.editors.open-link", "views.editors.place-country", "views.editors.place-country-search", "views.editors.place-change-country", "views.editors.place-region-search", "views.editors.place-line1", "views.editors.place-line2", "views.editors.place-region-area", "views.editors.place-region-county", "views.editors.place-region-department", "views.editors.place-region-district", "views.editors.place-region-do-si", "views.editors.place-region-emirate", "views.editors.place-region-island", "views.editors.place-region-oblast", "views.editors.place-region-parish", "views.editors.place-region-prefecture", "views.editors.place-region-province", "views.editors.place-region-state", "views.editors.place-city-city", "views.editors.place-city-district", "views.editors.place-city-post-town", "views.editors.place-city-suburb", "views.editors.place-postal-eircode", "views.editors.place-postal-pin", "views.editors.place-postal-postal", "views.editors.place-postal-zip", "views.editors.place-required", "views.editors.place-region", "views.menus.part-row", "views.menus.sort-asc", "views.menus.sort-desc", "views.menus.sort-clear", "views.menus.group-by", "views.menus.ungroup", "views.menus.move-left", "views.menus.move-right", "views.menus.hide-column", "views.menus.format", "views.menus.date-style", "views.menus.show-time", "views.menus.duration-style", "views.menus.decimals", "views.menus.automatic", "views.menus.currency", "views.menus.percent-display", "views.menus.percent-display-option", "views.menus.colour", "views.menus.colours-reset", "views.menus.group-options", "views.menus.group-sort", "views.menus.search", "views.menus.group-show", "views.menus.group-count", "views.menus.group-hide", "views.menus.add-column-search", "views.menus.add-column-no-match", "views.menus.add-column-all-shown", "views.menus.copy", "views.menus.cut", "views.menus.paste", "views.menus.clear", "views.menus.edit", "views.menus.row-open", "views.menus.row-select", "views.menus.row-delete", "views.menus.row-delete-confirm", "views.menus.row-delete-failed", "views.menus.row-menu", "views.menus.commands", "views.menus.commands-unnamed", "views.menus.figure-menu", "views.menus.column-menu", "views.grid.figure", "views.grid.figure-pick", "views.grid.add-column", "views.grid.loading", "views.grid.select-row", "views.grid.select-group", "views.grid.select-all", "views.grid.row-menu", "views.grid.group-expand", "views.grid.group-collapse", "views.grid.change-value", "views.grid.value", "views.grid.edit-value", "views.grid.read-only", "views.grid.read-only-why", "views.grid.locked", "views.grid.not-clearable", "views.grid.computed", "views.grid.cell-read-only", "views.grid.clear-none", "views.grid.clear-required", "views.grid.write-not-list", "views.grid.write-not-boolean", "views.grid.write-marker", "views.grid.write-not-email", "views.grid.write-not-url", "views.grid.write-not-link", "views.grid.write-not-linkable", "views.grid.paste-refused", "views.grid.paste-empty", "views.grid.paste-not-number", "views.grid.paste-not-duration", "views.grid.paste-not-date", "views.grid.paste-not-option", "views.grid.paste-ambiguous-option", "views.grid.paste-other-currency", "views.grid.paste-pick", "views.grid.paste-not-linkable", "views.grid.paste-not-range", "views.grid.paste-skipped", "views.grid.fill-skipped", "views.grid.commit-refused", "views.grid.commit-refused-many", "views.grid.changed-elsewhere", "views.grid.changed-elsewhere-cells", "views.grid.saved-value", "views.grid.saved-values", "views.grid.row-left", "views.display.just-now", "views.display.in", "views.display.today", "views.display.yesterday", "views.display.tomorrow", "views.display.month", "views.display.not-an-option", "views.display.needs-attention", "views.display.boolean", "views.display.show-all", "views.display.show-more", "views.display.show-less", "views.display.phone-extension", "views.display.phone-as-typed", "views.display.converted-from", "views.display.as-shown", "views.panels.for-you", "views.panels.group-order-most", "views.panels.group-order-fewest", "views.panels.group-order-newest", "views.panels.group-order-oldest", "views.panels.group-order-alphabetical", "views.panels.group-order-reverse-alphabetical", "views.panels.group-order-reversed", "views.panels.group-order-default", "views.panels.group-order-count", "views.panels.group-order-name", "views.panels.group-order-manual", "views.panels.quantifier", "views.panels.join-or", "views.panels.join-and", "views.panels.relation-condition-options", "views.panels.relation-condition", "views.panels.relation-sentence", "views.panels.filter-unavailable", "views.panels.filter-all", "views.panels.relation-value-one", "views.panels.relation-value-many", "views.panels.filter-all-of", "views.panels.filter-selected", "views.panels.date-range-all", "views.panels.date-range-between", "views.panels.date-range-from", "views.panels.date-range-until", "views.panels.time-scope-custom", "views.panels.sort-value", "views.panels.group-none", "views.panels.filter-count", "views.panels.direction", "views.panels.toggle-reset", "views.panels.toggle-reset-hint", "views.panels.search-clear", "views.selection.count", "views.selection.selected", "views.selection.deselect-all", "views.selection.clear", "views.selection.delete", "views.selection.more", "views.selection.more-label", "views.selection.actions", "views.selection.sheet-label", "views.selection.escape"];
|
|
531
692
|
/** What an app hands in: its wording for every message. A resolver that words
|
|
532
693
|
* only some keys calls `resolveViewsMessage` for the rest; the provider does not. */
|
|
533
694
|
export type ViewsMessageResolver = (message: ViewsMessage) => string;
|
package/dist/contract.js
CHANGED
|
@@ -103,6 +103,7 @@ export const VK_OPTIONAL_COLOURS = [
|
|
|
103
103
|
"--vk-label-purple",
|
|
104
104
|
"--vk-label-pink",
|
|
105
105
|
"--vk-label-teal",
|
|
106
|
+
"--vk-float-shadow",
|
|
106
107
|
];
|
|
107
108
|
export const VK_OPTIONAL_LAYOUT = ["--vk-gutter", "--vk-scroll-inset-bottom"];
|
|
108
109
|
export const VK_INTERNAL = ["--vk-drag-shift", "--vk-cols", "--vk-hold-x", "--vk-sx"];
|
|
@@ -119,7 +120,7 @@ export const COMPONENT_NAMES = [
|
|
|
119
120
|
"Markdown",
|
|
120
121
|
];
|
|
121
122
|
export const OPTIONAL_COMPONENT_NAMES = ["Input", "Command", "Picker", "Calendar", "DateBody"];
|
|
122
|
-
export const ATOM_NAMES = ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "RelationRoles", "Loading", "LoadMore", "PlatformMark", "RowMenu"];
|
|
123
|
+
export const ATOM_NAMES = ["Row", "RowContent", "TickBox", "StatusBadge", "StatusMarker", "Tag", "List", "CommandMenu", "RelationLink", "RelationRoles", "Loading", "LoadMore", "PlatformMark", "RowMenu", "SelectionSheet", "ChoiceRow", "CheckRow", "RadioRow", "DirectionButton", "MenuRow", "ToggleRow", "PanelSearch"];
|
|
123
124
|
export const ATOM_SLOTS = [
|
|
124
125
|
"vk-row",
|
|
125
126
|
"vk-row-content",
|
|
@@ -135,7 +136,16 @@ export const ATOM_SLOTS = [
|
|
|
135
136
|
"vk-load-more",
|
|
136
137
|
"vk-platform",
|
|
137
138
|
"vk-row-menu",
|
|
139
|
+
"vk-choice-row",
|
|
140
|
+
"vk-check-row",
|
|
141
|
+
"vk-radio-row",
|
|
142
|
+
"vk-direction",
|
|
143
|
+
"vk-menu-row",
|
|
144
|
+
"vk-toggle-row",
|
|
145
|
+
"vk-panel-search",
|
|
146
|
+
"vk-selection-sheet",
|
|
138
147
|
];
|
|
148
|
+
export const SELECTION_SLOTS = ["vk-selection-bar", "vk-selection-pill", "vk-selection-chip"];
|
|
139
149
|
export const EDITOR_SLOTS = ["vk-editor-panel", "vk-editor-bar", "vk-editor-refusal", "vk-text-editor"];
|
|
140
150
|
export const ATOM_STATES = ["chosen", "disabled", "muted", "checked", "open", "status", "platform"];
|
|
141
151
|
export const PORT_NAMES = ["toast", "haptics", "clipboard", "viewPrefs", "confirm"];
|
|
@@ -206,8 +216,17 @@ export const ICON_NAMES = [
|
|
|
206
216
|
"clearSort",
|
|
207
217
|
"sortRowsUp",
|
|
208
218
|
"sortRowsDown",
|
|
219
|
+
"search",
|
|
220
|
+
"reset",
|
|
221
|
+
];
|
|
222
|
+
export const MESSAGE_NAMESPACES = [
|
|
223
|
+
"views.grid",
|
|
224
|
+
"views.editors",
|
|
225
|
+
"views.menus",
|
|
226
|
+
"views.display",
|
|
227
|
+
"views.selection",
|
|
228
|
+
"views.panels",
|
|
209
229
|
];
|
|
210
|
-
export const MESSAGE_NAMESPACES = ["views.grid", "views.editors", "views.menus", "views.display"];
|
|
211
230
|
export function placeWordKey(kind, word) {
|
|
212
231
|
return `views.editors.place-${kind}-${word.replace("_", "-")}`;
|
|
213
232
|
}
|
|
@@ -366,6 +385,52 @@ export const VIEWS_MESSAGE_KEYS = [
|
|
|
366
385
|
"views.display.phone-as-typed",
|
|
367
386
|
"views.display.converted-from",
|
|
368
387
|
"views.display.as-shown",
|
|
388
|
+
"views.panels.for-you",
|
|
389
|
+
"views.panels.group-order-most",
|
|
390
|
+
"views.panels.group-order-fewest",
|
|
391
|
+
"views.panels.group-order-newest",
|
|
392
|
+
"views.panels.group-order-oldest",
|
|
393
|
+
"views.panels.group-order-alphabetical",
|
|
394
|
+
"views.panels.group-order-reverse-alphabetical",
|
|
395
|
+
"views.panels.group-order-reversed",
|
|
396
|
+
"views.panels.group-order-default",
|
|
397
|
+
"views.panels.group-order-count",
|
|
398
|
+
"views.panels.group-order-name",
|
|
399
|
+
"views.panels.group-order-manual",
|
|
400
|
+
"views.panels.quantifier",
|
|
401
|
+
"views.panels.join-or",
|
|
402
|
+
"views.panels.join-and",
|
|
403
|
+
"views.panels.relation-condition-options",
|
|
404
|
+
"views.panels.relation-condition",
|
|
405
|
+
"views.panels.relation-sentence",
|
|
406
|
+
"views.panels.filter-unavailable",
|
|
407
|
+
"views.panels.filter-all",
|
|
408
|
+
"views.panels.relation-value-one",
|
|
409
|
+
"views.panels.relation-value-many",
|
|
410
|
+
"views.panels.filter-all-of",
|
|
411
|
+
"views.panels.filter-selected",
|
|
412
|
+
"views.panels.date-range-all",
|
|
413
|
+
"views.panels.date-range-between",
|
|
414
|
+
"views.panels.date-range-from",
|
|
415
|
+
"views.panels.date-range-until",
|
|
416
|
+
"views.panels.time-scope-custom",
|
|
417
|
+
"views.panels.sort-value",
|
|
418
|
+
"views.panels.group-none",
|
|
419
|
+
"views.panels.filter-count",
|
|
420
|
+
"views.panels.direction",
|
|
421
|
+
"views.panels.toggle-reset",
|
|
422
|
+
"views.panels.toggle-reset-hint",
|
|
423
|
+
"views.panels.search-clear",
|
|
424
|
+
"views.selection.count",
|
|
425
|
+
"views.selection.selected",
|
|
426
|
+
"views.selection.deselect-all",
|
|
427
|
+
"views.selection.clear",
|
|
428
|
+
"views.selection.delete",
|
|
429
|
+
"views.selection.more",
|
|
430
|
+
"views.selection.more-label",
|
|
431
|
+
"views.selection.actions",
|
|
432
|
+
"views.selection.sheet-label",
|
|
433
|
+
"views.selection.escape",
|
|
369
434
|
];
|
|
370
435
|
const _everyKeyListed = true;
|
|
371
436
|
void _everyKeyListed;
|
|
@@ -418,6 +483,24 @@ const DURATION_STYLE_WORDS = {
|
|
|
418
483
|
};
|
|
419
484
|
const PERCENT_DISPLAY_WORDS = { text: "Number", bar: "Bar", ring: "Ring" };
|
|
420
485
|
const cellsWerent = (count) => (count === 1 ? "1 cell wasn't" : `${count} cells weren't`);
|
|
486
|
+
const QUANTIFIER_WORDS = { any: "Any", none: "None", every: "Every" };
|
|
487
|
+
function relationSentenceWords(values) {
|
|
488
|
+
const { rule, subject, one, many, conditions } = values;
|
|
489
|
+
if (rule === "all")
|
|
490
|
+
return `All ${subject}, whatever their ${many}.`;
|
|
491
|
+
const Subject = subject.charAt(0).toUpperCase() + subject.slice(1);
|
|
492
|
+
const where = conditions ? ` where ${conditions}` : "";
|
|
493
|
+
switch (rule) {
|
|
494
|
+
case "any":
|
|
495
|
+
return `${Subject} with at least one ${one}${where}.`;
|
|
496
|
+
case "none":
|
|
497
|
+
return `${Subject} with no ${one}${where}.`;
|
|
498
|
+
case "every":
|
|
499
|
+
return `${Subject} with only ${many}${where}.`;
|
|
500
|
+
case "every-unmatched":
|
|
501
|
+
return `${Subject} whose every ${one} matches.`;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
421
504
|
export function resolveViewsMessage(message) {
|
|
422
505
|
switch (message.key) {
|
|
423
506
|
case "views.editors.tag-remove":
|
|
@@ -731,5 +814,99 @@ export function resolveViewsMessage(message) {
|
|
|
731
814
|
return `Converted from ${message.values.code}`;
|
|
732
815
|
case "views.display.as-shown":
|
|
733
816
|
return "as shown";
|
|
817
|
+
case "views.panels.for-you":
|
|
818
|
+
return "For you";
|
|
819
|
+
case "views.panels.group-order-most":
|
|
820
|
+
return "Most first";
|
|
821
|
+
case "views.panels.group-order-fewest":
|
|
822
|
+
return "Fewest first";
|
|
823
|
+
case "views.panels.group-order-newest":
|
|
824
|
+
return "Newest first";
|
|
825
|
+
case "views.panels.group-order-oldest":
|
|
826
|
+
return "Oldest first";
|
|
827
|
+
case "views.panels.group-order-alphabetical":
|
|
828
|
+
return "Alphabetical";
|
|
829
|
+
case "views.panels.group-order-reverse-alphabetical":
|
|
830
|
+
return "Reverse alphabetical";
|
|
831
|
+
case "views.panels.group-order-reversed":
|
|
832
|
+
return `${message.values.label}, reversed`;
|
|
833
|
+
case "views.panels.group-order-default":
|
|
834
|
+
return "Default";
|
|
835
|
+
case "views.panels.group-order-count":
|
|
836
|
+
return "Count";
|
|
837
|
+
case "views.panels.group-order-name":
|
|
838
|
+
return "Name";
|
|
839
|
+
case "views.panels.group-order-manual":
|
|
840
|
+
return "Manual";
|
|
841
|
+
case "views.panels.quantifier":
|
|
842
|
+
return QUANTIFIER_WORDS[message.values.quantifier];
|
|
843
|
+
case "views.panels.join-or":
|
|
844
|
+
return " or ";
|
|
845
|
+
case "views.panels.join-and":
|
|
846
|
+
return " and ";
|
|
847
|
+
case "views.panels.relation-condition-options":
|
|
848
|
+
return `${message.values.field.toLowerCase()} is ${message.values.options}`;
|
|
849
|
+
case "views.panels.relation-condition":
|
|
850
|
+
return `${message.values.field.toLowerCase()} ${message.values.value}`;
|
|
851
|
+
case "views.panels.relation-sentence":
|
|
852
|
+
return relationSentenceWords(message.values);
|
|
853
|
+
case "views.panels.filter-unavailable":
|
|
854
|
+
return "Saved filter unavailable";
|
|
855
|
+
case "views.panels.filter-all":
|
|
856
|
+
return "All";
|
|
857
|
+
case "views.panels.relation-value-one":
|
|
858
|
+
return `${message.values.quantifier} · ${message.values.field}: ${message.values.value}`;
|
|
859
|
+
case "views.panels.relation-value-many":
|
|
860
|
+
return `${message.values.quantifier} · ${message.values.count} rules`;
|
|
861
|
+
case "views.panels.filter-all-of":
|
|
862
|
+
return `All ${message.values.field.toLowerCase()}`;
|
|
863
|
+
case "views.panels.filter-selected":
|
|
864
|
+
return `${message.values.count} selected`;
|
|
865
|
+
case "views.panels.date-range-all":
|
|
866
|
+
return "All time";
|
|
867
|
+
case "views.panels.date-range-between":
|
|
868
|
+
return `${message.values.from} — ${message.values.to}`;
|
|
869
|
+
case "views.panels.date-range-from":
|
|
870
|
+
return `From ${message.values.from}`;
|
|
871
|
+
case "views.panels.date-range-until":
|
|
872
|
+
return `Until ${message.values.to}`;
|
|
873
|
+
case "views.panels.time-scope-custom":
|
|
874
|
+
return "Custom";
|
|
875
|
+
case "views.panels.sort-value":
|
|
876
|
+
return `${message.values.label} ${message.values.dir}`;
|
|
877
|
+
case "views.panels.group-none":
|
|
878
|
+
return "None";
|
|
879
|
+
case "views.panels.filter-count":
|
|
880
|
+
if (message.values.count === 0)
|
|
881
|
+
return "None";
|
|
882
|
+
return message.values.count === 1 ? "1 filter" : `${message.values.count} filters`;
|
|
883
|
+
case "views.panels.direction":
|
|
884
|
+
return `Direction: ${message.values.dir === "asc" ? "ascending" : "descending"}`;
|
|
885
|
+
case "views.panels.toggle-reset":
|
|
886
|
+
return `Reset ${message.values.label}`;
|
|
887
|
+
case "views.panels.toggle-reset-hint":
|
|
888
|
+
return "Back to your default";
|
|
889
|
+
case "views.panels.search-clear":
|
|
890
|
+
return "Clear";
|
|
891
|
+
case "views.selection.count":
|
|
892
|
+
return `${message.values.count} selected`;
|
|
893
|
+
case "views.selection.selected":
|
|
894
|
+
return "selected";
|
|
895
|
+
case "views.selection.deselect-all":
|
|
896
|
+
return "Deselect all";
|
|
897
|
+
case "views.selection.clear":
|
|
898
|
+
return "Clear selection";
|
|
899
|
+
case "views.selection.delete":
|
|
900
|
+
return "Delete selected";
|
|
901
|
+
case "views.selection.more":
|
|
902
|
+
return "More";
|
|
903
|
+
case "views.selection.more-label":
|
|
904
|
+
return "More actions";
|
|
905
|
+
case "views.selection.actions":
|
|
906
|
+
return "Actions";
|
|
907
|
+
case "views.selection.sheet-label":
|
|
908
|
+
return "Selection actions";
|
|
909
|
+
case "views.selection.escape":
|
|
910
|
+
return "Esc";
|
|
734
911
|
}
|
|
735
912
|
}
|
package/dist/figures.d.ts
CHANGED
|
@@ -1,52 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A GROUP'S FIGURES, AS THE DATABASE COUNTED THEM (POR-470).
|
|
3
3
|
*
|
|
4
|
-
* A source list holds a page, not the list, so a footer or a group header that
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* footer pick the database can answer is read from them. Four, not one per
|
|
9
|
-
* pick: two parts' sums, counts, mins and maxes combine exactly, so a group
|
|
10
|
-
* folded from many discovery rows (the days of a week, a row under each of its
|
|
11
|
-
* tags) still answers an average, which a mean of the parts' means does not.
|
|
12
|
-
* Pure and free of the engine: the chassis reads it, the engine produces it.
|
|
13
|
-
*
|
|
14
|
-
* It imports NOTHING, not even a type: the source engine runs on the server,
|
|
15
|
-
* and the list model (`model/`) reaches browser modules — a type import is an
|
|
16
|
-
* edge the library ratchet follows (L004). So the footer picks are named here,
|
|
17
|
-
* and every caller hands a `ListAggregateKind`: a pick added there and not
|
|
18
|
-
* here fails the checker at the footer's call.
|
|
19
|
-
*/
|
|
20
|
-
/** The footer picks, as `model/column-schema.ts` names them (`ListAggregateKind`). */
|
|
21
|
-
export type FigureKind = "none" | "sum" | "avg" | "min" | "max" | "count" | "filled" | "unique" | "ratio";
|
|
22
|
-
export type ColumnFigure = {
|
|
23
|
-
sum: number | null;
|
|
24
|
-
count: number;
|
|
25
|
-
min: number | null;
|
|
26
|
-
max: number | null;
|
|
27
|
-
};
|
|
28
|
-
/** A group's — or the whole list's — figures: its rows, and each totalled key's figure. */
|
|
29
|
-
export type GroupFigures = {
|
|
30
|
-
rows: number;
|
|
31
|
-
fields: Record<string, ColumnFigure>;
|
|
32
|
-
};
|
|
33
|
-
export declare const EMPTY_FIGURE: ColumnFigure;
|
|
34
|
-
/** Two parts' figures as the figure of both. A null is a value absent, never a zero. */
|
|
35
|
-
export declare function combineFigure(a: ColumnFigure, b: ColumnFigure): ColumnFigure;
|
|
36
|
-
/** The figure of some values, a blank not counted. */
|
|
37
|
-
export declare function figureOf(values: readonly (number | null | undefined)[]): ColumnFigure;
|
|
38
|
-
/**
|
|
39
|
-
* The number a footer pick shows, or null for nothing to show. Follows the
|
|
40
|
-
* browser's own aggregate (`computeAggregate`): over no values, sum, avg, min
|
|
41
|
-
* and max are null; Count is the group's rows; Filled is the values present.
|
|
42
|
-
* Unique and Ratio are not the database's to answer.
|
|
43
|
-
*/
|
|
44
|
-
export declare function figureFor(kind: FigureKind, figures: GroupFigures, key: string): number | null;
|
|
45
|
-
/**
|
|
46
|
-
* A ratio formula's footer from its two parts' figures: sum over sum, as a
|
|
47
|
-
* percent (0–100), divided once — the browser's own `ratio` over the same
|
|
48
|
-
* rows. Null when either part was not totalled or the denominator is empty.
|
|
4
|
+
* A source list holds a page, not the list, so a footer or a group header that totals the rows in hand is wrong past
|
|
5
|
+
* the first page: it reads the figures the database answered for the whole group. Their shape and rules are
|
|
6
|
+
* `@viewkitjs/fields`' (the query entry's figures), which answers the same shape in memory, so the browser and a
|
|
7
|
+
* database are held to one answer. Re-exported here under the names the grid and the apps already read.
|
|
49
8
|
*/
|
|
50
|
-
export
|
|
51
|
-
/** Whether an answer's field is a `GroupFigures` — the hook hands a first page's own fields over untyped. */
|
|
52
|
-
export declare function isGroupFigures(value: unknown): value is GroupFigures;
|
|
9
|
+
export { EMPTY_FIGURE, combineFigure, figureFor, figureOf, isGroupFigures, ratioFigure, type ColumnFigure, type FigureKind, type GroupFigures, } from "@viewkitjs/fields/query";
|
package/dist/figures.js
CHANGED
|
@@ -1,63 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
function either(a, b, both) {
|
|
3
|
-
return a == null ? b : b == null ? a : both(a, b);
|
|
4
|
-
}
|
|
5
|
-
export function combineFigure(a, b) {
|
|
6
|
-
return {
|
|
7
|
-
sum: either(a.sum, b.sum, (x, y) => x + y),
|
|
8
|
-
count: a.count + b.count,
|
|
9
|
-
min: either(a.min, b.min, Math.min),
|
|
10
|
-
max: either(a.max, b.max, Math.max),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function figureOf(values) {
|
|
14
|
-
let figure = EMPTY_FIGURE;
|
|
15
|
-
for (const value of values) {
|
|
16
|
-
if (value == null || Number.isNaN(value))
|
|
17
|
-
continue;
|
|
18
|
-
figure = combineFigure(figure, { sum: value, count: 1, min: value, max: value });
|
|
19
|
-
}
|
|
20
|
-
return figure;
|
|
21
|
-
}
|
|
22
|
-
export function figureFor(kind, figures, key) {
|
|
23
|
-
if (kind === "none" || kind === "unique" || kind === "ratio")
|
|
24
|
-
return null;
|
|
25
|
-
if (kind === "count")
|
|
26
|
-
return figures.rows;
|
|
27
|
-
const figure = figures.fields[key];
|
|
28
|
-
if (!figure)
|
|
29
|
-
return null;
|
|
30
|
-
if (kind === "filled")
|
|
31
|
-
return figure.count;
|
|
32
|
-
if (figure.count === 0)
|
|
33
|
-
return null;
|
|
34
|
-
if (kind === "sum")
|
|
35
|
-
return figure.sum;
|
|
36
|
-
if (kind === "avg")
|
|
37
|
-
return figure.sum == null ? null : figure.sum / figure.count;
|
|
38
|
-
return kind === "min" ? figure.min : figure.max;
|
|
39
|
-
}
|
|
40
|
-
export function ratioFigure(figures, numerator, denominator) {
|
|
41
|
-
const num = figures.fields[numerator];
|
|
42
|
-
const den = figures.fields[denominator];
|
|
43
|
-
if (!num || !den)
|
|
44
|
-
return null;
|
|
45
|
-
const denominatorSum = den.sum ?? 0;
|
|
46
|
-
return denominatorSum > 0 ? Math.round(((num.sum ?? 0) / denominatorSum) * 100) : null;
|
|
47
|
-
}
|
|
48
|
-
const isFigure = (value) => !!value &&
|
|
49
|
-
typeof value === "object" &&
|
|
50
|
-
typeof value.count === "number" &&
|
|
51
|
-
["sum", "min", "max"].every((part) => {
|
|
52
|
-
const at = value[part];
|
|
53
|
-
return at === null || typeof at === "number";
|
|
54
|
-
});
|
|
55
|
-
export function isGroupFigures(value) {
|
|
56
|
-
if (!value || typeof value !== "object")
|
|
57
|
-
return false;
|
|
58
|
-
const { rows, fields } = value;
|
|
59
|
-
return (typeof rows === "number" &&
|
|
60
|
-
!!fields &&
|
|
61
|
-
typeof fields === "object" &&
|
|
62
|
-
Object.values(fields).every(isFigure));
|
|
63
|
-
}
|
|
1
|
+
export { EMPTY_FIGURE, combineFigure, figureFor, figureOf, isGroupFigures, ratioFigure, } from "@viewkitjs/fields/query";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MouseEvent as ReactMouseEvent, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
2
|
import type { PercentDisplay } from "@viewkitjs/fields";
|
|
3
|
-
import type {
|
|
3
|
+
import type { SortDirection } from "@viewkitjs/fields/query";
|
|
4
4
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
5
5
|
import type { ListDateStyle, ListDurationStyle, ListNumberFormatState } from "../../model/column-format.js";
|
|
6
6
|
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
@@ -17,10 +17,10 @@ type TriggerProps = {
|
|
|
17
17
|
* remote control for the SAME persisted sort the view-options popover drives. */
|
|
18
18
|
export type GridSortState = {
|
|
19
19
|
value: string;
|
|
20
|
-
dir:
|
|
20
|
+
dir: SortDirection;
|
|
21
21
|
onChange: (next: {
|
|
22
22
|
value: string;
|
|
23
|
-
dir:
|
|
23
|
+
dir: SortDirection;
|
|
24
24
|
}) => void;
|
|
25
25
|
};
|
|
26
26
|
/** The view's group, as the header asks it: which field, and a writer that
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SortDirection } from "@viewkitjs/fields/query";
|
|
2
2
|
/**
|
|
3
3
|
* The sort rows in the header menu — ascending, descending, and Clear sort
|
|
4
4
|
* while this column IS the sort. Split out of GridColumnMenu for the line
|
|
@@ -9,10 +9,10 @@ export declare function GridColumnSortSection({ sortKey, value, dir, onChange, o
|
|
|
9
9
|
sortKey: string;
|
|
10
10
|
/** The list's current sort key and direction. */
|
|
11
11
|
value: string;
|
|
12
|
-
dir:
|
|
12
|
+
dir: SortDirection;
|
|
13
13
|
onChange: (next: {
|
|
14
14
|
value: string;
|
|
15
|
-
dir:
|
|
15
|
+
dir: SortDirection;
|
|
16
16
|
}) => void;
|
|
17
17
|
onClose: () => void;
|
|
18
18
|
}): import("react/jsx-runtime").JSX.Element;
|