@wirecore/wirelayer-recipes 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/avatar.d.ts +24 -0
- package/dist/avatar.d.ts.map +1 -1
- package/dist/avatar.js +12 -1
- package/dist/avatar.js.map +1 -1
- package/dist/chart.d.ts +1 -1
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/conditions.d.ts +6 -6
- package/dist/conditions.d.ts.map +1 -1
- package/dist/conditions.js.map +1 -1
- package/dist/controls.js +1 -1
- package/dist/controls.js.map +1 -1
- package/dist/data.js +1 -1
- package/dist/data.js.map +1 -1
- package/dist/editor.js +3 -3
- package/dist/editor.js.map +1 -1
- package/dist/extras.js +2 -2
- package/dist/extras.js.map +1 -1
- package/dist/gantt.d.ts +7 -7
- package/dist/gantt.d.ts.map +1 -1
- package/dist/gantt.js.map +1 -1
- package/dist/hierarchy.js +1 -1
- package/dist/hierarchy.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/inputs.js +2 -2
- package/dist/inputs.js.map +1 -1
- package/dist/navigation.js +2 -2
- package/dist/navigation.js.map +1 -1
- package/dist/overlay.d.ts +39 -12
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +14 -5
- package/dist/overlay.js.map +1 -1
- package/dist/recurrence.d.ts +2 -2
- package/dist/recurrence.d.ts.map +1 -1
- package/dist/recurrence.js.map +1 -1
- package/dist/scheduler.d.ts +3 -3
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js.map +1 -1
- package/dist/shell-logic.d.ts +13 -3
- package/dist/shell-logic.d.ts.map +1 -1
- package/dist/shell-logic.js +3 -1
- package/dist/shell-logic.js.map +1 -1
- package/dist/shell.d.ts +47 -0
- package/dist/shell.d.ts.map +1 -1
- package/dist/shell.js +13 -1
- package/dist/shell.js.map +1 -1
- package/dist/sources/avatar.css +1 -1
- package/dist/sources/cascadeSelect.css +1 -1
- package/dist/sources/colorPicker.css +1 -1
- package/dist/sources/combobox.css +1 -1
- package/dist/sources/commandPalette.css +1 -1
- package/dist/sources/confirmPopup.css +1 -1
- package/dist/sources/dataTable.css +1 -1
- package/dist/sources/datePicker.css +1 -1
- package/dist/sources/editor.css +1 -1
- package/dist/sources/floatingPanel.css +1 -1
- package/dist/sources/hoverCard.css +1 -1
- package/dist/sources/megaMenu.css +1 -1
- package/dist/sources/mentions.css +1 -1
- package/dist/sources/menu.css +1 -1
- package/dist/sources/multiSelect.css +1 -1
- package/dist/sources/navigationMenu.css +1 -1
- package/dist/sources/popover.css +1 -1
- package/dist/sources/select.css +1 -1
- package/dist/sources/tagsInput.css +1 -1
- package/dist/sources/topBar.css +5 -0
- package/dist/sources/tour.css +1 -1
- package/dist/sources/treeSelect.css +1 -1
- package/dist/tree-data.d.ts +1 -1
- package/dist/tree-data.d.ts.map +1 -1
- package/dist/tree-data.js +1 -0
- package/dist/tree-data.js.map +1 -1
- package/dist/tv.d.ts +3 -0
- package/dist/tv.d.ts.map +1 -1
- package/dist/tv.js +2 -0
- package/dist/tv.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/visualizations.d.ts +1 -1
- package/dist/visualizations.d.ts.map +1 -1
- package/dist/visualizations.js.map +1 -1
- package/dist/widgets.js +1 -1
- package/dist/widgets.js.map +1 -1
- package/package.json +1 -1
- package/src/app.ts +1 -1
- package/src/avatar.ts +12 -1
- package/src/chart.ts +1 -1
- package/src/conditions.ts +23 -7
- package/src/controls.ts +1 -1
- package/src/data.ts +1 -1
- package/src/editor.ts +3 -3
- package/src/extras.ts +2 -2
- package/src/gantt.ts +9 -9
- package/src/hierarchy.ts +1 -1
- package/src/index.ts +3 -0
- package/src/inputs.ts +2 -2
- package/src/navigation.ts +2 -2
- package/src/overlay.ts +15 -5
- package/src/recurrence.ts +2 -2
- package/src/scheduler.ts +3 -3
- package/src/shell-logic.ts +10 -4
- package/src/shell.ts +14 -1
- package/src/tree-data.ts +5 -4
- package/src/tv.ts +2 -0
- package/src/utils.ts +8 -5
- package/src/visualizations.ts +2 -2
- package/src/widgets.ts +1 -1
package/src/conditions.ts
CHANGED
|
@@ -106,7 +106,11 @@ export function initialConditionValue(field: ConditionField | undefined, operato
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/** A new rule for the first field (or the given one) */
|
|
109
|
-
export function newConditionRule(
|
|
109
|
+
export function newConditionRule(
|
|
110
|
+
fields: readonly ConditionField[],
|
|
111
|
+
fieldId?: string,
|
|
112
|
+
id = conditionId()
|
|
113
|
+
): ConditionRule {
|
|
110
114
|
const field = fields.find((entry) => entry.id === fieldId) ?? fields[0];
|
|
111
115
|
const operator = operatorsFor(field)[0] ?? 'equals';
|
|
112
116
|
return { type: 'rule', id, field: field?.id ?? '', operator, value: initialConditionValue(field, operator) };
|
|
@@ -152,7 +156,11 @@ export function removeConditionNode(tree: ConditionGroup, id: string): Condition
|
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
/** Changes the field of a rule: the operator and value start over when the type changes */
|
|
155
|
-
export function setConditionField(
|
|
159
|
+
export function setConditionField(
|
|
160
|
+
rule: ConditionRule,
|
|
161
|
+
fields: readonly ConditionField[],
|
|
162
|
+
fieldId: string
|
|
163
|
+
): ConditionRule {
|
|
156
164
|
const before = fields.find((field) => field.id === rule.field);
|
|
157
165
|
const field = fields.find((entry) => entry.id === fieldId);
|
|
158
166
|
if (!field) return rule;
|
|
@@ -164,7 +172,7 @@ export function setConditionField(rule: ConditionRule, fields: ConditionField[],
|
|
|
164
172
|
/** Changes the operator of a rule: the value is kept if it still fits */
|
|
165
173
|
export function setConditionOperator(
|
|
166
174
|
rule: ConditionRule,
|
|
167
|
-
fields: ConditionField[],
|
|
175
|
+
fields: readonly ConditionField[],
|
|
168
176
|
operator: ConditionOperator
|
|
169
177
|
): ConditionRule {
|
|
170
178
|
const field = fields.find((entry) => entry.id === rule.field);
|
|
@@ -194,7 +202,7 @@ const isEmptyValue = (value: unknown) =>
|
|
|
194
202
|
value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0);
|
|
195
203
|
|
|
196
204
|
/** Whether a rule has what it needs to filter: a known field and a value (unless the operator takes none) */
|
|
197
|
-
export function isCompleteRule(rule: ConditionRule, fields?: ConditionField[]): boolean {
|
|
205
|
+
export function isCompleteRule(rule: ConditionRule, fields?: readonly ConditionField[]): boolean {
|
|
198
206
|
if (fields && !fields.some((field) => field.id === rule.field)) return false;
|
|
199
207
|
if (isValuelessOperator(rule.operator)) return true;
|
|
200
208
|
if (rule.operator === 'between') return Array.isArray(rule.value) && rule.value.some((part) => !isEmptyValue(part));
|
|
@@ -202,7 +210,10 @@ export function isCompleteRule(rule: ConditionRule, fields?: ConditionField[]):
|
|
|
202
210
|
}
|
|
203
211
|
|
|
204
212
|
/** Whether a tree filters anything (has at least one complete rule) */
|
|
205
|
-
export function isActiveCondition(
|
|
213
|
+
export function isActiveCondition(
|
|
214
|
+
tree: ConditionGroup | null | undefined,
|
|
215
|
+
fields?: readonly ConditionField[]
|
|
216
|
+
): boolean {
|
|
206
217
|
if (!tree) return false;
|
|
207
218
|
return tree.children.some((child) =>
|
|
208
219
|
child.type === 'rule' ? isCompleteRule(child, fields) : isActiveCondition(child, fields)
|
|
@@ -211,7 +222,12 @@ export function isActiveCondition(tree: ConditionGroup | null | undefined, field
|
|
|
211
222
|
|
|
212
223
|
const filterType = (type: ConditionFieldType | undefined): DataTableFilterType => type ?? 'text';
|
|
213
224
|
|
|
214
|
-
function matchesRule(
|
|
225
|
+
function matchesRule(
|
|
226
|
+
row: unknown,
|
|
227
|
+
rule: ConditionRule,
|
|
228
|
+
fields: readonly ConditionField[] | undefined,
|
|
229
|
+
locale?: string
|
|
230
|
+
) {
|
|
215
231
|
const field = fields?.find((entry) => entry.id === rule.field);
|
|
216
232
|
if (fields && !field) return true;
|
|
217
233
|
const cell = field?.accessor
|
|
@@ -241,7 +257,7 @@ function matchesRule(row: unknown, rule: ConditionRule, fields: ConditionField[]
|
|
|
241
257
|
export function matchesCondition(
|
|
242
258
|
row: unknown,
|
|
243
259
|
tree: ConditionNode | null | undefined,
|
|
244
|
-
fields?: ConditionField[],
|
|
260
|
+
fields?: readonly ConditionField[],
|
|
245
261
|
locale?: string
|
|
246
262
|
): boolean {
|
|
247
263
|
if (!tree) return true;
|
package/src/controls.ts
CHANGED
|
@@ -107,7 +107,7 @@ export const overlayBadge = tv({
|
|
|
107
107
|
export const confirmPopup = tv({
|
|
108
108
|
slots: {
|
|
109
109
|
content: [
|
|
110
|
-
'z-50 flex w-72 max-w-[calc(100vw-2rem)] flex-col gap-3 rounded-
|
|
110
|
+
'z-50 flex w-72 max-w-[calc(100vw-2rem)] flex-col gap-3 rounded-popup border border-line-2 bg-card p-4 text-fg outline-none',
|
|
111
111
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
112
112
|
'motion-safe:data-[state=open]:animate-pop-in motion-safe:data-[state=closed]:animate-pop-out',
|
|
113
113
|
],
|
package/src/data.ts
CHANGED
|
@@ -91,7 +91,7 @@ export const dataTable = tv({
|
|
|
91
91
|
filterCell: 'px-3 py-2 font-normal normal-case',
|
|
92
92
|
/** Filter menu (popover): conditions with match mode and value */
|
|
93
93
|
filterPanel: [
|
|
94
|
-
'z-50 flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-3 rounded-
|
|
94
|
+
'z-50 flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-3 rounded-popup border border-line-2 bg-card p-3 text-fg outline-none',
|
|
95
95
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
96
96
|
...popupMotion,
|
|
97
97
|
],
|
package/src/editor.ts
CHANGED
|
@@ -88,7 +88,7 @@ export const editor = tv({
|
|
|
88
88
|
'focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-fg',
|
|
89
89
|
],
|
|
90
90
|
/** Bubble menu (text selected) and floating menu (empty line) */
|
|
91
|
-
menu: 'z-20 flex items-center gap-0.5 rounded-
|
|
91
|
+
menu: 'z-20 flex items-center gap-0.5 rounded-popup border border-line bg-card p-1 shadow-[0_8px_24px_-12px_rgba(0,0,0,.35)]',
|
|
92
92
|
/** Colour choice: swatches in a row */
|
|
93
93
|
palette: 'flex flex-wrap items-center gap-1 border-b border-line p-2',
|
|
94
94
|
paletteLabel: 'me-1 text-xs text-muted',
|
|
@@ -109,9 +109,9 @@ export const editor = tv({
|
|
|
109
109
|
focusRing,
|
|
110
110
|
],
|
|
111
111
|
/** Suggestions for mentions (listbox below the caret) */
|
|
112
|
-
suggestions: 'fixed z-50 max-h-60 w-64 overflow-y-auto rounded-
|
|
112
|
+
suggestions: 'fixed z-50 max-h-60 w-64 overflow-y-auto rounded-popup border border-line bg-card p-1 shadow-lg',
|
|
113
113
|
suggestion: [
|
|
114
|
-
'flex min-h-8 cursor-pointer items-center rounded-
|
|
114
|
+
'flex min-h-8 cursor-pointer items-center rounded-lg px-2 text-sm text-fg',
|
|
115
115
|
'data-highlighted:bg-line forced-colors:data-highlighted:bg-[Highlight] forced-colors:data-highlighted:text-[HighlightText]',
|
|
116
116
|
],
|
|
117
117
|
status: 'sr-only',
|
package/src/extras.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const navigationMenu = tv({
|
|
|
22
22
|
focusRing,
|
|
23
23
|
],
|
|
24
24
|
content: [
|
|
25
|
-
'absolute top-[calc(100%+6px)] inset-s-0 z-40 grid w-[34rem] max-w-[calc(100vw-2rem)] grid-cols-2 gap-1 rounded-
|
|
25
|
+
'absolute top-[calc(100%+6px)] inset-s-0 z-40 grid w-[34rem] max-w-[calc(100vw-2rem)] grid-cols-2 gap-1 rounded-popup border border-line-2 bg-card p-2',
|
|
26
26
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
27
27
|
...popupMotion,
|
|
28
28
|
],
|
|
@@ -76,7 +76,7 @@ export const tour = tv({
|
|
|
76
76
|
'data-[type=dialog]:items-center data-[type=dialog]:justify-center data-[type=dialog]:p-4',
|
|
77
77
|
],
|
|
78
78
|
content: [
|
|
79
|
-
'pointer-events-auto flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2 rounded-
|
|
79
|
+
'pointer-events-auto flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2 rounded-popup border border-line-2 bg-card p-4 text-fg outline-none',
|
|
80
80
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
81
81
|
...popupMotion,
|
|
82
82
|
],
|
package/src/gantt.ts
CHANGED
|
@@ -55,7 +55,7 @@ export const taskDuration = (task: Pick<GanttTask, 'start' | 'end' | 'milestone'
|
|
|
55
55
|
task.milestone ? 0 : Math.max(1, daysBetween(task.start, task.end) + 1);
|
|
56
56
|
|
|
57
57
|
/** Sub-tasks by parent id (top-level tasks under "") in their order */
|
|
58
|
-
function childrenOf(tasks: GanttTask[]) {
|
|
58
|
+
function childrenOf(tasks: readonly GanttTask[]) {
|
|
59
59
|
const ids = new Set(tasks.map((task) => task.id));
|
|
60
60
|
const children = new Map<string, GanttTask[]>();
|
|
61
61
|
for (const task of tasks) {
|
|
@@ -66,7 +66,7 @@ function childrenOf(tasks: GanttTask[]) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/** Dates and progress of every task – groups span their sub-tasks, their progress is weighted by duration */
|
|
69
|
-
export function ganttSpans(tasks: GanttTask[]): Map<string, { start: string; end: string; progress: number }> {
|
|
69
|
+
export function ganttSpans(tasks: readonly GanttTask[]): Map<string, { start: string; end: string; progress: number }> {
|
|
70
70
|
const children = childrenOf(tasks);
|
|
71
71
|
const spans = new Map<string, { start: string; end: string; progress: number }>();
|
|
72
72
|
const visit = (task: GanttTask, seen: Set<string>): { start: string; end: string; progress: number } => {
|
|
@@ -94,7 +94,7 @@ export function ganttSpans(tasks: GanttTask[]): Map<string, { start: string; end
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/** The visible rows: top-level tasks and the sub-tasks of expanded groups, depth first */
|
|
97
|
-
export function ganttRows(tasks: GanttTask[], expanded: Iterable<string>): GanttRow[] {
|
|
97
|
+
export function ganttRows(tasks: readonly GanttTask[], expanded: Iterable<string>): GanttRow[] {
|
|
98
98
|
const open = new Set(expanded);
|
|
99
99
|
const children = childrenOf(tasks);
|
|
100
100
|
const spans = ganttSpans(tasks);
|
|
@@ -122,7 +122,7 @@ export function ganttRows(tasks: GanttTask[], expanded: Iterable<string>): Gantt
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/** Ids of all tasks that have sub-tasks (e.g. to expand everything) */
|
|
125
|
-
export const ganttGroupIds = (tasks: GanttTask[]) => [...childrenOf(tasks).keys()].filter(Boolean);
|
|
125
|
+
export const ganttGroupIds = (tasks: readonly GanttTask[]) => [...childrenOf(tasks).keys()].filter(Boolean);
|
|
126
126
|
|
|
127
127
|
/** A task moved by days, or with `resize` its end moved (at least one day long); milestones keep start = end */
|
|
128
128
|
export function shiftTask(
|
|
@@ -200,7 +200,7 @@ const UNITS: Record<GanttZoom, { bottom: 'day' | 'week' | 'month' | 'quarter'; t
|
|
|
200
200
|
* (or around `fallback` without tasks), with the header units labelled in the locale.
|
|
201
201
|
*/
|
|
202
202
|
export function ganttScale(
|
|
203
|
-
tasks: Pick<GanttTask, 'start' | 'end'>[],
|
|
203
|
+
tasks: readonly Pick<GanttTask, 'start' | 'end'>[],
|
|
204
204
|
zoom: GanttZoom,
|
|
205
205
|
locale: string,
|
|
206
206
|
translations: Translations,
|
|
@@ -275,7 +275,7 @@ export function dependencyPath(
|
|
|
275
275
|
// ── Dependencies ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
276
276
|
|
|
277
277
|
/** Ids of the tasks a task depends on, groups replaced by their sub-tasks without children (leaves) */
|
|
278
|
-
function leafDependencies(tasks: GanttTask[]) {
|
|
278
|
+
function leafDependencies(tasks: readonly GanttTask[]) {
|
|
279
279
|
const children = childrenOf(tasks);
|
|
280
280
|
const leaves = (id: string, seen = new Set<string>()): string[] => {
|
|
281
281
|
const kids = children.get(id);
|
|
@@ -290,7 +290,7 @@ function leafDependencies(tasks: GanttTask[]) {
|
|
|
290
290
|
* predecessors start at their planned start, the others as soon as their predecessors are finished; latest ends run
|
|
291
291
|
* back from the end of the project, tasks without slack are critical. Tasks in a cycle of dependencies are left out.
|
|
292
292
|
*/
|
|
293
|
-
export function criticalPath(tasks: GanttTask[]): Set<string> {
|
|
293
|
+
export function criticalPath(tasks: readonly GanttTask[]): Set<string> {
|
|
294
294
|
const { children, leaves } = leafDependencies(tasks);
|
|
295
295
|
const nodes = tasks.filter((task) => !children.get(task.id)?.length);
|
|
296
296
|
const byId = new Map(nodes.map((task) => [task.id, task]));
|
|
@@ -346,7 +346,7 @@ export function criticalPath(tasks: GanttTask[]): Set<string> {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
/** Whether "`to` depends on `from`" would close a cycle (or is the task itself, or exists already) */
|
|
349
|
-
export function dependencyCycle(tasks: GanttTask[], from: string, to: string): boolean {
|
|
349
|
+
export function dependencyCycle(tasks: readonly GanttTask[], from: string, to: string): boolean {
|
|
350
350
|
if (from === to) return true;
|
|
351
351
|
const byId = new Map(tasks.map((task) => [task.id, task]));
|
|
352
352
|
if (byId.get(to)?.dependencies?.includes(from)) return true;
|
|
@@ -468,7 +468,7 @@ export const gantt = tv({
|
|
|
468
468
|
* Tasks that can become a predecessor of the task (a new finish-to-start dependency): not the task itself, not one it
|
|
469
469
|
* already depends on, none that would close a cycle – in the order of `tasks`
|
|
470
470
|
*/
|
|
471
|
-
export function ganttPredecessors(tasks: GanttTask[], taskId: string): GanttTask[] {
|
|
471
|
+
export function ganttPredecessors(tasks: readonly GanttTask[], taskId: string): GanttTask[] {
|
|
472
472
|
const task = tasks.find((entry) => entry.id === taskId);
|
|
473
473
|
if (!task) return [];
|
|
474
474
|
return tasks.filter(
|
package/src/hierarchy.ts
CHANGED
|
@@ -281,7 +281,7 @@ export const treeSelect = tv({
|
|
|
281
281
|
indicator:
|
|
282
282
|
'size-4 shrink-0 text-muted transition-transform motion-reduce:transition-none data-[state=open]:rotate-180',
|
|
283
283
|
content: [
|
|
284
|
-
'max-h-80 w-[var(--reference-width)] overflow-y-auto rounded-
|
|
284
|
+
'max-h-80 w-[var(--reference-width)] overflow-y-auto rounded-popup border border-line-2 bg-card p-1 text-fg outline-none',
|
|
285
285
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
286
286
|
...popupMotion,
|
|
287
287
|
],
|
package/src/index.ts
CHANGED
|
@@ -244,6 +244,7 @@ export {
|
|
|
244
244
|
pageHeader,
|
|
245
245
|
result,
|
|
246
246
|
toolbarRegion,
|
|
247
|
+
topBar,
|
|
247
248
|
type BannerPosition,
|
|
248
249
|
type BannerVariant,
|
|
249
250
|
type MegaMenuCollapse,
|
|
@@ -272,6 +273,7 @@ export {
|
|
|
272
273
|
headroomHidden,
|
|
273
274
|
inSafeTriangle,
|
|
274
275
|
isCurrentLink,
|
|
276
|
+
linkTarget,
|
|
275
277
|
masonrySpan,
|
|
276
278
|
newUnread,
|
|
277
279
|
newestTime,
|
|
@@ -287,6 +289,7 @@ export {
|
|
|
287
289
|
type CurrentLinkLike,
|
|
288
290
|
type HoverIntent,
|
|
289
291
|
type HoverIntentOptions,
|
|
292
|
+
type LinkTo,
|
|
290
293
|
type NotificationDay,
|
|
291
294
|
type Point,
|
|
292
295
|
type RectLike,
|
package/src/inputs.ts
CHANGED
|
@@ -307,7 +307,7 @@ export const datePicker = tv({
|
|
|
307
307
|
trigger: boxButton,
|
|
308
308
|
triggerIcon: 'size-4',
|
|
309
309
|
content: [
|
|
310
|
-
'z-50 flex w-[304px] flex-col gap-2 rounded-
|
|
310
|
+
'z-50 flex w-[304px] flex-col gap-2 rounded-popup border border-line-2 bg-card p-3 text-fg outline-none',
|
|
311
311
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
312
312
|
'motion-safe:data-[state=open]:animate-pop-in motion-safe:data-[state=closed]:animate-pop-out',
|
|
313
313
|
'data-[side=bottom]:[--wc-pop-y:-4px] data-[side=top]:[--wc-pop-y:4px]',
|
|
@@ -635,7 +635,7 @@ export const colorPicker = tv({
|
|
|
635
635
|
/** Name of the trigger without a Field (read before the value) */
|
|
636
636
|
hiddenName: 'sr-only',
|
|
637
637
|
content: [
|
|
638
|
-
'z-50 flex w-[264px] flex-col gap-3 rounded-
|
|
638
|
+
'z-50 flex w-[264px] flex-col gap-3 rounded-popup border border-line-2 bg-card p-3 text-fg outline-none',
|
|
639
639
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
640
640
|
'motion-safe:data-[state=open]:animate-pop-in motion-safe:data-[state=closed]:animate-pop-out',
|
|
641
641
|
],
|
package/src/navigation.ts
CHANGED
|
@@ -12,13 +12,13 @@ export const SUBMENU_GUTTER = 9;
|
|
|
12
12
|
|
|
13
13
|
/** Floating list of options – Select, MultiSelect, Combobox */
|
|
14
14
|
export const listboxContent = [
|
|
15
|
-
'flex max-h-72 flex-col overflow-y-auto rounded-
|
|
15
|
+
'flex max-h-72 flex-col overflow-y-auto rounded-popup border border-line-2 bg-card p-1 text-fg outline-none',
|
|
16
16
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
17
17
|
...popupMotion,
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
export const listboxItem = [
|
|
21
|
-
'flex h-9 shrink-0 cursor-pointer items-center gap-2 rounded-
|
|
21
|
+
'flex h-9 shrink-0 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-sm',
|
|
22
22
|
'data-highlighted:bg-line data-[state=checked]:bg-line data-disabled:cursor-not-allowed data-disabled:opacity-40',
|
|
23
23
|
'forced-colors:data-highlighted:forced-color-adjust-none forced-colors:data-highlighted:bg-[Highlight] forced-colors:data-highlighted:text-[HighlightText]',
|
|
24
24
|
];
|
package/src/overlay.ts
CHANGED
|
@@ -3,15 +3,22 @@ import { popupMotion, pressable, tv } from './tv.js';
|
|
|
3
3
|
// Menu, tooltip, dialog and toast – rendered in a portal on top of the page.
|
|
4
4
|
|
|
5
5
|
const floatingSurface = [
|
|
6
|
-
'flex flex-col rounded-
|
|
6
|
+
'flex flex-col rounded-popup border border-line-2 bg-card p-1 text-fg outline-none',
|
|
7
7
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
8
8
|
];
|
|
9
9
|
|
|
10
|
+
/** Arrow from a floating panel to its trigger (Popover, Menu with `arrow`) */
|
|
11
|
+
const popupArrow = {
|
|
12
|
+
arrow: '[--arrow-background:var(--color-card)] [--arrow-size:10px]',
|
|
13
|
+
arrowTip: 'border-t border-l border-line-2',
|
|
14
|
+
};
|
|
15
|
+
|
|
10
16
|
export const menu = tv({
|
|
11
17
|
slots: {
|
|
12
18
|
content: [...floatingSurface, 'min-w-56', ...popupMotion],
|
|
19
|
+
...popupArrow,
|
|
13
20
|
item: [
|
|
14
|
-
'flex h-9 shrink-0 cursor-pointer items-center gap-2.5 rounded-
|
|
21
|
+
'flex h-9 shrink-0 cursor-pointer items-center gap-2.5 rounded-lg px-2.5 text-sm',
|
|
15
22
|
'data-highlighted:bg-line data-disabled:cursor-not-allowed data-disabled:opacity-40',
|
|
16
23
|
'forced-colors:data-highlighted:forced-color-adjust-none forced-colors:data-highlighted:bg-[Highlight] forced-colors:data-highlighted:text-[HighlightText]',
|
|
17
24
|
],
|
|
@@ -53,12 +60,11 @@ export const tooltip = tv({
|
|
|
53
60
|
export const popover = tv({
|
|
54
61
|
slots: {
|
|
55
62
|
content: [
|
|
56
|
-
'relative flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-1 rounded-
|
|
63
|
+
'relative flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-1 rounded-popup border border-line-2 bg-card p-4 text-fg outline-none',
|
|
57
64
|
'shadow-[0_14px_32px_-12px_rgba(0,0,0,.45)]',
|
|
58
65
|
...popupMotion,
|
|
59
66
|
],
|
|
60
|
-
|
|
61
|
-
arrowTip: 'border-t border-l border-line-2',
|
|
67
|
+
...popupArrow,
|
|
62
68
|
/** Optional dimming behind the panel (`overlay`) */
|
|
63
69
|
backdrop: [
|
|
64
70
|
'fixed inset-0 z-50 bg-black/40',
|
|
@@ -78,6 +84,10 @@ export const popover = tv({
|
|
|
78
84
|
width: {
|
|
79
85
|
trigger: { content: 'w-[var(--reference-width)] max-w-none' },
|
|
80
86
|
},
|
|
87
|
+
/** The title only for screen readers – it still names the panel */
|
|
88
|
+
hideTitle: {
|
|
89
|
+
true: { title: 'sr-only', body: 'mt-0' },
|
|
90
|
+
},
|
|
81
91
|
},
|
|
82
92
|
});
|
|
83
93
|
|
package/src/recurrence.ts
CHANGED
|
@@ -268,7 +268,7 @@ export function expandRecurrence(event: SchedulerEvent, range: DateRange, timeZo
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/** All events with their series expanded for a range; events without rule that do not touch it are left out */
|
|
271
|
-
export function expandEvents(events: SchedulerEvent[], range: DateRange, timeZone?: string): SchedulerEvent[] {
|
|
271
|
+
export function expandEvents(events: readonly SchedulerEvent[], range: DateRange, timeZone?: string): SchedulerEvent[] {
|
|
272
272
|
return events.flatMap((event) => expandRecurrence(event, range, timeZone));
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -373,7 +373,7 @@ function shiftWall(value: string, ms: number) {
|
|
|
373
373
|
* read in `timeZone` (else local time).
|
|
374
374
|
*/
|
|
375
375
|
export function applyEventChange(
|
|
376
|
-
events: SchedulerEvent[],
|
|
376
|
+
events: readonly SchedulerEvent[],
|
|
377
377
|
change: SchedulerEventChange,
|
|
378
378
|
timeZone?: string
|
|
379
379
|
): SchedulerEvent[] {
|
package/src/scheduler.ts
CHANGED
|
@@ -314,7 +314,7 @@ const minutesOf = (time: string) => {
|
|
|
314
314
|
* Closed times of a day as minute ranges [from, to) within 0–1440 – outside the opening hours of its weekday (all
|
|
315
315
|
* day when the weekday has none). No opening hours: nothing closed.
|
|
316
316
|
*/
|
|
317
|
-
export function closedRanges(hours: SchedulerBusinessHours[] | undefined, day: Date): [number, number][] {
|
|
317
|
+
export function closedRanges(hours: readonly SchedulerBusinessHours[] | undefined, day: Date): [number, number][] {
|
|
318
318
|
if (!hours) return [];
|
|
319
319
|
const open = hours
|
|
320
320
|
.filter((entry) => entry.days.includes(day.getDay()))
|
|
@@ -333,7 +333,7 @@ export function closedRanges(hours: SchedulerBusinessHours[] | undefined, day: D
|
|
|
333
333
|
|
|
334
334
|
/** Closed times of a day in the visible hours as top and height in percent (for the day and week view) */
|
|
335
335
|
export function closedTimes(
|
|
336
|
-
hours: SchedulerBusinessHours[] | undefined,
|
|
336
|
+
hours: readonly SchedulerBusinessHours[] | undefined,
|
|
337
337
|
day: Date,
|
|
338
338
|
startHour: number,
|
|
339
339
|
endHour: number
|
|
@@ -439,7 +439,7 @@ export function eventsOverlap(
|
|
|
439
439
|
|
|
440
440
|
export interface EventDropCheck {
|
|
441
441
|
/** All shown events (series expanded) */
|
|
442
|
-
events: SchedulerEvent[];
|
|
442
|
+
events: readonly SchedulerEvent[];
|
|
443
443
|
event: SchedulerEvent;
|
|
444
444
|
start: string;
|
|
445
445
|
end: string;
|
package/src/shell-logic.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Framework-neutral logic of the page shell: mega menu hover intent, current links, resize handles, headroom,
|
|
2
|
-
// stored preferences, notification days, speed dial positions, masonry rows and responsive column variables.
|
|
2
|
+
// link targets, stored preferences, notification days, speed dial positions, masonry rows and responsive column variables.
|
|
3
3
|
|
|
4
4
|
export interface Point {
|
|
5
5
|
x: number;
|
|
@@ -57,6 +57,12 @@ export function isCurrentLink<T extends CurrentLinkLike>(
|
|
|
57
57
|
return currentHref !== undefined && link.href !== undefined && link.href === currentHref;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/** Router target of a link: a path or a route object (vue-router, React Router, TanStack Router) */
|
|
61
|
+
export type LinkTo = string | object;
|
|
62
|
+
|
|
63
|
+
/** Props for the link component (`linkAs`): `to` when the link has a router target, else `href` */
|
|
64
|
+
export const linkTarget = (href: string | undefined, to?: LinkTo) => (to === undefined ? { href } : { to });
|
|
65
|
+
|
|
60
66
|
export interface ResizeLimits {
|
|
61
67
|
min: number;
|
|
62
68
|
max: number;
|
|
@@ -136,7 +142,7 @@ export function notificationDay(date: Date | string | number, now: Date = new Da
|
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
/** Items grouped by day (today, yesterday, older); groups without items are left out, the order is kept */
|
|
139
|
-
export function groupByDay<T extends { date: Date | string | number }>(items: T[], now: Date = new Date()) {
|
|
145
|
+
export function groupByDay<T extends { date: Date | string | number }>(items: readonly T[], now: Date = new Date()) {
|
|
140
146
|
const days: NotificationDay[] = ['today', 'yesterday', 'older'];
|
|
141
147
|
return days
|
|
142
148
|
.map((day) => ({ day, items: items.filter((item) => notificationDay(item.date, now) === day) }))
|
|
@@ -164,14 +170,14 @@ export function notificationTime(date: Date | string | number, day: Notification
|
|
|
164
170
|
*/
|
|
165
171
|
export function newUnread<T extends { id: string; read?: boolean; date: Date | string | number }>(
|
|
166
172
|
known: Set<string>,
|
|
167
|
-
items: T[],
|
|
173
|
+
items: readonly T[],
|
|
168
174
|
since = -Infinity
|
|
169
175
|
): T[] {
|
|
170
176
|
return items.filter((item) => !item.read && !known.has(item.id) && new Date(item.date).getTime() > since);
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
/** Time (ms) of the newest item, -Infinity without items */
|
|
174
|
-
export const newestTime = (items: { date: Date | string | number }[]) =>
|
|
180
|
+
export const newestTime = (items: readonly { date: Date | string | number }[]) =>
|
|
175
181
|
items.reduce((newest, item) => Math.max(newest, new Date(item.date).getTime()), -Infinity);
|
|
176
182
|
|
|
177
183
|
export type SpeedDialLayout = 'column' | 'circle' | 'semicircle' | 'quarter';
|
package/src/shell.ts
CHANGED
|
@@ -39,7 +39,7 @@ export const megaMenu = tv({
|
|
|
39
39
|
],
|
|
40
40
|
content: [
|
|
41
41
|
// At least as wide as one column plus the teaser, even when the navigation itself is narrow
|
|
42
|
-
'absolute inset-x-0 top-[calc(100%+6px)] z-40 flex min-w-[min(48rem,calc(100vw-2rem))] flex-col gap-4 rounded-
|
|
42
|
+
'absolute inset-x-0 top-[calc(100%+6px)] z-40 flex min-w-[min(48rem,calc(100vw-2rem))] flex-col gap-4 rounded-popup border border-line-2 bg-card p-5 text-fg',
|
|
43
43
|
panelShadow,
|
|
44
44
|
'motion-safe:data-[state=open]:animate-pop-in',
|
|
45
45
|
],
|
|
@@ -367,6 +367,19 @@ export const descriptions = tv({
|
|
|
367
367
|
},
|
|
368
368
|
});
|
|
369
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Slim header of an app outside AppShell: content at the start, in the middle and at the end – no menus, no toolbar
|
|
372
|
+
* keyboard navigation (TopBar)
|
|
373
|
+
*/
|
|
374
|
+
export const topBar = tv({
|
|
375
|
+
slots: {
|
|
376
|
+
base: 'flex h-14 shrink-0 items-center gap-3 border-b border-line bg-card px-4',
|
|
377
|
+
start: 'flex shrink-0 items-center gap-2',
|
|
378
|
+
center: 'flex min-w-0 flex-1 items-center gap-2',
|
|
379
|
+
end: 'ms-auto flex shrink-0 items-center gap-2',
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
|
|
370
383
|
/** Toolbar with start, centre and end areas (Toolbar `start`/`center`/`end`) */
|
|
371
384
|
export const toolbarRegion = tv({
|
|
372
385
|
base: 'flex min-w-0 flex-wrap items-center gap-1',
|
package/src/tree-data.ts
CHANGED
|
@@ -45,12 +45,13 @@ export function walkTree<T extends HierarchyNode>(
|
|
|
45
45
|
* of its own keeps them – the parent can always take over (manual loading). `key` names a node (default: `id`).
|
|
46
46
|
*/
|
|
47
47
|
export function withLoadedChildren<T extends LazyNode>(
|
|
48
|
-
items: T[],
|
|
48
|
+
items: readonly T[],
|
|
49
49
|
loaded: Readonly<Record<string, T[]>>,
|
|
50
50
|
key: (node: T) => string = idOf
|
|
51
51
|
): T[] {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// The items are never changed, only copied – read-only input comes back as it is
|
|
53
|
+
if (!Object.keys(loaded).length) return items as T[];
|
|
54
|
+
const resolve = (list: readonly T[]): T[] => {
|
|
54
55
|
let changed = false;
|
|
55
56
|
const next = list.map((node) => {
|
|
56
57
|
const own = node.children as T[] | undefined;
|
|
@@ -61,7 +62,7 @@ export function withLoadedChildren<T extends LazyNode>(
|
|
|
61
62
|
changed = true;
|
|
62
63
|
return { ...node, children: resolved };
|
|
63
64
|
});
|
|
64
|
-
return changed ? next : list;
|
|
65
|
+
return changed ? next : (list as T[]);
|
|
65
66
|
};
|
|
66
67
|
return resolve(items);
|
|
67
68
|
}
|
package/src/tv.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { createTV } from 'tailwind-variants';
|
|
|
3
3
|
/** tailwind-merge knows the custom WireLayer utilities (also used by the @wirecore/wirelayer-css generator). */
|
|
4
4
|
export const twMergeConfig = {
|
|
5
5
|
extend: {
|
|
6
|
+
// rounded-popup is a radius, so `classes` like rounded-none replace it
|
|
7
|
+
theme: { radius: ['popup'] },
|
|
6
8
|
classGroups: {
|
|
7
9
|
'bg-image': ['bg-glow'],
|
|
8
10
|
'text-gradient': ['text-gradient'],
|
package/src/utils.ts
CHANGED
|
@@ -217,7 +217,7 @@ export interface PasswordRequirement {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/** Which requirements a password meets, in their order */
|
|
220
|
-
export const checkPasswordRequirements = (password: string, requirements: PasswordRequirement[]): boolean[] =>
|
|
220
|
+
export const checkPasswordRequirements = (password: string, requirements: readonly PasswordRequirement[]): boolean[] =>
|
|
221
221
|
requirements.map(({ test }) => (typeof test === 'function' ? test(password) : test.test(password)));
|
|
222
222
|
|
|
223
223
|
/** Characters a PinInput box takes */
|
|
@@ -707,7 +707,7 @@ export function matchesHotkey(event: KeyLike, hotkey: string): boolean {
|
|
|
707
707
|
* Keeps the items a score accepts: `false`/0 drop an item, `true` keeps it in place, higher numbers come first
|
|
708
708
|
* (stable). `limit` cuts the list.
|
|
709
709
|
*/
|
|
710
|
-
export function rankItems<T>(items: T[], score: (item: T) => number | boolean, limit?: number): T[] {
|
|
710
|
+
export function rankItems<T>(items: readonly T[], score: (item: T) => number | boolean, limit?: number): T[] {
|
|
711
711
|
const ranked = items
|
|
712
712
|
.map((item, index) => ({ item, index, score: Number(score(item)) }))
|
|
713
713
|
.filter((entry) => entry.score > 0)
|
|
@@ -740,7 +740,7 @@ export function filterCommands<T extends CommandSearchItem>(
|
|
|
740
740
|
const score = filter
|
|
741
741
|
? (item: T) => filter(item, query)
|
|
742
742
|
: (item: T) => [item.label, ...(item.keywords ?? [])].some((text) => fold(text).includes(needle));
|
|
743
|
-
return rankItems(
|
|
743
|
+
return rankItems(items, score, limit);
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
/** Items by their group heading, in the order the groups first appear ('' for items without a group) */
|
|
@@ -757,7 +757,7 @@ export function commandGroups<T extends { group?: string }>(items: readonly T[])
|
|
|
757
757
|
interface FilterableEntry {
|
|
758
758
|
type?: string;
|
|
759
759
|
label?: string;
|
|
760
|
-
items?: FilterableEntry[];
|
|
760
|
+
items?: readonly FilterableEntry[];
|
|
761
761
|
children?: FilterableEntry[];
|
|
762
762
|
}
|
|
763
763
|
|
|
@@ -765,7 +765,10 @@ interface FilterableEntry {
|
|
|
765
765
|
* Filters menu entries by their label: groups keep their matching items, submenus their matching entries (or all
|
|
766
766
|
* when their own label matches), separators are dropped.
|
|
767
767
|
*/
|
|
768
|
-
export function filterMenuEntries<T extends FilterableEntry>(
|
|
768
|
+
export function filterMenuEntries<T extends FilterableEntry>(
|
|
769
|
+
entries: readonly T[],
|
|
770
|
+
matches: (label: string) => boolean
|
|
771
|
+
): T[] {
|
|
769
772
|
const result: T[] = [];
|
|
770
773
|
for (const entry of entries) {
|
|
771
774
|
if (entry.type === 'separator') continue;
|
package/src/visualizations.ts
CHANGED
|
@@ -211,8 +211,8 @@ export interface SankeyLinkLayout extends SankeyLinkInput {
|
|
|
211
211
|
* in- and outflow; bands leave and enter in the order of the nodes on the other side.
|
|
212
212
|
*/
|
|
213
213
|
export function sankeyLayout(
|
|
214
|
-
nodes: SankeyNodeInput[],
|
|
215
|
-
links: SankeyLinkInput[],
|
|
214
|
+
nodes: readonly SankeyNodeInput[],
|
|
215
|
+
links: readonly SankeyLinkInput[],
|
|
216
216
|
width: number,
|
|
217
217
|
height: number,
|
|
218
218
|
{ nodeWidth = 12, padding = 14 } = {}
|
package/src/widgets.ts
CHANGED
|
@@ -80,7 +80,7 @@ export const floatingPanel = tv({
|
|
|
80
80
|
slots: {
|
|
81
81
|
positioner: 'z-50',
|
|
82
82
|
content: [
|
|
83
|
-
'flex flex-col overflow-hidden rounded-
|
|
83
|
+
'flex flex-col overflow-hidden rounded-popup border border-line-2 bg-card text-fg outline-none',
|
|
84
84
|
popupShadow,
|
|
85
85
|
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-fg',
|
|
86
86
|
'data-maximized:rounded-none data-minimized:h-auto!',
|