@zeyos/zx 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +330 -0
- package/README.md +47 -9
- package/dist/types/components/activity-item/activity-item.d.ts +14 -3
- package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
- package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
- package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
- package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
- package/dist/types/components/approval-card/approval-card.d.ts +31 -2
- package/dist/types/components/aurora/aurora.d.ts +31 -5
- package/dist/types/components/calendar/calendar.d.ts +39 -26
- package/dist/types/components/chart/chart.d.ts +250 -20
- package/dist/types/components/chart/color.d.ts +66 -0
- package/dist/types/components/chart/svg-adapter.d.ts +103 -0
- package/dist/types/components/chart/svg-geometry.d.ts +203 -0
- package/dist/types/components/check-button/check-button.d.ts +1 -4
- package/dist/types/components/checklist/checklist.d.ts +48 -5
- package/dist/types/components/code-editor/code-editor.d.ts +55 -1
- package/dist/types/components/composer/composer.d.ts +41 -6
- package/dist/types/components/context-menu/context-menu.d.ts +36 -8
- package/dist/types/components/copy/copy-button.d.ts +6 -0
- package/dist/types/components/copy/copy-input.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +14 -0
- package/dist/types/components/date-picker/time-picker.d.ts +26 -17
- package/dist/types/components/datebox/datebox.d.ts +8 -4
- package/dist/types/components/dialog/dialog.d.ts +15 -4
- package/dist/types/components/empty-state/empty-state.d.ts +10 -1
- package/dist/types/components/field/field.d.ts +4 -2
- package/dist/types/components/form/form.d.ts +2 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
- package/dist/types/components/launcher/launcher.d.ts +26 -0
- package/dist/types/components/master-panel/master-panel.d.ts +9 -4
- package/dist/types/components/menu-button/menu-button.d.ts +29 -5
- package/dist/types/components/message/message.d.ts +308 -5
- package/dist/types/components/modal/modal.d.ts +45 -8
- package/dist/types/components/modal/native-dialog.d.ts +40 -0
- package/dist/types/components/module-bar/module-bar.d.ts +9 -2
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
- package/dist/types/components/number-field/number-field.d.ts +31 -1
- package/dist/types/components/pagination/pagination.d.ts +341 -19
- package/dist/types/components/run-status/run-status.d.ts +26 -0
- package/dist/types/components/run-trace/run-trace.d.ts +10 -6
- package/dist/types/components/search/search.d.ts +16 -4
- package/dist/types/components/select/select.d.ts +19 -1
- package/dist/types/components/sheet/sheet.d.ts +20 -6
- package/dist/types/components/slider/slider.d.ts +2 -1
- package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
- package/dist/types/components/stepper/stepper.d.ts +17 -4
- package/dist/types/components/surface/catalog.d.ts +61 -17
- package/dist/types/components/surface/surface.d.ts +6 -4
- package/dist/types/components/table/table.d.ts +207 -5
- package/dist/types/components/table/window.d.ts +25 -1
- package/dist/types/components/toggle/toggle.d.ts +38 -6
- package/dist/types/components/tooltip/tooltip.d.ts +5 -4
- package/dist/types/components/tree/tree.d.ts +43 -6
- package/dist/types/components/truncate/truncate.d.ts +4 -2
- package/dist/types/components/value-list/value-list.d.ts +9 -2
- package/dist/types/core/date.d.ts +2 -1
- package/dist/types/core/dom.d.ts +14 -0
- package/dist/types/core/drag-axis.d.ts +10 -5
- package/dist/types/core/export.d.ts +2 -2
- package/dist/types/core/format.d.ts +3 -1
- package/dist/types/core/icons.d.ts +36 -3
- package/dist/types/core/keyboard.d.ts +7 -3
- package/dist/types/core/messages.d.ts +3 -0
- package/dist/types/core/storage.d.ts +4 -3
- package/dist/types/core/util.d.ts +3 -1
- package/dist/types/elements/define.d.ts +5 -2
- package/dist/types/index.d.ts +6 -4
- package/dist/types/internal/agent-model.d.ts +99 -0
- package/dist/types/internal/app-rail.d.ts +37 -2
- package/dist/types/internal/collections.d.ts +18 -0
- package/dist/types/internal/menu-items.d.ts +27 -0
- package/dist/types/internal/overlay-content.d.ts +23 -0
- package/dist/types/internal/presence-loop.d.ts +5 -2
- package/dist/types/locales/index.d.ts +3 -0
- package/dist/types/zeyos/calendar.d.ts +43 -7
- package/dist/types/zeyos/connect.d.ts +4 -0
- package/dist/types/zeyos/form.d.ts +13 -5
- package/dist/types/zeyos/select.d.ts +5 -2
- package/dist/types/zeyos/table.d.ts +16 -8
- package/dist/types/zeyos/view.d.ts +2 -1
- package/dist/zx-zeyos.esm.js +3161 -515
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.core.css +4 -0
- package/dist/zx.core.min.css +1 -1
- package/dist/zx.css +970 -57
- package/dist/zx.esm.js +6405 -2249
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +6405 -2249
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +972 -57
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +159 -1
- package/docs/agent-surfaces.md +21 -21
- package/docs/api.json +3154 -518
- package/docs/components/account-menu.md +24 -0
- package/docs/components/activity-item.md +23 -0
- package/docs/components/activity-list.md +28 -0
- package/docs/components/agent-avatar.md +59 -0
- package/docs/components/agent-thread.md +275 -0
- package/docs/components/app-icon.md +36 -0
- package/docs/components/app-sidebar.md +92 -0
- package/docs/components/approval-card.md +71 -0
- package/docs/components/aurora.md +34 -0
- package/docs/components/avatar.md +37 -0
- package/docs/components/badge.md +36 -0
- package/docs/components/block-view.md +34 -0
- package/docs/components/breadcrumb.md +20 -0
- package/docs/components/button.md +23 -0
- package/docs/components/calendar.md +68 -0
- package/docs/components/card-view.md +73 -0
- package/docs/components/card.md +25 -0
- package/docs/components/chart.md +109 -0
- package/docs/components/check-button.md +16 -0
- package/docs/components/checklist.md +19 -0
- package/docs/components/code-editor.md +38 -0
- package/docs/components/composer.md +107 -0
- package/docs/components/context-menu.md +32 -0
- package/docs/components/copy.md +37 -0
- package/docs/components/data-filter.md +16 -0
- package/docs/components/date-picker.md +31 -0
- package/docs/components/date-range.md +21 -0
- package/docs/components/datebox.md +31 -0
- package/docs/components/dialog.md +25 -0
- package/docs/components/dock.md +57 -0
- package/docs/components/dropdown.md +39 -0
- package/docs/components/elements.md +63 -0
- package/docs/components/empty-state.md +17 -0
- package/docs/components/entity-ref.md +26 -0
- package/docs/components/field-upload.md +18 -0
- package/docs/components/file-item.md +27 -0
- package/docs/components/file-list.md +23 -0
- package/docs/components/filter-panel.md +45 -0
- package/docs/components/filter.md +47 -0
- package/docs/components/finder.md +25 -0
- package/docs/components/form-widgets.md +42 -0
- package/docs/components/form.md +80 -0
- package/docs/components/grid.md +26 -0
- package/docs/components/groupbox.md +11 -0
- package/docs/components/helpers.md +359 -0
- package/docs/components/icons.md +87 -0
- package/docs/components/index.md +99 -0
- package/docs/components/kanban-view.md +42 -0
- package/docs/components/kbd.md +23 -0
- package/docs/components/kernel.md +41 -0
- package/docs/components/launcher.md +66 -0
- package/docs/components/layout.md +33 -0
- package/docs/components/list-toolbar.md +38 -0
- package/docs/components/loading.md +48 -0
- package/docs/components/menu-button.md +47 -0
- package/docs/components/message.md +76 -0
- package/docs/components/modal.md +27 -0
- package/docs/components/module-bar.md +71 -0
- package/docs/components/multi-value-editor.md +16 -0
- package/docs/components/navigation-bar.md +22 -0
- package/docs/components/number-field.md +34 -0
- package/docs/components/pagination.md +73 -0
- package/docs/components/panel.md +28 -0
- package/docs/components/prompt-starters.md +40 -0
- package/docs/components/prose.md +38 -0
- package/docs/components/questionnaire.md +115 -0
- package/docs/components/rating.md +19 -0
- package/docs/components/run-status.md +50 -0
- package/docs/components/run-trace.md +72 -0
- package/docs/components/search.md +11 -0
- package/docs/components/select.md +129 -0
- package/docs/components/sheet-stack.md +39 -0
- package/docs/components/sheet.md +77 -0
- package/docs/components/skeleton.md +27 -0
- package/docs/components/slider.md +29 -0
- package/docs/components/sort-control.md +21 -0
- package/docs/components/source-list.md +30 -0
- package/docs/components/split-view.md +12 -0
- package/docs/components/stat-tile.md +49 -0
- package/docs/components/stepper.md +27 -0
- package/docs/components/surface.md +152 -0
- package/docs/components/tabbox.md +33 -0
- package/docs/components/table-view.md +43 -0
- package/docs/components/table.md +232 -0
- package/docs/components/tag-picker.md +39 -0
- package/docs/components/timebox.md +16 -0
- package/docs/components/toggle.md +21 -0
- package/docs/components/tokens.md +82 -0
- package/docs/components/toolbar.md +26 -0
- package/docs/components/tooltip.md +16 -0
- package/docs/components/tree.md +48 -0
- package/docs/components/truncate.md +21 -0
- package/docs/components/value-list.md +14 -0
- package/docs/components/view-settings.md +56 -0
- package/docs/components/workspace-switcher.md +42 -0
- package/docs/components/zeyos.md +196 -0
- package/docs/llms-small.txt +299 -0
- package/docs/llms.md +725 -109
- package/docs/llms.txt +46 -19
- package/package.json +9 -4
- package/src/components/activity-item/activity-item.js +21 -2
- package/src/components/agent-avatar/agent-avatar.css +195 -0
- package/src/components/agent-avatar/agent-avatar.js +333 -0
- package/src/components/agent-avatar/agent-face.js +292 -0
- package/src/components/agent-thread/ag-ui.js +44 -11
- package/src/components/agent-thread/agent-thread.js +103 -11
- package/src/components/agent-thread/ui-message-stream.js +3 -1
- package/src/components/app-rail/app-rail.css +5 -0
- package/src/components/app-sidebar/app-sidebar.css +3 -0
- package/src/components/app-sidebar/app-sidebar.js +4 -3
- package/src/components/approval-card/approval-card.css +6 -0
- package/src/components/approval-card/approval-card.js +55 -7
- package/src/components/aurora/aurora.css +149 -14
- package/src/components/aurora/aurora.js +49 -6
- package/src/components/button/button.css +24 -11
- package/src/components/calendar/calendar.css +6 -2
- package/src/components/calendar/calendar.js +127 -47
- package/src/components/card-view/card-view.js +5 -6
- package/src/components/chart/chart.css +159 -1
- package/src/components/chart/chart.js +450 -62
- package/src/components/chart/color.js +297 -0
- package/src/components/chart/svg-adapter.js +576 -0
- package/src/components/chart/svg-geometry.js +323 -0
- package/src/components/check-button/check-button.js +3 -18
- package/src/components/checklist/checklist.css +9 -1
- package/src/components/checklist/checklist.js +105 -20
- package/src/components/checklist/field-adapter.js +6 -12
- package/src/components/code-editor/code-editor.css +33 -0
- package/src/components/code-editor/code-editor.js +97 -8
- package/src/components/code-editor/field-adapter.js +3 -0
- package/src/components/composer/composer.css +3 -0
- package/src/components/composer/composer.js +100 -22
- package/src/components/context-menu/context-menu.js +41 -5
- package/src/components/copy/copy-button.js +9 -1
- package/src/components/copy/copy-input.js +5 -0
- package/src/components/data-filter/filter-core.js +0 -1
- package/src/components/date-picker/date-picker.css +8 -0
- package/src/components/date-picker/date-picker.js +47 -8
- package/src/components/date-picker/date-range-picker.js +1 -1
- package/src/components/date-picker/month-picker.js +19 -3
- package/src/components/date-picker/time-picker.js +54 -19
- package/src/components/datebox/date-range-box.js +7 -3
- package/src/components/datebox/datebox.js +32 -6
- package/src/components/dialog/dialog.css +6 -0
- package/src/components/dialog/dialog.js +24 -33
- package/src/components/dropdown/dropdown.js +1 -18
- package/src/components/empty-state/empty-state.js +21 -2
- package/src/components/field/field.js +19 -3
- package/src/components/fieldset/fieldset.js +3 -1
- package/src/components/filter/filter.js +9 -0
- package/src/components/form/form.js +19 -2
- package/src/components/kanban-view/kanban-card.js +15 -2
- package/src/components/kanban-view/kanban-view.css +21 -0
- package/src/components/kanban-view/kanban-view.js +29 -16
- package/src/components/launcher/launcher.css +14 -0
- package/src/components/launcher/launcher.js +54 -9
- package/src/components/master-panel/master-panel.js +24 -22
- package/src/components/menu-button/menu-button.js +26 -4
- package/src/components/message/message.css +228 -29
- package/src/components/message/message.js +664 -30
- package/src/components/modal/modal.js +129 -30
- package/src/components/modal/native-dialog.js +91 -0
- package/src/components/module-bar/module-bar.css +3 -0
- package/src/components/module-bar/module-bar.js +17 -4
- package/src/components/multi-value-editor/multi-value-editor.css +7 -2
- package/src/components/multi-value-editor/multi-value-editor.js +3 -2
- package/src/components/navigation-bar/navigation-bar.js +13 -1
- package/src/components/number-field/field-adapter.js +3 -0
- package/src/components/number-field/number-field.js +70 -16
- package/src/components/pagination/pagination.css +26 -2
- package/src/components/pagination/pagination.js +551 -65
- package/src/components/prose/prose.js +7 -1
- package/src/components/rating/field-adapter.js +3 -0
- package/src/components/run-status/run-status.js +43 -3
- package/src/components/run-trace/run-trace.js +15 -7
- package/src/components/search/search.js +3 -18
- package/src/components/select/field-adapter.js +8 -1
- package/src/components/select/select.js +68 -13
- package/src/components/sheet/sheet.js +39 -13
- package/src/components/slider/field-adapter.js +3 -0
- package/src/components/slider/slider.js +4 -6
- package/src/components/stat-tile/stat-tile.js +24 -9
- package/src/components/stepper/stepper.css +15 -0
- package/src/components/stepper/stepper.js +34 -2
- package/src/components/surface/catalog.js +185 -28
- package/src/components/surface/surface.js +10 -5
- package/src/components/tabbox/tabbox.js +13 -1
- package/src/components/table/table.css +160 -2
- package/src/components/table/table.js +479 -52
- package/src/components/table/window.js +46 -4
- package/src/components/table-view/table-view.js +1 -10
- package/src/components/tag-picker/field-adapter.js +3 -0
- package/src/components/tag-picker/tag-picker.js +2 -0
- package/src/components/timebox/field-adapter.js +3 -0
- package/src/components/toggle/toggle.js +51 -27
- package/src/components/tooltip/tooltip.js +21 -14
- package/src/components/tree/tree.js +87 -14
- package/src/components/truncate/truncate.js +21 -5
- package/src/components/value-list/value-list.js +37 -9
- package/src/components/view-settings/view-settings.js +1 -5
- package/src/core/component.js +34 -2
- package/src/core/date.js +5 -4
- package/src/core/dom.js +45 -2
- package/src/core/drag-axis.js +24 -7
- package/src/core/export.js +4 -4
- package/src/core/fontawesome.js +34 -3
- package/src/core/format.js +3 -1
- package/src/core/http.js +23 -11
- package/src/core/icons.js +60 -8
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +4 -3
- package/src/core/storage.js +80 -31
- package/src/core/util.js +16 -5
- package/src/elements/define.js +82 -47
- package/src/elements/kit.js +46 -35
- package/src/index.js +8 -4
- package/src/internal/agent-model.js +152 -0
- package/src/internal/app-rail.js +53 -2
- package/src/internal/collections.js +25 -0
- package/src/internal/menu-items.js +59 -0
- package/src/internal/overlay-content.js +35 -0
- package/src/internal/presence-loop.js +61 -14
- package/src/locales/de.js +3 -0
- package/src/zeyos/calendar.js +81 -19
- package/src/zeyos/connect.js +5 -1
- package/src/zeyos/form.js +29 -10
- package/src/zeyos/select.js +36 -12
- package/src/zeyos/table.js +43 -11
- package/src/zeyos/view.js +2 -1
- package/styles/tokens/semantic.css +7 -1
- package/styles/zx.css +1 -0
|
@@ -11,6 +11,11 @@ import { icon } from '../../core/icons.js';
|
|
|
11
11
|
* @property {number} [step=1] Increment applied by the buttons and arrow keys.
|
|
12
12
|
* @property {number} [largeStep=10] Multiple of `step` applied by PageUp/PageDown.
|
|
13
13
|
* @property {number|null} [precision=null] Decimal places; derived from `step` when null.
|
|
14
|
+
* @property {boolean} [snap=true] Whether a typed or assigned value is moved onto the `step` grid.
|
|
15
|
+
* With `false` the value is kept exactly as entered — `step` is then only the increment of the
|
|
16
|
+
* buttons and arrow keys, and decimals are rounded only to an explicit `precision`. `min` and
|
|
17
|
+
* `max` still apply. Use it for values that are not multiples of anything: an identifier, a
|
|
18
|
+
* seed, a measurement.
|
|
14
19
|
* @property {boolean} [wrap=false] Whether stepping past a bound wraps to the other one.
|
|
15
20
|
* @property {string} [placeholder=''] Empty-state text.
|
|
16
21
|
* @property {string|null} [label=null] Accessible name for the spinbutton.
|
|
@@ -48,6 +53,7 @@ export class NumberField extends Component {
|
|
|
48
53
|
step: 1,
|
|
49
54
|
largeStep: 10,
|
|
50
55
|
precision: null,
|
|
56
|
+
snap: true,
|
|
51
57
|
wrap: false,
|
|
52
58
|
placeholder: '',
|
|
53
59
|
label: null,
|
|
@@ -75,9 +81,13 @@ export class NumberField extends Component {
|
|
|
75
81
|
|
|
76
82
|
const step = normalizeStep(this.options.step);
|
|
77
83
|
this._step = step;
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
this._snap = this.options.snap !== false;
|
|
85
|
+
const explicit = this.options.precision !== null && this.options.precision !== undefined;
|
|
86
|
+
this._precision = explicit
|
|
87
|
+
? Math.max(0, Math.trunc(Number(this.options.precision) || 0))
|
|
88
|
+
: decimalsOf(step);
|
|
89
|
+
// Without snapping, only a precision the application asked for may round a value.
|
|
90
|
+
this._fixedPrecision = this._snap || explicit;
|
|
81
91
|
|
|
82
92
|
const down = this._stepButton('down', 'minus');
|
|
83
93
|
const up = this._stepButton('up', 'plus');
|
|
@@ -86,7 +96,7 @@ export class NumberField extends Component {
|
|
|
86
96
|
class: 'zx-number-field__input',
|
|
87
97
|
type: 'text',
|
|
88
98
|
role: 'spinbutton',
|
|
89
|
-
inputMode: this._precision > 0 ? 'decimal' : 'numeric',
|
|
99
|
+
inputMode: this._precision > 0 || !this._fixedPrecision ? 'decimal' : 'numeric',
|
|
90
100
|
autocomplete: 'off',
|
|
91
101
|
spellcheck: false,
|
|
92
102
|
placeholder: String(this.options.placeholder ?? ''),
|
|
@@ -153,7 +163,8 @@ export class NumberField extends Component {
|
|
|
153
163
|
}
|
|
154
164
|
|
|
155
165
|
/**
|
|
156
|
-
* Sets the value,
|
|
166
|
+
* Sets the value, clamping it into `[min, max]` and — unless `snap` is off — moving it onto the
|
|
167
|
+
* `step` grid.
|
|
157
168
|
* @param {number|string|null} next Next value; empty strings and null clear the field.
|
|
158
169
|
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
|
|
159
170
|
* @returns {this}
|
|
@@ -277,6 +288,16 @@ export class NumberField extends Component {
|
|
|
277
288
|
_coerce(raw) {
|
|
278
289
|
const parsed = parseNumber(raw, this.options.group ? this._separators() : null);
|
|
279
290
|
if (parsed === null) return null;
|
|
291
|
+
if (!this._snap) {
|
|
292
|
+
// Past the digits a double can round to, rounding would only turn a tiny value into zero.
|
|
293
|
+
if (this._decimalsFor(parsed) > ROUNDABLE_DECIMALS) return clampNumber(parsed, this._rangeMin, this._rangeMax);
|
|
294
|
+
return snapNumber(parsed, {
|
|
295
|
+
min: this._rangeMin,
|
|
296
|
+
max: this._rangeMax,
|
|
297
|
+
step: 0,
|
|
298
|
+
precision: this._decimalsFor(parsed)
|
|
299
|
+
});
|
|
300
|
+
}
|
|
280
301
|
return snapNumber(parsed, {
|
|
281
302
|
min: this._rangeMin,
|
|
282
303
|
max: this._rangeMax,
|
|
@@ -301,7 +322,8 @@ export class NumberField extends Component {
|
|
|
301
322
|
const base = current === null ? (min ?? 0) : current;
|
|
302
323
|
// An empty field steps to the lower bound first, so the first click lands on a real value.
|
|
303
324
|
const start = current === null && count > 0 && min !== null ? min - this._step * count : base;
|
|
304
|
-
|
|
325
|
+
const decimals = this._decimalsFor(start);
|
|
326
|
+
let next = decimals > ROUNDABLE_DECIMALS ? start + this._step * count : round(start + this._step * count, decimals);
|
|
305
327
|
|
|
306
328
|
if (this.options.wrap && min !== null && max !== null) {
|
|
307
329
|
if (next > max) next = min;
|
|
@@ -412,17 +434,29 @@ export class NumberField extends Component {
|
|
|
412
434
|
*/
|
|
413
435
|
_format(value, editing) {
|
|
414
436
|
// Ungrouped fields use a plain machine format, which `parseNumber` reads heuristically.
|
|
415
|
-
|
|
437
|
+
const decimals = this._decimalsFor(value);
|
|
438
|
+
if (!this.options.group) return value.toFixed(decimals);
|
|
416
439
|
// Grouped fields stay in the locale's notation even while editing — only the thousands
|
|
417
440
|
// separators drop away. Display and input therefore always use the same decimal character,
|
|
418
441
|
// so a value the field rendered is always a value it can read back.
|
|
419
442
|
return new Intl.NumberFormat(formattingLocale(this.options.locale), {
|
|
420
|
-
minimumFractionDigits:
|
|
421
|
-
maximumFractionDigits:
|
|
443
|
+
minimumFractionDigits: decimals,
|
|
444
|
+
maximumFractionDigits: decimals,
|
|
422
445
|
useGrouping: !editing
|
|
423
446
|
}).format(value);
|
|
424
447
|
}
|
|
425
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Decimal places a value is held and shown at: the field's precision, widened to the value's
|
|
451
|
+
* own decimals when nothing fixed the precision (`snap: false` without `precision`).
|
|
452
|
+
* @param {number} value Value in question.
|
|
453
|
+
* @returns {number}
|
|
454
|
+
*/
|
|
455
|
+
_decimalsFor(value) {
|
|
456
|
+
if (this._fixedPrecision) return this._precision;
|
|
457
|
+
return Math.min(MAX_DECIMALS, Math.max(this._precision, decimalsOf(value)));
|
|
458
|
+
}
|
|
459
|
+
|
|
426
460
|
/**
|
|
427
461
|
* @param {string} key Message key.
|
|
428
462
|
* @param {string} fallback Text used when the host has no translation.
|
|
@@ -541,13 +575,33 @@ function normalizeStep(step) {
|
|
|
541
575
|
return Number.isFinite(value) && value > 0 ? value : 1;
|
|
542
576
|
}
|
|
543
577
|
|
|
544
|
-
/**
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
578
|
+
/** Most decimals a value is displayed with (the limit of `toFixed`). */
|
|
579
|
+
const MAX_DECIMALS = 100;
|
|
580
|
+
/** Most decimals `round()` works to; an unsnapped value needing more is left unrounded. */
|
|
581
|
+
const ROUNDABLE_DECIMALS = 15;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @param {number} value Value to bound.
|
|
585
|
+
* @param {number|null} min Lower bound.
|
|
586
|
+
* @param {number|null} max Upper bound.
|
|
587
|
+
* @returns {number}
|
|
588
|
+
*/
|
|
589
|
+
function clampNumber(value, min, max) {
|
|
590
|
+
if (min !== null && value < min) return min;
|
|
591
|
+
if (max !== null && value > max) return max;
|
|
592
|
+
return value;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Decimal places in a number's shortest exact notation, exponent form included (`2.5e-7` has 8).
|
|
597
|
+
* Shared with Slider, whose `stepPrecision()` is this.
|
|
598
|
+
* @param {number} value Number to measure.
|
|
599
|
+
* @returns {number}
|
|
600
|
+
*/
|
|
601
|
+
export function decimalsOf(value) {
|
|
602
|
+
const [mantissa, exponent = '0'] = String(value).toLowerCase().split('e');
|
|
603
|
+
const fraction = mantissa.split('.')[1]?.length ?? 0;
|
|
604
|
+
return Math.max(0, fraction - Number(exponent));
|
|
551
605
|
}
|
|
552
606
|
|
|
553
607
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Pagination — the footer bar of a server-backed list.
|
|
3
3
|
*
|
|
4
|
-
* One row that wraps: the summary
|
|
5
|
-
* start, the pager sits alone at the end. Page buttons are ordinary `.zx-btn` controls so they inherit the library's control
|
|
4
|
+
* One row that wraps: the summary, the page-size select, and the Auto-load switch describe the
|
|
5
|
+
* slice and sit at the start, the pager (or Load more) sits alone at the end. Page buttons are ordinary `.zx-btn` controls so they inherit the library's control
|
|
6
6
|
* height, radius, and focus ring; the current page takes the neutral current fill — it is where
|
|
7
7
|
* you are, not a call to action.
|
|
8
8
|
*/
|
|
@@ -95,3 +95,27 @@
|
|
|
95
95
|
.zx-pagination[data-mode="loadmore"] .zx-pagination__more {
|
|
96
96
|
flex: none;
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
/* Both ends are built once; the one the mode does not use is hidden. Their own display rules would
|
|
100
|
+
otherwise outrank the attribute. */
|
|
101
|
+
.zx-pagination :is(.zx-pagination__controls, .zx-pagination__more)[hidden] {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* The switch reads as part of the bar's quiet description, not as a form field. */
|
|
106
|
+
.zx-pagination__autoload {
|
|
107
|
+
display: inline-flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
white-space: nowrap;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.zx-pagination__autoload .zx-toggle {
|
|
113
|
+
min-block-size: calc(var(--zx-control-height) - var(--zx-space-1));
|
|
114
|
+
align-items: center;
|
|
115
|
+
color: var(--zx-color-text-muted);
|
|
116
|
+
font-size: var(--zx-text-sm);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.zx-pagination__autoload .zx-toggle__track {
|
|
120
|
+
margin-block-start: 0;
|
|
121
|
+
}
|