apex-grid 1.1.0 → 3.0.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/LICENSE +76 -5
- package/README.md +523 -10
- package/components/cell.d.ts +39 -0
- package/components/cell.js +334 -5
- package/components/cell.js.map +1 -1
- package/components/filter-row.d.ts +7 -5
- package/components/filter-row.js +151 -68
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +955 -4
- package/components/grid.js +412 -40
- package/components/grid.js.map +1 -1
- package/components/header-row.d.ts +21 -1
- package/components/header-row.js +140 -7
- package/components/header-row.js.map +1 -1
- package/components/header.d.ts +7 -0
- package/components/header.js +151 -31
- package/components/header.js.map +1 -1
- package/components/paginator.d.ts +56 -0
- package/components/paginator.js +148 -0
- package/components/paginator.js.map +1 -0
- package/components/row.d.ts +21 -2
- package/components/row.js +185 -10
- package/components/row.js.map +1 -1
- package/components/toolbar.d.ts +60 -0
- package/components/toolbar.js +259 -0
- package/components/toolbar.js.map +1 -0
- package/components/virtualizer.js +1 -1
- package/components/virtualizer.js.map +1 -1
- package/controllers/data-operation.d.ts +14 -0
- package/controllers/data-operation.js +19 -2
- package/controllers/data-operation.js.map +1 -1
- package/controllers/dom.d.ts +37 -1
- package/controllers/dom.js +176 -9
- package/controllers/dom.js.map +1 -1
- package/controllers/editing.d.ts +130 -0
- package/controllers/editing.js +197 -0
- package/controllers/editing.js.map +1 -0
- package/controllers/expansion.d.ts +68 -0
- package/controllers/expansion.js +126 -0
- package/controllers/expansion.js.map +1 -0
- package/controllers/navigation.d.ts +17 -6
- package/controllers/navigation.js +24 -8
- package/controllers/navigation.js.map +1 -1
- package/controllers/pagination.d.ts +102 -0
- package/controllers/pagination.js +106 -0
- package/controllers/pagination.js.map +1 -0
- package/controllers/reorder.d.ts +78 -0
- package/controllers/reorder.js +124 -0
- package/controllers/reorder.js.map +1 -0
- package/controllers/selection.d.ts +109 -0
- package/controllers/selection.js +168 -0
- package/controllers/selection.js.map +1 -0
- package/controllers/sort.js +28 -0
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +47 -1
- package/controllers/state.js +48 -1
- package/controllers/state.js.map +1 -1
- package/controllers/tree.d.ts +87 -0
- package/controllers/tree.js +0 -0
- package/controllers/tree.js.map +1 -0
- package/custom-elements.json +6491 -1355
- package/define.js.map +1 -1
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +77 -14
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +4 -4
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +3 -3
- package/docs/classes/ApexGrid.html +320 -24
- package/docs/functions/setup.html +16 -0
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +543 -9
- package/docs/interfaces/ApexCellValueChangedEvent.html +11 -0
- package/docs/interfaces/ApexCellValueChangingEvent.html +13 -0
- package/docs/interfaces/ApexColumnMovedEvent.html +8 -0
- package/docs/interfaces/ApexColumnMovingEvent.html +11 -0
- package/docs/interfaces/ApexColumnPinnedEvent.html +6 -0
- package/docs/interfaces/ApexColumnPinningEvent.html +8 -0
- package/docs/interfaces/ApexDetailContext.html +8 -0
- package/docs/interfaces/ApexFilteredEvent.html +4 -4
- package/docs/interfaces/ApexFilteringEvent.html +4 -4
- package/docs/interfaces/ApexGridEventMap.html +60 -9
- package/docs/interfaces/ApexHeaderContext.html +4 -4
- package/docs/interfaces/ApexPageChangedEvent.html +10 -0
- package/docs/interfaces/ApexPageChangingEvent.html +10 -0
- package/docs/interfaces/ApexQuickFilterChangedEvent.html +4 -0
- package/docs/interfaces/ApexQuickFilterChangingEvent.html +6 -0
- package/docs/interfaces/ApexRowEditEndedEvent.html +6 -0
- package/docs/interfaces/ApexRowEditStartedEvent.html +4 -0
- package/docs/interfaces/ApexRowExpandedEvent.html +8 -0
- package/docs/interfaces/ApexRowExpandingEvent.html +11 -0
- package/docs/interfaces/ApexRowSelectedEvent.html +8 -0
- package/docs/interfaces/ApexRowSelectingEvent.html +11 -0
- package/docs/interfaces/ApexTreeRowExpandedEvent.html +8 -0
- package/docs/interfaces/ApexTreeRowExpandingEvent.html +10 -0
- package/docs/interfaces/BaseApexCellContext.html +12 -6
- package/docs/interfaces/BaseApexEditorContext.html +19 -0
- package/docs/interfaces/BaseColumnConfiguration.html +88 -14
- package/docs/interfaces/BaseColumnSortConfiguration.html +4 -4
- package/docs/interfaces/BaseFilterExpression.html +5 -5
- package/docs/interfaces/BaseSortExpression.html +4 -4
- package/docs/interfaces/CSVExportOptions.html +22 -0
- package/docs/interfaces/ColumnFilterConfiguration.html +3 -3
- package/docs/interfaces/DataPipelineConfiguration.html +13 -4
- package/docs/interfaces/ExportFormat.html +10 -0
- package/docs/interfaces/ExportOptions.html +15 -0
- package/docs/interfaces/GridEditingConfiguration.html +10 -0
- package/docs/interfaces/GridExpansionConfiguration.html +15 -0
- package/docs/interfaces/GridSelectionConfiguration.html +11 -0
- package/docs/interfaces/GridSortConfiguration.html +4 -4
- package/docs/interfaces/GridTreeConfiguration.html +33 -0
- package/docs/interfaces/PaginationConfiguration.html +18 -0
- package/docs/interfaces/PaginationState.html +10 -0
- package/docs/media/LICENSE +80 -0
- package/docs/media/_tokens.scss +106 -0
- package/docs/media/package.json +85 -0
- package/docs/modules.html +1 -1
- package/docs/types/ApexCellContext.html +2 -2
- package/docs/types/ApexEditorContext.html +2 -0
- package/docs/types/BasePropertyType.html +2 -2
- package/docs/types/BaseSortComparer.html +2 -2
- package/docs/types/ColumnConfiguration.html +2 -2
- package/docs/types/ColumnDropPosition.html +2 -0
- package/docs/types/ColumnSortConfiguration.html +2 -2
- package/docs/types/DataPipelineHook.html +2 -2
- package/docs/types/DataPipelineParams.html +5 -5
- package/docs/types/DataType.html +47 -2
- package/docs/types/EditMode.html +6 -0
- package/docs/types/EditTrigger.html +4 -0
- package/docs/types/ExportCellValue.html +5 -0
- package/docs/types/ExportSource.html +8 -0
- package/docs/types/FilterCriteria.html +2 -2
- package/docs/types/FilterExpression.html +2 -2
- package/docs/types/Keys.html +2 -2
- package/docs/types/PaginationMode.html +6 -0
- package/docs/types/PinPosition.html +5 -0
- package/docs/types/PropertyType.html +2 -2
- package/docs/types/SelectionMode.html +7 -0
- package/docs/types/SortComparer.html +2 -2
- package/docs/types/SortExpression.html +2 -2
- package/docs/types/SortState.html +2 -2
- package/docs/types/SortingDirection.html +1 -1
- package/index.d.ts +5 -2
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/column-types.d.ts +94 -0
- package/internal/column-types.js +428 -0
- package/internal/column-types.js.map +1 -0
- package/internal/export.d.ts +114 -0
- package/internal/export.js +122 -0
- package/internal/export.js.map +1 -0
- package/internal/feature-module.d.ts +27 -0
- package/internal/feature-module.js +2 -0
- package/internal/feature-module.js.map +1 -0
- package/internal/flip.d.ts +80 -0
- package/internal/flip.js +52 -0
- package/internal/flip.js.map +1 -0
- package/internal/icons.d.ts +31 -0
- package/internal/icons.js +145 -0
- package/internal/icons.js.map +1 -0
- package/internal/index.d.ts +20 -0
- package/internal/index.js +6 -0
- package/internal/index.js.map +1 -0
- package/internal/tags.d.ts +2 -0
- package/internal/tags.js +2 -0
- package/internal/tags.js.map +1 -1
- package/internal/types.d.ts +473 -3
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +24 -1
- package/internal/utils.js +48 -7
- package/internal/utils.js.map +1 -1
- package/operations/filter/tree.d.ts +1 -1
- package/operations/filter/types.js.map +1 -1
- package/operations/pagination.d.ts +19 -0
- package/operations/pagination.js +12 -0
- package/operations/pagination.js.map +1 -0
- package/operations/quick-filter.d.ts +21 -0
- package/operations/quick-filter.js +26 -0
- package/operations/quick-filter.js.map +1 -0
- package/operations/sort/types.js.map +1 -1
- package/package.json +10 -5
- package/setup.d.ts +51 -0
- package/setup.js +31 -0
- package/setup.js.map +1 -0
- package/styles/_checkbox.css.js +3 -0
- package/styles/_checkbox.css.js.map +1 -0
- package/styles/_tokens.css.js +3 -0
- package/styles/_tokens.css.js.map +1 -0
- package/styles/body-cell/body-cell.css.js +1 -1
- package/styles/body-cell/body-cell.css.js.map +1 -1
- package/styles/body-cell/cell-renderers.css.js +3 -0
- package/styles/body-cell/cell-renderers.css.js.map +1 -0
- package/styles/body-row/body-row.css.js +1 -1
- package/styles/body-row/body-row.css.js.map +1 -1
- package/styles/filter-row/filter-row.css.js +1 -1
- package/styles/filter-row/filter-row.css.js.map +1 -1
- package/styles/grid/_grid.base.css.js +1 -1
- package/styles/grid/_grid.base.css.js.map +1 -1
- package/styles/grid/grid.css.js +3 -0
- package/styles/grid/grid.css.js.map +1 -0
- package/styles/header-cell/header-cell.css.js +1 -1
- package/styles/header-cell/header-cell.css.js.map +1 -1
- package/styles/header-row/header-row.base.css.js +1 -1
- package/styles/header-row/header-row.base.css.js.map +1 -1
- package/styles/paginator/paginator.css.d.ts +1 -0
- package/styles/paginator/paginator.css.js +3 -0
- package/styles/paginator/paginator.css.js.map +1 -0
- package/styles/toolbar/toolbar.css.d.ts +1 -0
- package/styles/toolbar/toolbar.css.js +3 -0
- package/styles/toolbar/toolbar.css.js.map +1 -0
- package/styles.css +17 -0
- package/internal/icon-registry.d.ts +0 -1
- package/internal/icon-registry.js +0 -29
- package/internal/icon-registry.js.map +0 -1
- package/internal/theming.d.ts +0 -34
- package/internal/theming.js +0 -123
- package/internal/theming.js.map +0 -1
- package/styles/grid/themes/light/grid.bootstrap.css.js +0 -3
- package/styles/grid/themes/light/grid.bootstrap.css.js.map +0 -1
- package/styles/grid/themes/light/grid.fluent.css.js +0 -3
- package/styles/grid/themes/light/grid.fluent.css.js.map +0 -1
- package/styles/grid/themes/light/grid.indigo.css.js +0 -3
- package/styles/grid/themes/light/grid.indigo.css.js.map +0 -1
- package/styles/grid/themes/light/grid.material.css.js +0 -3
- package/styles/grid/themes/light/grid.material.css.js.map +0 -1
- /package/styles/{grid/themes/light/grid.bootstrap.css.d.ts → _checkbox.css.d.ts} +0 -0
- /package/styles/{grid/themes/light/grid.fluent.css.d.ts → _tokens.css.d.ts} +0 -0
- /package/styles/{grid/themes/light/grid.indigo.css.d.ts → body-cell/cell-renderers.css.d.ts} +0 -0
- /package/styles/grid/{themes/light/grid.material.css.d.ts → grid.css.d.ts} +0 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { html, nothing, svg } from 'lit';
|
|
2
|
+
import { ref } from 'lit/directives/ref.js';
|
|
3
|
+
import { renderIcon } from './icons.js';
|
|
4
|
+
const RATING_DEFAULT_MAX = 5;
|
|
5
|
+
function getRatingMax(column) {
|
|
6
|
+
const max = typeof column.max === 'number' ? Math.floor(column.max) : RATING_DEFAULT_MAX;
|
|
7
|
+
return max > 0 ? max : RATING_DEFAULT_MAX;
|
|
8
|
+
}
|
|
9
|
+
function clampRating(value, max) {
|
|
10
|
+
const n = typeof value === 'number' ? value : Number(value ?? 0);
|
|
11
|
+
if (!Number.isFinite(n))
|
|
12
|
+
return 0;
|
|
13
|
+
if (n < 0)
|
|
14
|
+
return 0;
|
|
15
|
+
if (n > max)
|
|
16
|
+
return max;
|
|
17
|
+
return Math.round(n);
|
|
18
|
+
}
|
|
19
|
+
export function getSelectOptions(column) {
|
|
20
|
+
const raw = column.options ?? [];
|
|
21
|
+
return raw.map((entry) => {
|
|
22
|
+
if (entry !== null && typeof entry === 'object' && 'value' in entry) {
|
|
23
|
+
const opt = entry;
|
|
24
|
+
return { value: opt.value, label: opt.label ?? String(opt.value) };
|
|
25
|
+
}
|
|
26
|
+
return { value: entry, label: String(entry) };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const selectType = {
|
|
30
|
+
display(ctx) {
|
|
31
|
+
const opts = getSelectOptions(ctx.column);
|
|
32
|
+
const match = opts.find((o) => o.value === ctx.value);
|
|
33
|
+
const label = match?.label ?? (ctx.value == null ? '' : String(ctx.value));
|
|
34
|
+
return html `<span part="select-label">${label}</span>`;
|
|
35
|
+
},
|
|
36
|
+
editor(ctx) {
|
|
37
|
+
const opts = getSelectOptions(ctx.column);
|
|
38
|
+
const current = ctx.value;
|
|
39
|
+
const match = opts.find((o) => o.value === current);
|
|
40
|
+
const label = match?.label ?? (current == null ? '' : String(current));
|
|
41
|
+
const selectedIdx = Math.max(0, opts.findIndex((o) => o.value === current));
|
|
42
|
+
const mountPopover = (el) => {
|
|
43
|
+
if (!el)
|
|
44
|
+
return;
|
|
45
|
+
const popover = el;
|
|
46
|
+
if (popover.dataset.apexFocused)
|
|
47
|
+
return;
|
|
48
|
+
popover.dataset.apexFocused = '1';
|
|
49
|
+
const items = Array.from(popover.querySelectorAll('[part~="select-option"]'));
|
|
50
|
+
items[selectedIdx]?.focus();
|
|
51
|
+
};
|
|
52
|
+
const handleKeydown = (event) => {
|
|
53
|
+
const target = event.target;
|
|
54
|
+
const list = target.closest('[part~="select-popover"]');
|
|
55
|
+
if (!list)
|
|
56
|
+
return;
|
|
57
|
+
const items = Array.from(list.querySelectorAll('[part~="select-option"]'));
|
|
58
|
+
const idx = items.indexOf(target);
|
|
59
|
+
if (idx < 0)
|
|
60
|
+
return;
|
|
61
|
+
if (event.key === 'ArrowDown') {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
event.stopPropagation();
|
|
64
|
+
items[Math.min(idx + 1, items.length - 1)]?.focus();
|
|
65
|
+
}
|
|
66
|
+
else if (event.key === 'ArrowUp') {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
event.stopPropagation();
|
|
69
|
+
items[Math.max(idx - 1, 0)]?.focus();
|
|
70
|
+
}
|
|
71
|
+
else if (event.key === 'Home') {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
event.stopPropagation();
|
|
74
|
+
items[0]?.focus();
|
|
75
|
+
}
|
|
76
|
+
else if (event.key === 'End') {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
event.stopPropagation();
|
|
79
|
+
items[items.length - 1]?.focus();
|
|
80
|
+
}
|
|
81
|
+
else if (event.key === 'Enter' || event.key === ' ') {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
event.stopPropagation();
|
|
84
|
+
ctx.commit(opts[idx].value);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return html `<span part="select-label">${label}</span>
|
|
88
|
+
<div
|
|
89
|
+
part="select-popover"
|
|
90
|
+
role="listbox"
|
|
91
|
+
@keydown=${handleKeydown}
|
|
92
|
+
${ref(mountPopover)}
|
|
93
|
+
>
|
|
94
|
+
${opts.map((o, i) => html `<div
|
|
95
|
+
part=${o.value === current ? 'select-option selected' : 'select-option'}
|
|
96
|
+
role="option"
|
|
97
|
+
aria-selected=${o.value === current ? 'true' : 'false'}
|
|
98
|
+
tabindex=${i === selectedIdx ? '0' : '-1'}
|
|
99
|
+
data-apex-editor=${i === selectedIdx ? '' : nothing}
|
|
100
|
+
@click=${() => ctx.commit(o.value)}
|
|
101
|
+
>
|
|
102
|
+
${o.label}
|
|
103
|
+
</div>`)}
|
|
104
|
+
</div>`;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
export function parseDate(value) {
|
|
108
|
+
if (value instanceof Date) {
|
|
109
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
110
|
+
}
|
|
111
|
+
if (typeof value === 'number') {
|
|
112
|
+
const d = new Date(value);
|
|
113
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === 'string') {
|
|
116
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
117
|
+
if (match) {
|
|
118
|
+
const [, y, m, d] = match;
|
|
119
|
+
const date = new Date(Number(y), Number(m) - 1, Number(d));
|
|
120
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
121
|
+
}
|
|
122
|
+
const date = new Date(value);
|
|
123
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
function toDateInputValue(date) {
|
|
128
|
+
const y = date.getFullYear();
|
|
129
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
130
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
131
|
+
return `${y}-${m}-${d}`;
|
|
132
|
+
}
|
|
133
|
+
function formatDateValue(value, style) {
|
|
134
|
+
const date = parseDate(value);
|
|
135
|
+
if (!date)
|
|
136
|
+
return '';
|
|
137
|
+
return new Intl.DateTimeFormat(undefined, {
|
|
138
|
+
dateStyle: style,
|
|
139
|
+
}).format(date);
|
|
140
|
+
}
|
|
141
|
+
function commitDateInSameShape(original, next) {
|
|
142
|
+
if (next === null)
|
|
143
|
+
return null;
|
|
144
|
+
if (original instanceof Date)
|
|
145
|
+
return next;
|
|
146
|
+
if (typeof original === 'number')
|
|
147
|
+
return next.getTime();
|
|
148
|
+
return toDateInputValue(next);
|
|
149
|
+
}
|
|
150
|
+
const dateType = {
|
|
151
|
+
display(ctx) {
|
|
152
|
+
const style = ctx.column.format ?? 'medium';
|
|
153
|
+
return html `${formatDateValue(ctx.value, style)}`;
|
|
154
|
+
},
|
|
155
|
+
editor(ctx) {
|
|
156
|
+
const initial = parseDate(ctx.value);
|
|
157
|
+
const initialInput = initial ? toDateInputValue(initial) : '';
|
|
158
|
+
const handleChange = (event) => {
|
|
159
|
+
const raw = event.target.value;
|
|
160
|
+
const next = raw ? parseDate(raw) : null;
|
|
161
|
+
ctx.commit(commitDateInSameShape(ctx.value, next));
|
|
162
|
+
};
|
|
163
|
+
const handleKeydown = (event) => {
|
|
164
|
+
if (event.key === 'Enter') {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
event.stopPropagation();
|
|
167
|
+
const raw = event.target.value;
|
|
168
|
+
const next = raw ? parseDate(raw) : null;
|
|
169
|
+
ctx.commit(commitDateInSameShape(ctx.value, next));
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
return html `<input
|
|
173
|
+
type="date"
|
|
174
|
+
part="editor"
|
|
175
|
+
data-apex-editor
|
|
176
|
+
.value=${initialInput}
|
|
177
|
+
@change=${handleChange}
|
|
178
|
+
@keydown=${handleKeydown}
|
|
179
|
+
/>`;
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const ratingType = {
|
|
183
|
+
display(ctx) {
|
|
184
|
+
const max = getRatingMax(ctx.column);
|
|
185
|
+
const value = clampRating(ctx.value, max);
|
|
186
|
+
const stars = Array.from({ length: max }, (_, i) => i < value);
|
|
187
|
+
return html `<span part="rating" role="img" aria-label="${value} of ${max}">
|
|
188
|
+
${stars.map((filled) => html `<span part=${filled ? 'rating-star filled' : 'rating-star'} aria-hidden="true">
|
|
189
|
+
${renderIcon('star')}
|
|
190
|
+
</span>`)}
|
|
191
|
+
</span>`;
|
|
192
|
+
},
|
|
193
|
+
editor(ctx) {
|
|
194
|
+
const max = getRatingMax(ctx.column);
|
|
195
|
+
const current = clampRating(ctx.value, max);
|
|
196
|
+
const focusRank = Math.max(current, 1);
|
|
197
|
+
const commitTo = (next) => ctx.commit(clampRating(next, max));
|
|
198
|
+
const stars = Array.from({ length: max }, (_, i) => i + 1);
|
|
199
|
+
return html `<span
|
|
200
|
+
part="rating-editor"
|
|
201
|
+
role="radiogroup"
|
|
202
|
+
aria-label="Rating"
|
|
203
|
+
>
|
|
204
|
+
${stars.map((rank) => html `<button
|
|
205
|
+
type="button"
|
|
206
|
+
part=${rank <= current ? 'rating-star filled selected' : 'rating-star'}
|
|
207
|
+
role="radio"
|
|
208
|
+
aria-checked=${rank === current}
|
|
209
|
+
aria-label=${`${rank} of ${max}`}
|
|
210
|
+
data-rating-value=${rank}
|
|
211
|
+
data-apex-editor=${rank === focusRank ? '' : nothing}
|
|
212
|
+
@click=${() => commitTo(rank === current ? 0 : rank)}
|
|
213
|
+
>
|
|
214
|
+
${renderIcon('star')}
|
|
215
|
+
</button>`)}
|
|
216
|
+
</span>`;
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
const booleanType = {
|
|
220
|
+
display(ctx) {
|
|
221
|
+
const truthy = ctx.value === true;
|
|
222
|
+
const editable = typeof ctx.commit === 'function';
|
|
223
|
+
return html `<input
|
|
224
|
+
type="checkbox"
|
|
225
|
+
part=${truthy ? 'boolean-mark checked' : 'boolean-mark'}
|
|
226
|
+
.checked=${truthy}
|
|
227
|
+
tabindex=${editable ? '0' : '-1'}
|
|
228
|
+
aria-readonly=${editable ? 'false' : 'true'}
|
|
229
|
+
aria-label=${truthy ? 'true' : 'false'}
|
|
230
|
+
@click=${(event) => {
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
}}
|
|
233
|
+
@change=${editable
|
|
234
|
+
? (event) => {
|
|
235
|
+
const next = event.target.checked;
|
|
236
|
+
ctx.commit?.(next);
|
|
237
|
+
}
|
|
238
|
+
: undefined}
|
|
239
|
+
/>`;
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
const imageType = {
|
|
243
|
+
display(ctx) {
|
|
244
|
+
const value = ctx.value;
|
|
245
|
+
if (value == null || value === '')
|
|
246
|
+
return html ``;
|
|
247
|
+
const shape = ctx.column.shape ?? 'square';
|
|
248
|
+
const colAny = ctx.column;
|
|
249
|
+
const alt = colAny.alt ?? String(colAny.key ?? '');
|
|
250
|
+
return html `<img
|
|
251
|
+
part=${shape === 'circle' ? 'image circle' : 'image'}
|
|
252
|
+
src=${String(value)}
|
|
253
|
+
alt=${alt}
|
|
254
|
+
loading="lazy"
|
|
255
|
+
/>`;
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
function toFiniteNumber(value) {
|
|
259
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
260
|
+
return Number.isFinite(n) ? n : null;
|
|
261
|
+
}
|
|
262
|
+
function getPositiveMax(column, fallback) {
|
|
263
|
+
const m = typeof column.max === 'number' ? column.max : fallback;
|
|
264
|
+
return m > 0 ? m : fallback;
|
|
265
|
+
}
|
|
266
|
+
function hashHue(value) {
|
|
267
|
+
let hash = 0;
|
|
268
|
+
for (let i = 0; i < value.length; i++) {
|
|
269
|
+
hash = (hash * 31 + value.charCodeAt(i)) % 360;
|
|
270
|
+
}
|
|
271
|
+
return hash;
|
|
272
|
+
}
|
|
273
|
+
function inferStatus(value) {
|
|
274
|
+
const s = String(value ?? '').toLowerCase();
|
|
275
|
+
if (/churn|cancel|expired|inactive|lost|risk|fail|off|overdue/.test(s))
|
|
276
|
+
return 'churn';
|
|
277
|
+
if (/trial|trialing|pending|new|invited|watch|paused/.test(s))
|
|
278
|
+
return 'trial';
|
|
279
|
+
return 'active';
|
|
280
|
+
}
|
|
281
|
+
const currencyType = {
|
|
282
|
+
display(ctx) {
|
|
283
|
+
const col = ctx.column;
|
|
284
|
+
const n = toFiniteNumber(ctx.value);
|
|
285
|
+
if (n === null)
|
|
286
|
+
return html ``;
|
|
287
|
+
return html `${new Intl.NumberFormat(col.locale, {
|
|
288
|
+
style: 'currency',
|
|
289
|
+
currency: col.currency ?? 'USD',
|
|
290
|
+
}).format(n)}`;
|
|
291
|
+
},
|
|
292
|
+
editor(ctx) {
|
|
293
|
+
const commit = (event) => {
|
|
294
|
+
const raw = event.target.value;
|
|
295
|
+
ctx.commit(raw === '' ? null : Number(raw));
|
|
296
|
+
};
|
|
297
|
+
const handleKeydown = (event) => {
|
|
298
|
+
if (event.key === 'Enter') {
|
|
299
|
+
event.preventDefault();
|
|
300
|
+
event.stopPropagation();
|
|
301
|
+
commit(event);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
return html `<input
|
|
305
|
+
type="number"
|
|
306
|
+
part="editor"
|
|
307
|
+
data-apex-editor
|
|
308
|
+
.value=${ctx.value == null ? '' : String(ctx.value)}
|
|
309
|
+
@change=${commit}
|
|
310
|
+
@keydown=${handleKeydown}
|
|
311
|
+
/>`;
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const avatarType = {
|
|
315
|
+
display(ctx) {
|
|
316
|
+
const label = ctx.value == null ? '' : String(ctx.value);
|
|
317
|
+
const initial = label.trim().charAt(0).toUpperCase();
|
|
318
|
+
if (!initial)
|
|
319
|
+
return html ``;
|
|
320
|
+
return html `<span part="avatar" role="img" aria-label=${label} style="--ag-avatar-hue: ${hashHue(label)}"
|
|
321
|
+
>${initial}</span
|
|
322
|
+
>`;
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
const badgeType = {
|
|
326
|
+
display(ctx) {
|
|
327
|
+
const value = ctx.value;
|
|
328
|
+
if (value == null || value === '')
|
|
329
|
+
return html ``;
|
|
330
|
+
const col = ctx.column;
|
|
331
|
+
const variant = typeof col.badgeVariant === 'function'
|
|
332
|
+
? col.badgeVariant(value)
|
|
333
|
+
: (col.badgeVariant ?? 'neutral');
|
|
334
|
+
return html `<span part="pill pill--${variant}">${String(value)}</span>`;
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
const progressType = {
|
|
338
|
+
display(ctx) {
|
|
339
|
+
const n = toFiniteNumber(ctx.value);
|
|
340
|
+
if (n === null)
|
|
341
|
+
return html ``;
|
|
342
|
+
const max = getPositiveMax(ctx.column, 100);
|
|
343
|
+
const pct = Math.max(0, Math.min(100, (n / max) * 100));
|
|
344
|
+
const tier = pct >= 80 ? 'good' : pct >= 65 ? 'watch' : 'risk';
|
|
345
|
+
return html `<span part="progress">
|
|
346
|
+
<span part="progress-track">
|
|
347
|
+
<span part="progress-fill progress-fill--${tier}" style="width: ${pct}%"></span>
|
|
348
|
+
</span>
|
|
349
|
+
<span part="progress-label">${Math.round(pct)}</span>
|
|
350
|
+
</span>`;
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
const sparklineType = {
|
|
354
|
+
display(ctx) {
|
|
355
|
+
const series = Array.isArray(ctx.value)
|
|
356
|
+
? ctx.value.filter((v) => typeof v === 'number' && Number.isFinite(v))
|
|
357
|
+
: [];
|
|
358
|
+
if (series.length < 2)
|
|
359
|
+
return html ``;
|
|
360
|
+
const width = 64;
|
|
361
|
+
const height = 22;
|
|
362
|
+
const pad = 2;
|
|
363
|
+
const min = Math.min(...series);
|
|
364
|
+
const max = Math.max(...series);
|
|
365
|
+
const range = max - min || 1;
|
|
366
|
+
const stepX = width / (series.length - 1);
|
|
367
|
+
const points = series.map((value, i) => {
|
|
368
|
+
const x = i * stepX;
|
|
369
|
+
const y = pad + (height - 2 * pad) * (1 - (value - min) / range);
|
|
370
|
+
return `${x.toFixed(1)} ${y.toFixed(1)}`;
|
|
371
|
+
});
|
|
372
|
+
const line = `M${points.join(' L')}`;
|
|
373
|
+
const area = `${line} L${width} ${height} L0 ${height} Z`;
|
|
374
|
+
const first = series[0];
|
|
375
|
+
const last = series[series.length - 1];
|
|
376
|
+
const trend = last > first ? 'up' : last < first ? 'down' : 'flat';
|
|
377
|
+
const delta = first === 0 ? 0 : ((last - first) / Math.abs(first)) * 100;
|
|
378
|
+
const showDelta = ctx.column.showDelta !== false;
|
|
379
|
+
return html `<span part="spark-cell">
|
|
380
|
+
<svg
|
|
381
|
+
part="sparkline sparkline--${trend}"
|
|
382
|
+
viewBox="0 0 ${width} ${height}"
|
|
383
|
+
width=${width}
|
|
384
|
+
height=${height}
|
|
385
|
+
preserveAspectRatio="none"
|
|
386
|
+
aria-hidden="true"
|
|
387
|
+
>
|
|
388
|
+
${svg `<path part="spark-area" d=${area} /><path part="spark-line" d=${line} />`}
|
|
389
|
+
</svg>
|
|
390
|
+
${showDelta
|
|
391
|
+
? html `<span part="spark-delta spark-delta--${trend}"
|
|
392
|
+
>${delta > 0 ? '+' : ''}${delta.toFixed(0)}%</span
|
|
393
|
+
>`
|
|
394
|
+
: nothing}
|
|
395
|
+
</span>`;
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
const statusType = {
|
|
399
|
+
display(ctx) {
|
|
400
|
+
const value = ctx.value;
|
|
401
|
+
if (value == null || value === '')
|
|
402
|
+
return html ``;
|
|
403
|
+
const col = ctx.column;
|
|
404
|
+
const variant = typeof col.statusVariant === 'function'
|
|
405
|
+
? col.statusVariant(value)
|
|
406
|
+
: (col.statusVariant ?? inferStatus(value));
|
|
407
|
+
return html `<span part="status status--${variant}">
|
|
408
|
+
<span part="status-dot"></span>${String(value)}
|
|
409
|
+
</span>`;
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
const BUILTIN_TYPES = {
|
|
413
|
+
select: selectType,
|
|
414
|
+
rating: ratingType,
|
|
415
|
+
date: dateType,
|
|
416
|
+
boolean: booleanType,
|
|
417
|
+
image: imageType,
|
|
418
|
+
currency: currencyType,
|
|
419
|
+
avatar: avatarType,
|
|
420
|
+
badge: badgeType,
|
|
421
|
+
progress: progressType,
|
|
422
|
+
sparkline: sparklineType,
|
|
423
|
+
status: statusType,
|
|
424
|
+
};
|
|
425
|
+
export function getColumnTypeRenderer(type) {
|
|
426
|
+
return type ? BUILTIN_TYPES[type] : undefined;
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=column-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/internal/column-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAuB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,SAAS,YAAY,CAAC,MAAwB;IAC5C,MAAM,GAAG,GAAG,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC;IACzF,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,kBAAkB,CAAC;AAC5C,CAAC;AAED,SAAS,WAAW,CAAC,KAAc,EAAE,GAAW;IAC9C,MAAM,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAA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'lit';\nimport { ref } from 'lit/directives/ref.js';\nimport type ApexGridCell from '../components/cell.js';\nimport type ApexGridRow from '../components/row.js';\nimport { renderIcon } from './icons.js';\nimport type { BadgeVariant, ColumnConfiguration, StatusVariant } from './types.js';\n\nconst RATING_DEFAULT_MAX = 5;\n\nfunction getRatingMax(column: { max?: number }): number {\n const max = typeof column.max === 'number' ? Math.floor(column.max) : RATING_DEFAULT_MAX;\n return max > 0 ? max : RATING_DEFAULT_MAX;\n}\n\nfunction clampRating(value: unknown, max: number): number {\n const n = typeof value === 'number' ? value : Number(value ?? 0);\n if (!Number.isFinite(n)) return 0;\n if (n < 0) return 0;\n if (n > max) return max;\n return Math.round(n);\n}\n\n/**\n * An option entry for a `'select'` column. May be either a bare value (the\n * displayed label is `String(value)`) or an explicit `{ value, label }` pair.\n */\nexport type SelectOption<V = unknown> = V | { value: V; label?: string };\n\n/**\n * The flat, non-distributive cell context handed to a column-type renderer's\n * `display` function. Mirrors {@link ApexCellContext} but uses `unknown` for\n * `value` so renderers can author against a single shape without\n * conditional-type narrowing in generic positions.\n */\nexport interface ColumnTypeCellContext<T extends object> {\n parent: ApexGridCell<T>;\n row: ApexGridRow<T>;\n column: ColumnConfiguration<T>;\n value: unknown;\n /**\n * Commits a new value for this cell without entering edit mode. Only\n * present when the column is editable. Used by interactive display\n * widgets like the boolean checkbox.\n */\n commit?(value: unknown): Promise<boolean>;\n}\n\n/**\n * Cell context handed to a column-type renderer's `editor` function. Adds the\n * `commit` / `cancel` helpers wired through {@link EditingController}.\n */\nexport interface ColumnTypeEditorContext<T extends object> extends ColumnTypeCellContext<T> {\n commit(value: unknown): Promise<boolean>;\n cancel(): void;\n}\n\n/**\n * Built-in column-type renderer contract. A renderer can supply either a\n * display template, an editor template, or both. Cells fall back to the\n * column's `cellTemplate` / `editorTemplate` / built-in primitive editor if\n * the renderer is absent.\n */\nexport interface ColumnTypeRenderer<T extends object> {\n /**\n * Renders the display (read-only) representation of the cell.\n *\n * @remarks\n * Called when the cell is not in edit mode and the column has no\n * `cellTemplate`. Return any lit-renderable value.\n */\n display?(ctx: ColumnTypeCellContext<T>): TemplateResult | unknown;\n\n /**\n * Renders the inline editor while the cell is in edit mode.\n *\n * @remarks\n * Called when the cell is in edit mode and the column has no\n * `editorTemplate`. The returned template SHOULD include `data-apex-editor`\n * on its focusable element so the cell auto-focuses it. The editor is\n * responsible for calling `ctx.commit(value)` / `ctx.cancel()`.\n */\n editor?(ctx: ColumnTypeEditorContext<T>): TemplateResult | unknown;\n}\n\ninterface NormalizedSelectOption {\n value: unknown;\n label: string;\n}\n\n/**\n * Normalizes a column's `options` configuration into a uniform\n * `{ value, label }[]` list. Accepts both bare-value entries and explicit\n * `{ value, label }` pairs.\n */\nexport function getSelectOptions(column: { options?: SelectOption[] }): NormalizedSelectOption[] {\n const raw = column.options ?? [];\n return raw.map((entry) => {\n if (entry !== null && typeof entry === 'object' && 'value' in entry) {\n const opt = entry as { value: unknown; label?: string };\n return { value: opt.value, label: opt.label ?? String(opt.value) };\n }\n return { value: entry, label: String(entry) };\n });\n}\n\nconst selectType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const opts = getSelectOptions(ctx.column as { options?: SelectOption[] });\n const match = opts.find((o) => o.value === ctx.value);\n const label = match?.label ?? (ctx.value == null ? '' : String(ctx.value));\n // Closed-state display is intentionally plain text — the cell reads as\n // a normal value cell until the user double-clicks to edit. The\n // dropdown affordance appears only in edit mode (the listbox popover).\n return html`<span part=\"select-label\">${label}</span>`;\n },\n\n editor(ctx) {\n const opts = getSelectOptions(ctx.column as { options?: SelectOption[] });\n const current = ctx.value;\n const match = opts.find((o) => o.value === current);\n const label = match?.label ?? (current == null ? '' : String(current));\n const selectedIdx = Math.max(\n 0,\n opts.findIndex((o) => o.value === current)\n );\n\n // The popover is rendered as a `position: absolute` child of the cell\n // (the cell host is `position: relative`). That positions it relative\n // to the cell regardless of how the row is laid out — important\n // because the virtualizer applies `transform: translate` to each row,\n // which would re-anchor a `position: fixed` descendant onto the row.\n // The cell-level SCSS lifts `overflow: hidden` for select-type editing\n // cells so the popover can extend below the cell's box.\n const mountPopover = (el: Element | undefined) => {\n if (!el) return;\n const popover = el as HTMLElement;\n if (popover.dataset.apexFocused) return;\n popover.dataset.apexFocused = '1';\n const items = Array.from(popover.querySelectorAll<HTMLElement>('[part~=\"select-option\"]'));\n items[selectedIdx]?.focus();\n };\n\n const handleKeydown = (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const list = target.closest('[part~=\"select-popover\"]') as HTMLElement | null;\n if (!list) return;\n const items = Array.from(list.querySelectorAll<HTMLElement>('[part~=\"select-option\"]'));\n const idx = items.indexOf(target);\n if (idx < 0) return;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n items[Math.min(idx + 1, items.length - 1)]?.focus();\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n items[Math.max(idx - 1, 0)]?.focus();\n } else if (event.key === 'Home') {\n event.preventDefault();\n event.stopPropagation();\n items[0]?.focus();\n } else if (event.key === 'End') {\n event.preventDefault();\n event.stopPropagation();\n items[items.length - 1]?.focus();\n } else if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n event.stopPropagation();\n ctx.commit(opts[idx].value);\n }\n // Escape / Tab fall through to the cell-level handler which cancels /\n // exits — we don't consume them here so the standard exit flow applies.\n };\n\n return html`<span part=\"select-label\">${label}</span>\n <div\n part=\"select-popover\"\n role=\"listbox\"\n @keydown=${handleKeydown}\n ${ref(mountPopover)}\n >\n ${opts.map(\n (o, i) => html`<div\n part=${o.value === current ? 'select-option selected' : 'select-option'}\n role=\"option\"\n aria-selected=${o.value === current ? 'true' : 'false'}\n tabindex=${i === selectedIdx ? '0' : '-1'}\n data-apex-editor=${i === selectedIdx ? '' : nothing}\n @click=${() => ctx.commit(o.value)}\n >\n ${o.label}\n </div>`\n )}\n </div>`;\n },\n};\n\n/**\n * Parses a stored cell value into a `Date`, or `null` when the value can't be\n * resolved to a real date.\n *\n * @remarks\n * Accepts `Date` instances, ISO/parseable strings, and millisecond\n * timestamps. `YYYY-MM-DD` strings are interpreted as **floating dates**\n * (local midnight) rather than UTC midnight, so they render on the same\n * calendar day in every timezone.\n */\nexport function parseDate(value: unknown): Date | null {\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value;\n }\n if (typeof value === 'number') {\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? null : d;\n }\n if (typeof value === 'string') {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n if (match) {\n const [, y, m, d] = match;\n const date = new Date(Number(y), Number(m) - 1, Number(d));\n return Number.isNaN(date.getTime()) ? null : date;\n }\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n }\n return null;\n}\n\nfunction toDateInputValue(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, '0');\n const d = String(date.getDate()).padStart(2, '0');\n return `${y}-${m}-${d}`;\n}\n\nfunction formatDateValue(value: unknown, style: string): string {\n const date = parseDate(value);\n if (!date) return '';\n return new Intl.DateTimeFormat(undefined, {\n dateStyle: style as Intl.DateTimeFormatOptions['dateStyle'],\n }).format(date);\n}\n\n/**\n * Returns a `next` value cast to the same shape as `original` (Date / number\n * timestamp / ISO string). Empty inputs commit `null` regardless of the\n * source shape, which is the simplest \"clear\" semantics.\n */\nfunction commitDateInSameShape(original: unknown, next: Date | null): unknown {\n if (next === null) return null;\n if (original instanceof Date) return next;\n if (typeof original === 'number') return next.getTime();\n return toDateInputValue(next);\n}\n\nconst dateType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const style = (ctx.column as { format?: string }).format ?? 'medium';\n return html`${formatDateValue(ctx.value, style)}`;\n },\n\n editor(ctx) {\n const initial = parseDate(ctx.value);\n const initialInput = initial ? toDateInputValue(initial) : '';\n\n const handleChange = (event: Event) => {\n const raw = (event.target as HTMLInputElement).value;\n const next = raw ? parseDate(raw) : null;\n ctx.commit(commitDateInSameShape(ctx.value, next));\n };\n // Escape / Tab / focus-out are handled at the cell level; we only need\n // Enter here to commit the typed value without waiting for `change`.\n const handleKeydown = (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n const raw = (event.target as HTMLInputElement).value;\n const next = raw ? parseDate(raw) : null;\n ctx.commit(commitDateInSameShape(ctx.value, next));\n }\n };\n return html`<input\n type=\"date\"\n part=\"editor\"\n data-apex-editor\n .value=${initialInput}\n @change=${handleChange}\n @keydown=${handleKeydown}\n />`;\n },\n};\n\nconst ratingType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const max = getRatingMax(ctx.column as { max?: number });\n const value = clampRating(ctx.value, max);\n const stars = Array.from({ length: max }, (_, i) => i < value);\n return html`<span part=\"rating\" role=\"img\" aria-label=\"${value} of ${max}\">\n ${stars.map(\n (filled) =>\n html`<span part=${filled ? 'rating-star filled' : 'rating-star'} aria-hidden=\"true\">\n ${renderIcon('star')}\n </span>`\n )}\n </span>`;\n },\n\n editor(ctx) {\n const max = getRatingMax(ctx.column as { max?: number });\n const current = clampRating(ctx.value, max);\n const focusRank = Math.max(current, 1);\n\n const commitTo = (next: number) => ctx.commit(clampRating(next, max));\n\n // Escape / Tab / focus-out are handled at the cell level — no per-editor\n // handlers needed here. Clicking a star is the primary commit action;\n // clicking the currently-rated star clears the rating back to 0, which\n // is the only way to get below 1 once any star is set.\n const stars = Array.from({ length: max }, (_, i) => i + 1);\n return html`<span\n part=\"rating-editor\"\n role=\"radiogroup\"\n aria-label=\"Rating\"\n >\n ${stars.map(\n (rank) => html`<button\n type=\"button\"\n part=${rank <= current ? 'rating-star filled selected' : 'rating-star'}\n role=\"radio\"\n aria-checked=${rank === current}\n aria-label=${`${rank} of ${max}`}\n data-rating-value=${rank}\n data-apex-editor=${rank === focusRank ? '' : nothing}\n @click=${() => commitTo(rank === current ? 0 : rank)}\n >\n ${renderIcon('star')}\n </button>`\n )}\n </span>`;\n },\n};\n\nconst booleanType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const truthy = ctx.value === true;\n const editable = typeof ctx.commit === 'function';\n // For editable boolean cells the display IS the interactive control —\n // a single click toggles and commits via `ctx.commit`, no edit mode\n // dance and no visual reflow. For non-editable cells the checkbox\n // reads as a state indicator (tabindex=-1, aria-readonly, pointer-\n // events disabled via SCSS).\n return html`<input\n type=\"checkbox\"\n part=${truthy ? 'boolean-mark checked' : 'boolean-mark'}\n .checked=${truthy}\n tabindex=${editable ? '0' : '-1'}\n aria-readonly=${editable ? 'false' : 'true'}\n aria-label=${truthy ? 'true' : 'false'}\n @click=${(event: Event) => {\n // Keep the click inside the cell — we don't want it to bubble into\n // the grid body-click handler twice or trigger edit-mode logic.\n event.stopPropagation();\n }}\n @change=${\n editable\n ? (event: Event) => {\n const next = (event.target as HTMLInputElement).checked;\n ctx.commit?.(next);\n }\n : undefined\n }\n />`;\n },\n // No `editor` — boolean cells never enter edit mode (the display widget\n // commits directly). Programmatic `editCell` on a boolean column is a\n // no-op as far as the user can see.\n};\n\nconst imageType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const value = ctx.value;\n if (value == null || value === '') return html``;\n const shape = (ctx.column as { shape?: 'square' | 'circle' }).shape ?? 'square';\n const colAny = ctx.column as { alt?: string; key?: unknown };\n const alt = colAny.alt ?? String(colAny.key ?? '');\n return html`<img\n part=${shape === 'circle' ? 'image circle' : 'image'}\n src=${String(value)}\n alt=${alt}\n loading=\"lazy\"\n />`;\n },\n // Editing an image URL is just text editing — fall through to the default\n // text editor for `editable: true` image columns.\n};\n\n// ── Premium presentation renderers ─────────────────────────────────────────\n// currency / avatar / badge / progress / sparkline / status. These are display\n// presentations over primitive values; for sorting / filtering they behave as\n// their underlying value type. Styling lives in `styles/body-cell/cell-renderers.scss`.\n\nfunction toFiniteNumber(value: unknown): number | null {\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isFinite(n) ? n : null;\n}\n\nfunction getPositiveMax(column: { max?: number }, fallback: number): number {\n const m = typeof column.max === 'number' ? column.max : fallback;\n return m > 0 ? m : fallback;\n}\n\n/** Stable 0–359 hue derived from a string, for per-row avatar tinting. */\nfunction hashHue(value: string): number {\n let hash = 0;\n for (let i = 0; i < value.length; i++) {\n hash = (hash * 31 + value.charCodeAt(i)) % 360;\n }\n return hash;\n}\n\n/** Heuristic fallback mapping a free-text status to a known state. */\nfunction inferStatus(value: unknown): StatusVariant {\n const s = String(value ?? '').toLowerCase();\n if (/churn|cancel|expired|inactive|lost|risk|fail|off|overdue/.test(s)) return 'churn';\n if (/trial|trialing|pending|new|invited|watch|paused/.test(s)) return 'trial';\n return 'active';\n}\n\nconst currencyType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const col = ctx.column as { currency?: string; locale?: string };\n const n = toFiniteNumber(ctx.value);\n if (n === null) return html``;\n return html`${new Intl.NumberFormat(col.locale, {\n style: 'currency',\n currency: col.currency ?? 'USD',\n }).format(n)}`;\n },\n\n editor(ctx) {\n const commit = (event: Event) => {\n const raw = (event.target as HTMLInputElement).value;\n ctx.commit(raw === '' ? null : Number(raw));\n };\n const handleKeydown = (event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n commit(event);\n }\n };\n return html`<input\n type=\"number\"\n part=\"editor\"\n data-apex-editor\n .value=${ctx.value == null ? '' : String(ctx.value)}\n @change=${commit}\n @keydown=${handleKeydown}\n />`;\n },\n};\n\nconst avatarType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const label = ctx.value == null ? '' : String(ctx.value);\n const initial = label.trim().charAt(0).toUpperCase();\n if (!initial) return html``;\n return html`<span part=\"avatar\" role=\"img\" aria-label=${label} style=\"--ag-avatar-hue: ${hashHue(label)}\"\n >${initial}</span\n >`;\n },\n};\n\nconst badgeType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const value = ctx.value;\n if (value == null || value === '') return html``;\n const col = ctx.column as {\n badgeVariant?: BadgeVariant | ((value: unknown) => BadgeVariant);\n };\n const variant =\n typeof col.badgeVariant === 'function'\n ? col.badgeVariant(value)\n : (col.badgeVariant ?? 'neutral');\n return html`<span part=\"pill pill--${variant}\">${String(value)}</span>`;\n },\n};\n\nconst progressType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const n = toFiniteNumber(ctx.value);\n if (n === null) return html``;\n const max = getPositiveMax(ctx.column as { max?: number }, 100);\n const pct = Math.max(0, Math.min(100, (n / max) * 100));\n const tier = pct >= 80 ? 'good' : pct >= 65 ? 'watch' : 'risk';\n return html`<span part=\"progress\">\n <span part=\"progress-track\">\n <span part=\"progress-fill progress-fill--${tier}\" style=\"width: ${pct}%\"></span>\n </span>\n <span part=\"progress-label\">${Math.round(pct)}</span>\n </span>`;\n },\n};\n\nconst sparklineType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const series = Array.isArray(ctx.value)\n ? (ctx.value.filter((v) => typeof v === 'number' && Number.isFinite(v)) as number[])\n : [];\n if (series.length < 2) return html``;\n\n const width = 64;\n const height = 22;\n const pad = 2;\n const min = Math.min(...series);\n const max = Math.max(...series);\n const range = max - min || 1;\n const stepX = width / (series.length - 1);\n const points = series.map((value, i) => {\n const x = i * stepX;\n const y = pad + (height - 2 * pad) * (1 - (value - min) / range);\n return `${x.toFixed(1)} ${y.toFixed(1)}`;\n });\n const line = `M${points.join(' L')}`;\n const area = `${line} L${width} ${height} L0 ${height} Z`;\n\n const first = series[0];\n const last = series[series.length - 1];\n const trend = last > first ? 'up' : last < first ? 'down' : 'flat';\n const delta = first === 0 ? 0 : ((last - first) / Math.abs(first)) * 100;\n const showDelta = (ctx.column as { showDelta?: boolean }).showDelta !== false;\n\n return html`<span part=\"spark-cell\">\n <svg\n part=\"sparkline sparkline--${trend}\"\n viewBox=\"0 0 ${width} ${height}\"\n width=${width}\n height=${height}\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n >\n ${svg`<path part=\"spark-area\" d=${area} /><path part=\"spark-line\" d=${line} />`}\n </svg>\n ${\n showDelta\n ? html`<span part=\"spark-delta spark-delta--${trend}\"\n >${delta > 0 ? '+' : ''}${delta.toFixed(0)}%</span\n >`\n : nothing\n }\n </span>`;\n },\n};\n\nconst statusType: ColumnTypeRenderer<object> = {\n display(ctx) {\n const value = ctx.value;\n if (value == null || value === '') return html``;\n const col = ctx.column as {\n statusVariant?: StatusVariant | ((value: unknown) => StatusVariant);\n };\n const variant =\n typeof col.statusVariant === 'function'\n ? col.statusVariant(value)\n : (col.statusVariant ?? inferStatus(value));\n return html`<span part=\"status status--${variant}\">\n <span part=\"status-dot\"></span>${String(value)}\n </span>`;\n },\n};\n\nconst BUILTIN_TYPES: Record<string, ColumnTypeRenderer<object>> = {\n select: selectType,\n rating: ratingType,\n date: dateType,\n boolean: booleanType,\n image: imageType,\n currency: currencyType,\n avatar: avatarType,\n badge: badgeType,\n progress: progressType,\n sparkline: sparklineType,\n status: statusType,\n};\n\n/**\n * Returns the built-in renderer for a column `type`, or `undefined` when the\n * type has no built-in display/editor (the cell falls back to plain text /\n * the primitive editor in that case).\n */\nexport function getColumnTypeRenderer<T extends object>(\n type?: string\n): ColumnTypeRenderer<T> | undefined {\n return type ? (BUILTIN_TYPES[type] as unknown as ColumnTypeRenderer<T> | undefined) : undefined;\n}\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ApexGrid } from '../components/grid.js';
|
|
2
|
+
import type { ColumnConfiguration, Keys } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Primitive cell values supported by the export pipeline.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Returned by the default formatter and accepted from user-supplied formatters.
|
|
8
|
+
* `Date` is preserved (not stringified) so that XLSX export can write it as a
|
|
9
|
+
* native date cell instead of inline text.
|
|
10
|
+
*/
|
|
11
|
+
export type ExportCellValue = string | number | boolean | Date | null | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Which row set should drive the export.
|
|
14
|
+
*
|
|
15
|
+
* - `'view'` (default) — post-filter, post-sort rows across all pages.
|
|
16
|
+
* - `'all'` — the raw `data` array as supplied by the consumer.
|
|
17
|
+
* - `'page'` — only the rows in the current page slice.
|
|
18
|
+
* - `'selected'` — the current row selection (insertion order).
|
|
19
|
+
*/
|
|
20
|
+
export type ExportSource = 'view' | 'all' | 'page' | 'selected';
|
|
21
|
+
/**
|
|
22
|
+
* Options shared by all export targets.
|
|
23
|
+
*/
|
|
24
|
+
export interface ExportOptions<T extends object> {
|
|
25
|
+
/** Output filename, without extension. Defaults to `'data'`. */
|
|
26
|
+
filename?: string;
|
|
27
|
+
/** Row set to export. Defaults to `'view'`. */
|
|
28
|
+
source?: ExportSource;
|
|
29
|
+
/**
|
|
30
|
+
* Column keys to include. When omitted, every visible non-hidden column with
|
|
31
|
+
* `exportable !== false` is exported, in display order.
|
|
32
|
+
*/
|
|
33
|
+
columns?: ReadonlyArray<Keys<T>>;
|
|
34
|
+
/** Whether to emit a header row. Defaults to `true`. */
|
|
35
|
+
includeHeader?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Per-cell value formatter. Receives the column configuration, the raw value
|
|
38
|
+
* from the record, and the record itself. Return one of {@link ExportCellValue}
|
|
39
|
+
* (return a `Date` to keep date typing in XLSX).
|
|
40
|
+
*/
|
|
41
|
+
formatter?: (column: ColumnConfiguration<T>, value: unknown, row: T) => ExportCellValue;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options for {@link ApexGrid.exportToCSV}.
|
|
45
|
+
*/
|
|
46
|
+
export interface CSVExportOptions<T extends object> extends ExportOptions<T> {
|
|
47
|
+
/** Field delimiter. Defaults to `','`. */
|
|
48
|
+
delimiter?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Prepend a UTF-8 byte-order mark so Excel auto-detects the encoding when
|
|
51
|
+
* opening the file. Defaults to `true`.
|
|
52
|
+
*/
|
|
53
|
+
bom?: boolean;
|
|
54
|
+
/** Line separator. Defaults to `'\r\n'` (RFC 4180). */
|
|
55
|
+
newline?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Describes an export format offered by the grid's toolbar menu.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* The toolbar renders one menu item per entry returned by
|
|
62
|
+
* {@link ApexGrid.exportFormats} and dispatches the chosen `id` to
|
|
63
|
+
* {@link ApexGrid.exportAs}. The community grid offers `'csv'`; derived grids
|
|
64
|
+
* (e.g. `@apexcharts/grid-enterprise`) extend the list (e.g. with `'xlsx'`).
|
|
65
|
+
*/
|
|
66
|
+
export interface ExportFormat {
|
|
67
|
+
/** Stable format identifier, e.g. `'csv'`. */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Menu item label, e.g. `'Export CSV'`. */
|
|
70
|
+
label: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the columns that should appear in the export, in display order.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveExportColumns<T extends object>(grid: ApexGrid<T>, opts: ExportOptions<T>): Array<ColumnConfiguration<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the rows that should appear in the export.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveExportRows<T extends object>(grid: ApexGrid<T>, source?: ExportSource): ReadonlyArray<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the column's display label, used as the header cell value.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getColumnLabel<T extends object>(column: ColumnConfiguration<T>): string;
|
|
84
|
+
/**
|
|
85
|
+
* Default cell-value formatter. Mirrors the on-screen rendering for each
|
|
86
|
+
* column type while keeping primitive types primitive (so number/boolean/date
|
|
87
|
+
* survive into XLSX as native cells instead of strings).
|
|
88
|
+
*/
|
|
89
|
+
export declare function defaultExportFormat<T extends object>(column: ColumnConfiguration<T>, value: unknown): ExportCellValue;
|
|
90
|
+
/**
|
|
91
|
+
* Resolves the export value for a single cell, applying the user-supplied
|
|
92
|
+
* formatter when present and falling back to {@link defaultExportFormat}.
|
|
93
|
+
*/
|
|
94
|
+
export declare function resolveExportValue<T extends object>(column: ColumnConfiguration<T>, row: T, opts: ExportOptions<T>): ExportCellValue;
|
|
95
|
+
/** Formats a `Date` into the configured date style for CSV output. */
|
|
96
|
+
export declare function formatDateForCSV<T extends object>(column: ColumnConfiguration<T>, value: Date): string;
|
|
97
|
+
/**
|
|
98
|
+
* Builds the CSV string for the grid without triggering a download.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* Useful when consumers want to ship the bytes through their own transport
|
|
102
|
+
* (clipboard, HTTP upload). The {@link ApexGrid.exportToCSV} method calls
|
|
103
|
+
* this and then triggers a browser download.
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildCSV<T extends object>(grid: ApexGrid<T>, opts?: CSVExportOptions<T>): string;
|
|
106
|
+
/**
|
|
107
|
+
* Triggers a browser download for the given payload.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Falls back to a no-op when called outside the browser (during SSR or unit
|
|
111
|
+
* tests on JSDOM without a body), so consumers can still call the public
|
|
112
|
+
* export API safely.
|
|
113
|
+
*/
|
|
114
|
+
export declare function downloadBlob(filename: string, content: string | Uint8Array, mimeType: string): void;
|