viewkitjs 0.19.0 → 0.21.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/MIGRATION.md +117 -0
  3. package/README.md +7 -3
  4. package/fields/README.md +3 -3
  5. package/fields/dist/derived.d.ts +4 -0
  6. package/fields/dist/derived.js +39 -0
  7. package/fields/dist/entities.js +30 -30
  8. package/fields/dist/formula.js +2 -2
  9. package/fields/dist/query/evaluate.js +5 -5
  10. package/fields/dist/query/figures.js +5 -5
  11. package/fields/dist/query/filter.d.ts +15 -0
  12. package/fields/dist/query/filter.js +85 -0
  13. package/fields/dist/query/hold.js +2 -2
  14. package/fields/dist/query/option-counts.js +2 -2
  15. package/fields/dist/query/read-rule.js +2 -2
  16. package/fields/dist/query/search.js +2 -2
  17. package/fields/dist/query/set-aside.js +4 -4
  18. package/fields/dist/query/settings.d.ts +2 -15
  19. package/fields/dist/query/settings.js +3 -81
  20. package/fields/dist/query/sort.js +4 -4
  21. package/fields/dist/registry.d.ts +19 -5
  22. package/fields/dist/registry.js +371 -50
  23. package/fields/dist/types.d.ts +1 -1
  24. package/fields/docs/getting-started.md +2 -2
  25. package/fields/docs/guides/checking-definitions.md +17 -4
  26. package/fields/docs/guides/derived-fields.md +5 -5
  27. package/fields/docs/guides/queries.md +1 -1
  28. package/fields/docs/reference/design-category-colors.md +1 -1
  29. package/fields/docs/reference/design-status-slots.md +1 -1
  30. package/fields/docs/reference/fields.md +3 -3
  31. package/fields/docs/reference/query.md +1 -0
  32. package/fields/skills/viewkit/SKILL.md +2 -2
  33. package/package.json +17 -6
  34. package/postgres/README.md +2 -2
  35. package/postgres/dist/access.d.ts +12 -4
  36. package/postgres/dist/access.js +3 -0
  37. package/postgres/dist/calendar.js +3 -2
  38. package/postgres/dist/check.d.ts +6 -4
  39. package/postgres/dist/check.js +27 -16
  40. package/postgres/dist/counts.js +3 -2
  41. package/postgres/dist/definitions/build.js +7 -0
  42. package/postgres/dist/definitions/formula.d.ts +1 -1
  43. package/postgres/dist/definitions/formula.js +5 -3
  44. package/postgres/dist/definitions/lookup.js +5 -1
  45. package/postgres/dist/definitions/money.js +6 -1
  46. package/postgres/dist/definitions/place.d.ts +7 -0
  47. package/postgres/dist/definitions/place.js +8 -0
  48. package/postgres/dist/definitions/relations.js +36 -3
  49. package/postgres/dist/definitions/rollup.d.ts +1 -1
  50. package/postgres/dist/definitions/rollup.js +11 -6
  51. package/postgres/dist/field-values.js +11 -8
  52. package/postgres/dist/figures.js +4 -2
  53. package/postgres/dist/filled.js +2 -2
  54. package/postgres/dist/groups.d.ts +2 -1
  55. package/postgres/dist/groups.js +5 -3
  56. package/postgres/dist/index.d.ts +1 -0
  57. package/postgres/dist/index.js +1 -0
  58. package/postgres/dist/kept.js +8 -4
  59. package/postgres/dist/lanes.js +5 -3
  60. package/postgres/dist/phone.js +2 -2
  61. package/postgres/dist/predicates.js +2 -2
  62. package/postgres/dist/readable.d.ts +40 -0
  63. package/postgres/dist/readable.js +84 -0
  64. package/postgres/dist/records.js +7 -4
  65. package/postgres/dist/refusals.d.ts +8 -1
  66. package/postgres/dist/refusals.js +7 -0
  67. package/postgres/dist/relations.js +5 -4
  68. package/postgres/dist/search-indexes.js +2 -1
  69. package/postgres/dist/search.js +6 -4
  70. package/postgres/dist/several.js +8 -8
  71. package/postgres/dist/sort.d.ts +5 -3
  72. package/postgres/dist/sort.js +13 -8
  73. package/postgres/dist/value-rows.js +2 -2
  74. package/postgres/dist/values.js +4 -2
  75. package/postgres/docs/guides/definitions.md +2 -2
  76. package/postgres/docs/guides/field-map.md +43 -18
  77. package/postgres/docs/guides/test-kit.md +2 -0
  78. package/postgres/docs/reference/postgres.md +10 -4
  79. package/views/README.md +4 -2
  80. package/views/dist/atoms/StatusBadge.js +1 -1
  81. package/views/dist/atoms/tones.js +7 -7
  82. package/views/dist/atoms/types.d.ts +3 -2
  83. package/views/dist/contract.d.ts +7 -2
  84. package/views/dist/contract.js +33 -0
  85. package/views/dist/display/fit-values.d.ts +3 -2
  86. package/views/dist/display/link.d.ts +1 -1
  87. package/views/dist/display/location.js +2 -1
  88. package/views/dist/display/multi-value.js +1 -1
  89. package/views/dist/display/name.js +3 -1
  90. package/views/dist/display/select.js +1 -1
  91. package/views/dist/display/value-list.d.ts +1 -1
  92. package/views/dist/grid/chrome/GridStructure.js +2 -1
  93. package/views/dist/grid/looks.d.ts +45 -0
  94. package/views/dist/grid/looks.js +74 -0
  95. package/views/dist/looks/index.d.ts +7 -0
  96. package/views/dist/looks/index.js +3 -0
  97. package/views/dist/looks/looks.d.ts +46 -0
  98. package/views/dist/looks/looks.js +25 -0
  99. package/views/dist/looks/pieces.d.ts +3 -0
  100. package/views/dist/looks/pieces.js +2 -0
  101. package/views/dist/provider/ViewsProvider.d.ts +3 -3
  102. package/views/dist/provider/ViewsProvider.js +1 -1
  103. package/views/dist/provider/context.d.ts +1 -1
  104. package/views/dist/styles.css +3277 -0
  105. package/views/dist/styles.unlayered.css +3276 -0
  106. package/views/docs/contract.md +61 -13
  107. package/views/docs/getting-started.md +1 -1
  108. package/views/docs/guides/display.md +11 -7
  109. package/views/docs/guides/looks.md +29 -0
  110. package/views/docs/guides/the-grid.md +1 -1
  111. package/views/docs/guides/the-provider.md +1 -1
  112. package/views/docs/index.md +2 -0
  113. package/views/docs/install.md +36 -9
  114. package/views/docs/reference/display.md +2 -2
  115. package/views/docs/reference/looks.md +31 -0
  116. package/views/docs/reference/react.md +2 -2
  117. package/views/docs/reference/views.md +1 -1
  118. package/views/skills/views/SKILL.md +2 -2
@@ -18,11 +18,11 @@ export const STATUS_DOT = {
18
18
  };
19
19
  export const TAG_TONE = {
20
20
  gray: "bg-(color:--vk-neutral) text-(color:--vk-fg-subtle)",
21
- blue: "bg-[color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_12%,var(--vk-ground))] text-[var(--vk-label-blue,hsl(199_89%_48%))]",
22
- green: "bg-[color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_12%,var(--vk-ground))] text-[var(--vk-label-green,hsl(160_84%_39%))]",
23
- amber: "bg-[color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_12%,var(--vk-ground))] text-[var(--vk-label-amber,hsl(38_92%_50%))]",
24
- red: "bg-[color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_12%,var(--vk-ground))] text-[var(--vk-label-red,hsl(0_84%_60%))]",
25
- purple: "bg-[color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_12%,var(--vk-ground))] text-[var(--vk-label-purple,hsl(258_90%_66%))]",
26
- pink: "bg-[color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_12%,var(--vk-ground))] text-[var(--vk-label-pink,hsl(330_81%_60%))]",
27
- teal: "bg-[color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_12%,var(--vk-ground))] text-[var(--vk-label-teal,hsl(173_80%_40%))]",
21
+ blue: "bg-[var(--vk-label-blue-fill,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-blue-edge,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_40%,var(--vk-ground)))] text-[var(--vk-label-blue-strong,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_60%,var(--vk-fg)))]",
22
+ green: "bg-[var(--vk-label-green-fill,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-green-edge,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_40%,var(--vk-ground)))] text-[var(--vk-label-green-strong,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_60%,var(--vk-fg)))]",
23
+ amber: "bg-[var(--vk-label-amber-fill,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-amber-edge,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_40%,var(--vk-ground)))] text-[var(--vk-label-amber-strong,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_60%,var(--vk-fg)))]",
24
+ red: "bg-[var(--vk-label-red-fill,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-red-edge,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_40%,var(--vk-ground)))] text-[var(--vk-label-red-strong,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_60%,var(--vk-fg)))]",
25
+ purple: "bg-[var(--vk-label-purple-fill,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-purple-edge,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_40%,var(--vk-ground)))] text-[var(--vk-label-purple-strong,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_60%,var(--vk-fg)))]",
26
+ pink: "bg-[var(--vk-label-pink-fill,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-pink-edge,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_40%,var(--vk-ground)))] text-[var(--vk-label-pink-strong,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_60%,var(--vk-fg)))]",
27
+ teal: "bg-[var(--vk-label-teal-fill,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-teal-edge,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_40%,var(--vk-ground)))] text-[var(--vk-label-teal-strong,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_60%,var(--vk-fg)))]",
28
28
  };
@@ -98,8 +98,9 @@ export type ViewsStatusBadgeProps = {
98
98
  /** Replaces the slot's own mark. */
99
99
  leading?: ReactNode;
100
100
  title?: string;
101
- /** Default `compact` (11px), the size a status value is drawn at in a cell. */
102
- size?: "compact" | "regular";
101
+ /** Default `compact` (11px). `row`: the text size of the row it sits in, its dot as compact's: what a cell's
102
+ * status value hands, which an app's own badge should honour. */
103
+ size?: "compact" | "regular" | "row";
103
104
  className?: string;
104
105
  };
105
106
  export type ViewsStatusMarkerProps = {
@@ -37,8 +37,13 @@ export type VkColour = (typeof VK_COLOURS)[number];
37
37
  * pointer or while editing (undeclared, `--vk-border-brand`). `--vk-selection-edge` is a picked row's lines
38
38
  * (undeclared, `--vk-brand`). `--vk-frozen-shadow` is the colour the pinned edge's shadow fades from (undeclared,
39
39
  * black at 15%, 60% in the dark). `--vk-editing-shadow` is the open editor's lift, a whole `box-shadow` value
40
- * (undeclared, Tailwind's `shadow-lg` in black at 20%, 50% in the dark). */
41
- 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", "--vk-focus-ring", "--vk-outline-hover-shadow", "--vk-editing-shadow", "--vk-frozen-shadow", "--vk-selected", "--vk-outline", "--vk-outline-active", "--vk-outline-hover", "--vk-selection-edge", "--vk-head-glyph-fg"];
40
+ * (undeclared, Tailwind's `shadow-lg` in black at 20%, 50% in the dark).
41
+ * The status washes (`--vk-success-subtlest`, `--vk-warning-subtlest`, `--vk-info-subtlest`), the words on a
42
+ * filled status (`--vk-fg-inverse`, `--vk-fg-warning-inverse`) and each hue's pale ground (`--vk-label-blue-soft` and
43
+ * the six others) are what fields' class names draw under the stylesheet (VK-769). Each hue's `-fill`, `-edge` and `-strong` are the
44
+ * default Tag's pill: its fill, its edge drawn inside and its words (VK-733); undeclared, the hue 15% and 40% into
45
+ * `--vk-ground` and 60% into `--vk-fg`, so an app that declares only its hue keeps it. */
46
+ export declare const VK_OPTIONAL_COLOURS: readonly ["--vk-success", "--vk-warning", "--vk-info", "--vk-success-subtlest", "--vk-warning-subtlest", "--vk-info-subtlest", "--vk-fg-inverse", "--vk-fg-warning-inverse", "--vk-label-blue", "--vk-label-blue-soft", "--vk-label-blue-fill", "--vk-label-blue-edge", "--vk-label-blue-strong", "--vk-label-green", "--vk-label-green-soft", "--vk-label-green-fill", "--vk-label-green-edge", "--vk-label-green-strong", "--vk-label-amber", "--vk-label-amber-soft", "--vk-label-amber-fill", "--vk-label-amber-edge", "--vk-label-amber-strong", "--vk-label-red", "--vk-label-red-soft", "--vk-label-red-fill", "--vk-label-red-edge", "--vk-label-red-strong", "--vk-label-purple", "--vk-label-purple-soft", "--vk-label-purple-fill", "--vk-label-purple-edge", "--vk-label-purple-strong", "--vk-label-pink", "--vk-label-pink-soft", "--vk-label-pink-fill", "--vk-label-pink-edge", "--vk-label-pink-strong", "--vk-label-teal", "--vk-label-teal-soft", "--vk-label-teal-fill", "--vk-label-teal-edge", "--vk-label-teal-strong", "--vk-float-shadow", "--vk-focus-ring", "--vk-outline-hover-shadow", "--vk-editing-shadow", "--vk-frozen-shadow", "--vk-selected", "--vk-outline", "--vk-outline-active", "--vk-outline-hover", "--vk-selection-edge", "--vk-head-glyph-fg"];
42
47
  export type VkOptionalColour = (typeof VK_OPTIONAL_COLOURS)[number];
43
48
  /** Layout the APP may declare, read with a built-in fallback. `--vk-gutter` is the side padding the
44
49
  * page gives its content: the grid's rows run edge to edge and line their content up with it.
@@ -116,13 +116,46 @@ export const VK_OPTIONAL_COLOURS = [
116
116
  "--vk-success",
117
117
  "--vk-warning",
118
118
  "--vk-info",
119
+ "--vk-success-subtlest",
120
+ "--vk-warning-subtlest",
121
+ "--vk-info-subtlest",
122
+ "--vk-fg-inverse",
123
+ "--vk-fg-warning-inverse",
119
124
  "--vk-label-blue",
125
+ "--vk-label-blue-soft",
126
+ "--vk-label-blue-fill",
127
+ "--vk-label-blue-edge",
128
+ "--vk-label-blue-strong",
120
129
  "--vk-label-green",
130
+ "--vk-label-green-soft",
131
+ "--vk-label-green-fill",
132
+ "--vk-label-green-edge",
133
+ "--vk-label-green-strong",
121
134
  "--vk-label-amber",
135
+ "--vk-label-amber-soft",
136
+ "--vk-label-amber-fill",
137
+ "--vk-label-amber-edge",
138
+ "--vk-label-amber-strong",
122
139
  "--vk-label-red",
140
+ "--vk-label-red-soft",
141
+ "--vk-label-red-fill",
142
+ "--vk-label-red-edge",
143
+ "--vk-label-red-strong",
123
144
  "--vk-label-purple",
145
+ "--vk-label-purple-soft",
146
+ "--vk-label-purple-fill",
147
+ "--vk-label-purple-edge",
148
+ "--vk-label-purple-strong",
124
149
  "--vk-label-pink",
150
+ "--vk-label-pink-soft",
151
+ "--vk-label-pink-fill",
152
+ "--vk-label-pink-edge",
153
+ "--vk-label-pink-strong",
125
154
  "--vk-label-teal",
155
+ "--vk-label-teal-soft",
156
+ "--vk-label-teal-fill",
157
+ "--vk-label-teal-edge",
158
+ "--vk-label-teal-strong",
126
159
  "--vk-float-shadow",
127
160
  "--vk-focus-ring",
128
161
  "--vk-outline-hover-shadow",
@@ -5,8 +5,9 @@
5
5
  * edge, and the room the count needs. From then on a change of its width is arithmetic over what it kept,
6
6
  * so a column resize reads nothing from the page and draws again only the cells whose number changed.
7
7
  */
8
- /** How a cell of several values draws on one line (`ViewsProvider`'s `severalValues`). `first`: its first
9
- * value and a count, at any width, as on 0.5.0. `fit`: as many whole values as fit its width, then a count. */
8
+ /** How a cell of several values draws on one line (`ViewsProvider`'s `severalValues`). `fit` (the default):
9
+ * as many whole values as fit its width, then a count. `first`: its first value and a count, at any
10
+ * width, as on 0.5.0. */
10
11
  export type ViewsSeveralValues = "first" | "fit";
11
12
  /** The most values drawn to be measured: no column fits more, and a cell of 200 records doesn't draw 200
12
13
  * chips to find out. */
@@ -11,7 +11,7 @@ import type { DisplayOptions } from "./options.js";
11
11
  * A value that is no link (`webHref`) draws as its text. Its platform
12
12
  * (`linkPlatform`, read with the host's conventions) goes to the app's
13
13
  * `PlatformMark`, drawn before it; the default draws nothing, so a link looks
14
- * plain. Several links draw as their main one and a count (`renderValueList`).
14
+ * plain. Several links draw the main one first, as many as fit, then a count (`renderValueList`).
15
15
  */
16
16
  export declare function renderUrl(_field: FieldDefOf<"url">, value: unknown, opts?: DisplayOptions): ReactNode;
17
17
  /**
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { locationShort, locationText } from "viewkitjs/fields";
4
4
  import { MultiValueCell } from "./multi-value.js";
5
+ import { cellTextClass } from "./text-class.js";
5
6
  import { useDisplayOptions } from "./use-display-options.js";
6
7
  export function renderLocation(field, value, opts) {
7
8
  void field;
@@ -18,5 +19,5 @@ function PlaceValue({ value, opts: given }) {
18
19
  const places = value.map((place) => write(place, locale)).filter(Boolean);
19
20
  return (_jsx(MultiValueCell, { items: places, wrap: !!opts.wrap, title: places.join(", "), slotOwnsClick: opts.slotOwnsClick }));
20
21
  }
21
- return write(value, locale);
22
+ return _jsx("span", { className: cellTextClass(opts.wrap), children: write(value, locale) });
22
23
  }
@@ -18,7 +18,7 @@ export function MultiValueCell({ items, details, wrap, title, slotOwnsClick, })
18
18
  const [open, setOpen] = useState(false);
19
19
  const anchor = useRef(null);
20
20
  const trigger = useRef(null);
21
- const fit = severalValues === "fit" && !wrap && items.length > 1;
21
+ const fit = severalValues !== "first" && !wrap && items.length > 1;
22
22
  const key = `${items.length}\u0000${title ?? ""}`;
23
23
  const keyRef = useRef(key);
24
24
  useLayoutEffect(() => {
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { nameText } from "viewkitjs/fields";
4
4
  import { MultiValueCell } from "./multi-value.js";
5
+ import { cellTextClass } from "./text-class.js";
5
6
  export function renderName(field, value, opts) {
6
7
  void field;
7
8
  if (Array.isArray(value)) {
@@ -10,5 +11,6 @@ export function renderName(field, value, opts) {
10
11
  return opts?.nameFallback || null;
11
12
  return (_jsx(MultiValueCell, { items: names, wrap: !!opts?.wrap, title: names.join(", "), slotOwnsClick: opts?.slotOwnsClick }));
12
13
  }
13
- return nameText(value) || opts?.nameFallback || null;
14
+ const text = nameText(value) || opts?.nameFallback;
15
+ return text ? _jsx("span", { className: cellTextClass(opts?.wrap), children: text }) : null;
14
16
  }
@@ -32,7 +32,7 @@ function StrayOption({ value }) {
32
32
  }
33
33
  function OptionStatus({ slot, label, icon, place, }) {
34
34
  const { atoms: { StatusBadge }, components: { AppIcon }, } = useViews();
35
- return (_jsx(StatusBadge, { slot: slot, label: label, place: place, className: "border-0", leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined }));
35
+ return (_jsx(StatusBadge, { slot: slot, label: label, place: place, size: "row", className: "border-0", leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined }));
36
36
  }
37
37
  function OptionCategory({ label, color, icon }) {
38
38
  const { atoms: { Tag }, components: { AppIcon }, } = useViews();
@@ -3,7 +3,7 @@ import type { DisplayOptions } from "./options.js";
3
3
  /**
4
4
  * Several values of one kind (VK-58's `{ value, label, main }`, or a plain list read as items, the first main):
5
5
  * the main one first and the rest in stored order, each drawn by its type's own renderer for one value. The cell
6
- * shows the main one and a count; each value's label is drawn beside it behind the count, never in the cell.
6
+ * shows as many as fit, the main one first, then a count; each value's label is drawn beside it behind the count, never in the cell.
7
7
  */
8
8
  export declare function renderValueList(value: unknown[], one: (value: unknown) => ReactNode, opts?: DisplayOptions,
9
9
  /** One value as plain text, for the native hover. */
@@ -12,6 +12,7 @@ import { GridGroupMenu } from "./GridGroupMenu.js";
12
12
  import { groupMenuParts } from "./grid-group-menu-parts.js";
13
13
  import { GRID_CHROME_FOCUS, GRID_ROW_PAD } from "./grid-styles.js";
14
14
  import { GridRowsSlotContext } from "./grid-wait.js";
15
+ const GROUP_COUNT_CHIP = "ml-2 inline-flex h-6 min-w-6 items-center justify-center rounded-sm bg-(color:--vk-neutral) px-1.5 text-(color:--vk-fg-subtle) tabular-nums";
15
16
  function GridRowsSlot({ children }) {
16
17
  const slot = useContext(GridRowsSlotContext);
17
18
  if (!slot)
@@ -60,7 +61,7 @@ function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks
60
61
  "aria-expanded": !collapsed,
61
62
  onClick: () => onToggleGroup?.(group.key),
62
63
  children: _jsx(Caret, { className: "h-(--vk-glyph) w-(--vk-glyph)" }),
63
- }), _jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem-(1.5rem-var(--vk-glyph))/2)] truncate text-(length:--vk-text) font-medium", children: renderGroupLabel?.(group) ?? group.label ?? "—" }), parts.length > 0 && (_jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem)] flex min-w-0 items-baseline gap-1.5 overflow-hidden text-(length:--vk-text) text-(color:--vk-fg-subtle) tabular-nums", children: parts.map((part) => (_jsxs("span", { className: "flex items-baseline gap-1.5 whitespace-nowrap", children: [_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-group-dot", "data-part": part.key, className: "text-(color:--vk-fg-subtlest)", children: "\u00B7" }), part.key === "count" ? (_jsx("span", { "data-slot": "vk-grid-group-count", "data-part": part.key, children: part.node })) : (_jsx("span", { "data-slot": "vk-grid-group-figure", "data-part": part.key, children: part.node }))] }, part.key))) })), groupMenuParts({
64
+ }), _jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem-(1.5rem-var(--vk-glyph))/2)] truncate text-(length:--vk-text) font-medium", children: renderGroupLabel?.(group) ?? group.label ?? "—" }), parts.length > 0 && (_jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem)] flex min-w-0 items-baseline gap-1.5 overflow-hidden text-(length:--vk-text) text-(color:--vk-fg-subtle) tabular-nums", children: parts.map((part) => (_jsx("span", { className: "flex items-baseline gap-1.5 whitespace-nowrap", children: part.key === "count" ? (_jsx("span", { "data-slot": "vk-grid-group-count", "data-part": part.key, className: GROUP_COUNT_CHIP, children: part.node })) : (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-group-dot", "data-part": part.key, className: "text-(color:--vk-fg-subtlest)", children: "\u00B7" }), _jsx("span", { "data-slot": "vk-grid-group-figure", "data-part": part.key, children: part.node })] })) }, part.key))) })), groupMenuParts({
64
65
  groupMenu,
65
66
  hasSort: !!sort,
66
67
  sortCount: sortOptions?.length ?? 0,
@@ -0,0 +1,45 @@
1
+ import type { GridGroupMenuPart } from "./chrome/grid-group-menu-parts.js";
2
+ import { type LookPicks, type PieceLooks } from "../looks/looks.js";
3
+ export type GridLookOptionId = "header" | "lines" | "columns" | "density" | "phone" | "name" | "edge" | "boxes" | "icon" | "picked" | "cell" | "corners" | "hover" | "frame" | "groups" | "names" | "phones" | "typed" | "figures" | "width" | "more" | "wait" | "foot" | "add" | "picking";
4
+ /** The grid's options and its two looks, attio (every option's default) and portal. */
5
+ export declare const GRID_LOOKS: PieceLooks<GridLookOptionId>;
6
+ /** What the grid's code reads of its options; the rest are its look stylesheet's alone. */
7
+ export type GridLookWorn = {
8
+ columns: "all" | "none" | "pinned";
9
+ density: "compact" | "default" | "roomy";
10
+ phone: "attio" | "computer";
11
+ name: "pinned" | "scrolls";
12
+ boxes: "hover" | "always";
13
+ icon: "on" | "off";
14
+ groups: "compact" | "titles";
15
+ figures: "value" | "word";
16
+ width: "own" | "fill";
17
+ more: "scroll" | "pages";
18
+ wait: "kept" | "cleared";
19
+ foot: "pinned" | "rows";
20
+ add: "name" | "end";
21
+ picking: "press" | "rail";
22
+ };
23
+ /** The options the grid's code reads, in this order. */
24
+ export declare const GRID_LOOK_READ: readonly (keyof GridLookWorn)[];
25
+ /** What the grid's code reads, from a set of picks; a pick left out, or one its option doesn't have, its default. */
26
+ export declare function gridLookWorn(picks?: LookPicks<GridLookOptionId>): GridLookWorn;
27
+ /** The same, from the closest frame round `el` carrying each `data-grid-<option>`; outside any frame, the defaults. */
28
+ export declare function gridLookWornOf(el: Element | null): GridLookWorn;
29
+ /** The GridTable props a look sets. */
30
+ export type GridLookProps = {
31
+ verticalBorders: boolean;
32
+ headerVerticalBorders: boolean;
33
+ scale: number;
34
+ freezeIdentity: boolean;
35
+ alwaysCheckboxes: boolean;
36
+ showRowIcon: boolean;
37
+ oneHeader: boolean;
38
+ groupMenu: GridGroupMenuPart[];
39
+ fillWidth: boolean;
40
+ pinFooter: boolean;
41
+ addColumnAt: "end" | "title";
42
+ phonePicking: boolean;
43
+ };
44
+ /** What a worn look hands GridTable, on a phone or a computer. */
45
+ export declare function gridLookProps(worn: GridLookWorn, phone: boolean): GridLookProps;
@@ -0,0 +1,74 @@
1
+ import { lookWorn, lookWornOf } from "../looks/looks.js";
2
+ const options = [
3
+ { id: "header", name: "Header", device: "desktop", def: "words", values: [{ id: "words", name: "Words" }, { id: "quiet", name: "Quiet" }] },
4
+ { id: "lines", name: "Row lines", def: "on", values: [{ id: "on", name: "On" }, { id: "off", name: "Off" }] },
5
+ { id: "columns", name: "Column lines", def: "pinned", values: [{ id: "all", name: "All" }, { id: "none", name: "None" }, { id: "pinned", name: "Pinned only" }] },
6
+ { id: "density", name: "Density", def: "default", values: [{ id: "compact", name: "Compact" }, { id: "default", name: "Default" }, { id: "roomy", name: "Roomy" }] },
7
+ { id: "phone", name: "Size", device: "phone", def: "attio", values: [{ id: "attio", name: "Attio's" }, { id: "computer", name: "The computer's" }] },
8
+ { id: "name", name: "Name column", def: "pinned", values: [{ id: "pinned", name: "Pinned" }, { id: "scrolls", name: "Scrolls" }] },
9
+ { id: "edge", name: "Pinned edge", def: "fade", values: [{ id: "shadow", name: "Shadow" }, { id: "fade", name: "Fade" }, { id: "line", name: "Line" }, { id: "divider", name: "Divider" }, { id: "mask", name: "Fade out" }] },
10
+ { id: "boxes", name: "Checkboxes", def: "hover", values: [{ id: "hover", name: "On hover" }, { id: "always", name: "Always" }] },
11
+ { id: "icon", name: "Row icon", def: "on", values: [{ id: "on", name: "On" }, { id: "off", name: "Off" }] },
12
+ { id: "picked", name: "Picked rows", def: "tint", values: [{ id: "tint", name: "Tint" }, { id: "line", name: "Tint and line" }] },
13
+ { id: "cell", name: "Picked cell", def: "wash", values: [{ id: "wash", name: "Wash" }, { id: "ring", name: "Ring" }] },
14
+ { id: "corners", name: "Cell corners", def: "square", values: [{ id: "square", name: "Square" }, { id: "round", name: "Round" }] },
15
+ { id: "hover", name: "Hover frame", def: "subtle", values: [{ id: "none", name: "None" }, { id: "subtle", name: "Subtle" }, { id: "strong", name: "Strong" }] },
16
+ { id: "frame", name: "Picked cell frame", def: "brand", values: [{ id: "brand", name: "Brand" }, { id: "neutral", name: "Neutral" }] },
17
+ { id: "groups", name: "Groups", def: "compact", values: [{ id: "compact", name: "Compact" }, { id: "titles", name: "Own titles" }] },
18
+ { id: "names", name: "Names", def: "underline", values: [{ id: "underline", name: "Underlined" }, { id: "hover", name: "On hover" }] },
19
+ { id: "phones", name: "Phones", def: "link", values: [{ id: "link", name: "Link" }, { id: "text", name: "As text" }] },
20
+ { id: "typed", name: "Phones as typed", def: "dotted", values: [{ id: "none", name: "None" }, { id: "dotted", name: "Dotted line" }, { id: "subtle", name: "Subtle" }, { id: "dot", name: "Dot" }, { id: "tint", name: "Tinted" }] },
21
+ { id: "figures", name: "Figures", def: "value", values: [{ id: "value", name: "Value first" }, { id: "word", name: "Word first" }] },
22
+ { id: "width", name: "Width", def: "own", values: [{ id: "own", name: "The columns' own" }, { id: "fill", name: "Fill" }] },
23
+ { id: "more", name: "More rows", def: "scroll", values: [{ id: "scroll", name: "As you scroll" }, { id: "pages", name: "In pages" }] },
24
+ { id: "wait", name: "Rows changing", def: "kept", values: [{ id: "kept", name: "Kept" }, { id: "cleared", name: "Cleared" }] },
25
+ { id: "foot", name: "Footer", device: "phone", def: "pinned", values: [{ id: "pinned", name: "At the foot" }, { id: "rows", name: "After the rows" }] },
26
+ { id: "add", name: "Add column", device: "phone", def: "name", values: [{ id: "name", name: "In the name's header" }, { id: "end", name: "At the end" }] },
27
+ { id: "picking", name: "Picking rows", device: "phone", def: "press", values: [{ id: "press", name: "Long press" }, { id: "rail", name: "In the rail" }] },
28
+ ];
29
+ const defs = Object.fromEntries(options.map((o) => [o.id, o.def]));
30
+ export const GRID_LOOKS = {
31
+ id: "grid",
32
+ name: "Grid",
33
+ options,
34
+ looks: [
35
+ { id: "attio", name: "Attio", picks: { ...defs } },
36
+ {
37
+ id: "portal",
38
+ name: "The portal's",
39
+ picks: {
40
+ header: "quiet", lines: "on", columns: "all", density: "default", phone: "computer", name: "pinned", edge: "shadow",
41
+ boxes: "hover", icon: "off", picked: "line", cell: "ring", corners: "square", hover: "strong", frame: "brand",
42
+ groups: "titles", names: "hover", phones: "text", typed: "subtle", figures: "word", width: "own", more: "scroll",
43
+ wait: "kept", foot: "rows", add: "end", picking: "rail",
44
+ },
45
+ },
46
+ ],
47
+ };
48
+ export const GRID_LOOK_READ = [
49
+ "columns", "density", "phone", "name", "boxes", "icon", "groups", "figures", "width", "more", "wait", "foot", "add", "picking",
50
+ ];
51
+ export function gridLookWorn(picks) {
52
+ return lookWorn(GRID_LOOKS, picks, GRID_LOOK_READ);
53
+ }
54
+ export function gridLookWornOf(el) {
55
+ return lookWornOf(GRID_LOOKS, el, GRID_LOOK_READ);
56
+ }
57
+ const SCALE = { compact: 0.85, default: 1, roomy: 1.15 };
58
+ const PHONE = 1.25;
59
+ export function gridLookProps(worn, phone) {
60
+ return {
61
+ verticalBorders: worn.columns === "all",
62
+ headerVerticalBorders: worn.columns === "all",
63
+ scale: SCALE[worn.density] * (phone && worn.phone === "attio" ? PHONE : 1),
64
+ freezeIdentity: worn.name === "pinned",
65
+ alwaysCheckboxes: worn.boxes === "always",
66
+ showRowIcon: worn.icon === "on",
67
+ oneHeader: worn.groups === "compact",
68
+ groupMenu: worn.groups === "compact" ? ["select", "sort"] : ["sort"],
69
+ fillWidth: worn.width === "fill",
70
+ pinFooter: phone && worn.foot === "pinned",
71
+ addColumnAt: phone && worn.add === "name" ? "title" : "end",
72
+ phonePicking: phone && worn.picking === "press",
73
+ };
74
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A PIECE'S LOOKS. Each piece's options and looks, declared beside the piece, and the helpers that wear one:
3
+ * the frame's `data-<piece>-<option>` attributes and the values read back from them. No React.
4
+ */
5
+ export { lookAttrs, lookPicks, lookWorn, lookWornOf, type Look, type LookDevice, type LookOption, type LookPicks, type LookValue, type PieceLooks, } from "./looks.js";
6
+ export { LOOKS } from "./pieces.js";
7
+ export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, type GridLookOptionId, type GridLookProps, type GridLookWorn, } from "../grid/looks.js";
@@ -0,0 +1,3 @@
1
+ export { lookAttrs, lookPicks, lookWorn, lookWornOf, } from "./looks.js";
2
+ export { LOOKS } from "./pieces.js";
3
+ export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, } from "../grid/looks.js";
@@ -0,0 +1,46 @@
1
+ /** The device an option or a look is for, when it is for one: nothing means both. */
2
+ export type LookDevice = "phone" | "desktop";
3
+ /** One value an option can hold. */
4
+ export type LookValue = {
5
+ readonly id: string;
6
+ readonly name: string;
7
+ };
8
+ /** One option of a piece: its id is public, as are its values' ids. */
9
+ export type LookOption<Id extends string = string> = {
10
+ readonly id: Id;
11
+ readonly name: string;
12
+ /** The value worn when nothing is picked, or when the pick is a value the option doesn't have. */
13
+ readonly def: string;
14
+ readonly device?: LookDevice;
15
+ /** How a picker draws it: "steps" for an ordered scale, "list" for a long list. Nothing means chips. */
16
+ readonly kind?: "steps" | "list";
17
+ /** Means nothing while that option holds that value, or one of several. */
18
+ readonly unless?: readonly [Id, string | readonly string[]];
19
+ /** false: the option changes nothing a whole list draws, so a list-wide picker may leave it out. */
20
+ readonly demo?: false;
21
+ readonly values: readonly LookValue[];
22
+ };
23
+ /** A named set of picks, one value for every option. */
24
+ export type Look<Id extends string = string> = {
25
+ readonly id: string;
26
+ readonly name: string;
27
+ readonly device?: LookDevice;
28
+ readonly picks: Readonly<Record<Id, string>>;
29
+ };
30
+ /** A piece's options and looks; its first look is the one worn when nothing is picked. */
31
+ export type PieceLooks<Id extends string = string> = {
32
+ readonly id: string;
33
+ readonly name: string;
34
+ readonly options: readonly LookOption<Id>[];
35
+ readonly looks: readonly Look<Id>[];
36
+ };
37
+ /** Some options' picks, by option id. */
38
+ export type LookPicks<Id extends string = string> = Partial<Record<Id, string>>;
39
+ /** `data-<piece>-<option>` for every option: the pick when the option has that value, else its default. */
40
+ export declare function lookAttrs<Id extends string>(piece: PieceLooks<Id>, picks?: LookPicks<Id>): Record<string, string>;
41
+ /** A look's picks by its id; undefined for an id the piece has no look by. */
42
+ export declare function lookPicks<Id extends string>(piece: PieceLooks<Id>, look: string): LookPicks<Id> | undefined;
43
+ /** The named options' values from picks, each the option's default when missing or unknown. */
44
+ export declare function lookWorn<Id extends string, K extends Id>(piece: PieceLooks<Id>, picks: LookPicks<Id> | undefined, ids: readonly K[]): Record<K, string>;
45
+ /** The same, read from the closest frame round `el` carrying each `data-<piece>-<option>`; outside any frame, the defaults. */
46
+ export declare function lookWornOf<Id extends string, K extends Id>(piece: PieceLooks<Id>, el: Element | null, ids: readonly K[]): Record<K, string>;
@@ -0,0 +1,25 @@
1
+ function valueOf(option, pick) {
2
+ return pick != null && option.values.some((v) => v.id === pick) ? pick : option.def;
3
+ }
4
+ function optionOf(piece, id) {
5
+ const option = piece.options.find((o) => o.id === id);
6
+ if (!option)
7
+ throw new Error(`${piece.id} has no option ${id}`);
8
+ return option;
9
+ }
10
+ export function lookAttrs(piece, picks = {}) {
11
+ return Object.fromEntries(piece.options.map((o) => [`data-${piece.id}-${o.id}`, valueOf(o, picks[o.id])]));
12
+ }
13
+ export function lookPicks(piece, look) {
14
+ const found = piece.looks.find((l) => l.id === look);
15
+ return found ? { ...found.picks } : undefined;
16
+ }
17
+ export function lookWorn(piece, picks, ids) {
18
+ return Object.fromEntries(ids.map((id) => [id, valueOf(optionOf(piece, id), picks?.[id])]));
19
+ }
20
+ export function lookWornOf(piece, el, ids) {
21
+ return Object.fromEntries(ids.map((id) => {
22
+ const attr = `data-${piece.id}-${id}`;
23
+ return [id, valueOf(optionOf(piece, id), el?.closest(`[${attr}]`)?.getAttribute(attr))];
24
+ }));
25
+ }
@@ -0,0 +1,3 @@
1
+ import type { PieceLooks } from "./looks.js";
2
+ /** Every piece's options and looks, in a list; each is found by its `id`. */
3
+ export declare const LOOKS: readonly PieceLooks[];
@@ -0,0 +1,2 @@
1
+ import { GRID_LOOKS } from "../grid/looks.js";
2
+ export const LOOKS = [GRID_LOOKS];
@@ -55,9 +55,9 @@ export type ViewsProviderProps = {
55
55
  * `aria-expanded`, `data-slot` and `data-open` to forward to its element. */
56
56
  gridButtons?: ViewsGridButtons;
57
57
  /** How a cell of several values draws on one line: a multiselect's options, several emails, phones, links or
58
- * domains, several records, a lookup's names or places. `first` (the default): its first value and a count, at any
59
- * width, as on 0.5.0. `fit`: as many whole values as fit its width, then a count, following a column resize; the
60
- * first shows cut when even it doesn't fit. A wrapped row shows three either way. */
58
+ * domains, several records, a lookup's names or places. `fit` (the default): as many whole values as fit its
59
+ * width, then a count, following a column resize; the first shows cut when even it doesn't fit. `first`: its
60
+ * first value and a count, at any width, as on 0.5.0. A wrapped row shows three either way. */
61
61
  severalValues?: ViewsSeveralValues;
62
62
  /** Who draws a yes/no cell's box in the grid (the checkbox style). `own` (the default): ViewKit's tick box in its
63
63
  * own button, as on 0.5.0. `checkbox`: your `Checkbox`, the box your rail draws, handed `checked`, the column's
@@ -12,7 +12,7 @@ import { browserConfirm } from "./ports.js";
12
12
  export { useViews } from "./context.js";
13
13
  const MISSING_COMMAND_PARTS = missingParts("Command");
14
14
  const MISSING_CALENDAR_COMPONENT = missingComponent("Calendar");
15
- export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, sayRefusals = false, menus = "popover", gridButtons = "own", severalValues = "first", gridCheckboxes = "own", fieldRowButtons = "own", fieldRowCheckboxes = "own", panelButtons = "own", bodyFrame = "views", gridBodyPlace = "under", selectionBar, datePicks, }) {
15
+ export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, sayRefusals = false, menus = "popover", gridButtons = "own", severalValues = "fit", gridCheckboxes = "own", fieldRowButtons = "own", fieldRowCheckboxes = "own", panelButtons = "own", bodyFrame = "views", gridBodyPlace = "under", selectionBar, datePicks, }) {
16
16
  const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
17
17
  const settled = useMemo(() => ({
18
18
  ...components,
@@ -34,7 +34,7 @@ export type ViewsContextValue = {
34
34
  menus?: ViewsMenuRoute;
35
35
  /** Who draws the buttons the grid draws itself (`ViewsProvider`'s `gridButtons`). Absent means `own`. */
36
36
  gridButtons?: ViewsGridButtons;
37
- /** How a cell of several values draws on one line (`ViewsProvider`'s `severalValues`). Absent means `first`. */
37
+ /** How a cell of several values draws on one line (`ViewsProvider`'s `severalValues`). Absent means `fit`. */
38
38
  severalValues?: ViewsSeveralValues;
39
39
  /** Who draws a yes/no cell's box in the grid (`ViewsProvider`'s `gridCheckboxes`). Absent means `own`. */
40
40
  gridCheckboxes?: ViewsGridCheckboxes;