@orbitcommerce/constellation-docs 1.0.0 → 1.2.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/docs.css +14764 -2237
- package/dist/index.js +2 -2
- package/dist/pages/{Playground-CNbBbErC.js → Playground-Mk1yIWXb.js} +2 -2
- package/dist/pages/_address-data-L9BR499w.js +161 -0
- package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
- package/dist/pages/_card-art-0be5ncyV.js +18 -0
- package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
- package/dist/pages/{_figures-data-BDmScEny.js → _figures-data-DaDvB7Nm.js} +5 -5
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/{_overlays-specimens-Dpn6oiyH.js → _overlays-specimens-bawR331Z.js} +33 -23
- package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
- package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
- package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
- package/dist/pages/address-block-BZOOOPA9.js +368 -0
- package/dist/pages/address-fields-CwSqro3W.js +277 -0
- package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
- package/dist/pages/{alert-BD4e6QTh.js → alert-D3i7xZTU.js} +195 -50
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/{app-shell-KbA-nRqZ.js → app-shell-D4hdlHps.js} +133 -54
- package/dist/pages/{area-chart-B91dLcGo.js → area-chart-BEWFwiB2.js} +183 -27
- package/dist/pages/{avatar-DPPHXJAu.js → avatar-BFEqQViw.js} +194 -12
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/{badge-C9JR0thI.js → badge-0-PyMrih.js} +441 -135
- package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
- package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
- package/dist/pages/board-card-D2tZY_mU.js +415 -0
- package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
- package/dist/pages/{button-D3V912P4.js → button-DAyfssDY.js} +276 -79
- package/dist/pages/{calendar-DSDZ9nRH.js → calendar-Ds7KsgSI.js} +69 -17
- package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
- package/dist/pages/card-CQEM1_wc.js +1567 -0
- package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
- package/dist/pages/chart-legend-B20AbakD.js +724 -0
- package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
- package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
- package/dist/pages/checklist-card-DEyykVFS.js +783 -0
- package/dist/pages/chip-Ck-o3Ui6.js +839 -0
- package/dist/pages/chip-list-k1LxXuCi.js +414 -0
- package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
- package/dist/pages/coachmark-Be2ghobT.js +366 -0
- package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
- package/dist/pages/collab-field-CfqqK7d2.js +696 -0
- package/dist/pages/color-field-CZpfcA-A.js +1127 -0
- package/dist/pages/{colour-BwuO8xAv.js → colour-q2ntvI0w.js} +496 -20
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/{command-palette-xAD7fOg6.js → command-palette-CJ7uBA04.js} +201 -58
- package/dist/pages/comment-box-CDSGYhr5.js +346 -0
- package/dist/pages/composer-D4B0NgpA.js +689 -0
- package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
- package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
- package/dist/pages/context-menu-F9DV30ia.js +487 -0
- package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
- package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
- package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
- package/dist/pages/date-input-GOW067EB.js +956 -0
- package/dist/pages/{date-picker-BYSa816m.js → date-picker-GdBciR99.js} +186 -38
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/{delta-CtAo0eIM.js → delta-CNAGv8JY.js} +266 -61
- package/dist/pages/description-list-BPeXn1eW.js +1268 -0
- package/dist/pages/device-switcher-BCaN99c1.js +554 -0
- package/dist/pages/dialog-CRpkRC98.js +3164 -0
- package/dist/pages/{docs-BNOb7AqR.js → docs-lM2UBSir.js} +20 -15
- package/dist/pages/doodle-nzkqi2UI.js +201 -0
- package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
- package/dist/pages/drill-menu-cskH5mol.js +490 -0
- package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
- package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
- package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
- package/dist/pages/empty-state-4U2txFpI.js +1113 -0
- package/dist/pages/facet-filters-McbBeY9e.js +353 -0
- package/dist/pages/figure-D-HF5vCj.js +563 -0
- package/dist/pages/figure-strip-BB3mNl7D.js +1364 -0
- package/dist/pages/{figure-tabs-CoPFzzKz.js → figure-tabs-QOeQMY6N.js} +153 -35
- package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
- package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
- package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
- package/dist/pages/form-grid-BfWCVlie.js +692 -0
- package/dist/pages/gallery-BBk2EOri.js +453 -0
- package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
- package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
- package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
- package/dist/pages/heatmap-BohgIcNk.js +507 -0
- package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
- package/dist/pages/{home-dashboard-CFQwDtC9.js → home-dashboard-CxPmvduE.js} +21 -18
- package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
- package/dist/pages/hosted-field-BLh-53AE.js +208 -0
- package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
- package/dist/pages/{icon-button-C9eSVPPW.js → icon-button-Bu4Gj5sy.js} +370 -31
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/{icons-sxkTs5Ob.js → icons-CJ9Aar3d.js} +315 -52
- package/dist/pages/image-cropper-NyougqLH.js +466 -0
- package/dist/pages/image-field-7knBv4mJ.js +567 -0
- package/dist/pages/import-result-CmTtGXW_.js +486 -0
- package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
- package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
- package/dist/pages/input-CzLCzfyx.js +2372 -0
- package/dist/pages/{installation-DpsX8G_n.js → installation-C3UcpQJT.js} +112 -29
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/{kbd-cNfDoikz.js → kbd-UNj4zqxn.js} +15 -14
- package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
- package/dist/pages/line-chart-CntWxeMF.js +1117 -0
- package/dist/pages/link-CXqvAg9z.js +689 -0
- package/dist/pages/link-picker-BMFGCC67.js +478 -0
- package/dist/pages/link-row-x8yaUuWc.js +595 -0
- package/dist/pages/{live-globe-ClvLn9Lb.js → live-globe-95ROMhGQ.js} +191 -47
- package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
- package/dist/pages/loading-state-BNbCo51C.js +556 -0
- package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
- package/dist/pages/{logo-BfGF1Pq9.js → logo-B38rnzoq.js} +13 -13
- package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
- package/dist/pages/markdown-Ied72vMT.js +237 -0
- package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
- package/dist/pages/media-banner-DkStCia0.js +233 -0
- package/dist/pages/{menu-by2sgQ09.js → menu-NrLYKqKp.js} +623 -109
- package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
- package/dist/pages/meta-line-D5p2TycR.js +371 -0
- package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
- package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
- package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
- package/dist/pages/{motion-BvTGc2Dk.js → motion-CrXtiBvA.js} +20 -10
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/{orbit-spinner-Dil1Z3Oy.js → orbit-spinner-Dxv5qAhr.js} +30 -14
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/{overview-BPEbZQ6g.js → overview-LA9XRhZc.js} +4 -4
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/{pagination-BBUnGvv5.js → pagination-C1EgVtW4.js} +74 -29
- package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
- package/dist/pages/password-field-DHEQKyUC.js +912 -0
- package/dist/pages/person-cell-BmjbADBz.js +564 -0
- package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
- package/dist/pages/plan-card-DRaA6RuB.js +621 -0
- package/dist/pages/plan-card-DtloWvMh.js +258 -0
- package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
- package/dist/pages/plan-grid-cfPVTB5V.js +251 -0
- package/dist/pages/point-list-BbPmZjsm.js +222 -0
- package/dist/pages/{popover-Db1gLDpb.js → popover-C3Oar9D5.js} +76 -14
- package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
- package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
- package/dist/pages/price-CRBLoa9h.js +604 -0
- package/dist/pages/{principles-CeAIOIdt.js → principles-pnDyfHpK.js} +9 -9
- package/dist/pages/print-page-BkLv6bW8.js +513 -0
- package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
- package/dist/pages/progress-CP_awmo4.js +904 -0
- package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
- package/dist/pages/{radio-group-CkdBWWfG.js → radio-group-C-4tg6FS.js} +580 -18
- package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
- package/dist/pages/rating-CweKN2SX.js +471 -0
- package/dist/pages/record-layout-DUP_X0RL.js +719 -0
- package/dist/pages/record-pager-y9D7JFgb.js +278 -0
- package/dist/pages/registry-BZg-xAbi.js +594 -0
- package/dist/pages/{release-Dvo684UJ.js → release-Cs6tl16C.js} +4 -1
- package/dist/pages/repeater-BRZYKRQa.js +1351 -0
- package/dist/pages/reply-feedback-BDnHprla.js +192 -0
- package/dist/pages/reveal-BygENBbL.js +460 -0
- package/dist/pages/rich-text-DOFQZEpT.js +156 -0
- package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
- package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
- package/dist/pages/{rolling-number-qmvH84Mq.js → rolling-number-GR3Cyfpz.js} +12 -12
- package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
- package/dist/pages/rule-list-DTCmIMpT.js +648 -0
- package/dist/pages/save-status-B5KkyMZP.js +378 -0
- package/dist/pages/schedule-YycI95O1.js +243 -0
- package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
- package/dist/pages/{search-field-BN7MWGQ4.js → search-field-D1uG7R6A.js} +15 -15
- package/dist/pages/search-menu-DMuXyUUW.js +580 -0
- package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
- package/dist/pages/section-rail-BtTCETS5.js +637 -0
- package/dist/pages/section-v2Pubup9.js +639 -0
- package/dist/pages/{segmented-control-CTbIpRBW.js → segmented-control-D-FB1K1T.js} +450 -37
- package/dist/pages/{select-DguELoRR.js → select-DZ43NpOm.js} +22 -17
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/{separator-CPZub9pv.js → separator-CFwqRvfO.js} +99 -22
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/{shape-DKvA0YKr.js → shape-DzniHAVT.js} +10 -10
- package/dist/pages/share-list-D4wgBxKN.js +926 -0
- package/dist/pages/side-panel-CCtkrZjs.js +811 -0
- package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
- package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
- package/dist/pages/skip-link-BxznhSkz.js +252 -0
- package/dist/pages/slider-CAoPURKD.js +774 -0
- package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
- package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
- package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
- package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
- package/dist/pages/{sparkline-DMMYGbHn.js → sparkline-D3aavCly.js} +301 -22
- package/dist/pages/split-bar-DYgZnFID.js +414 -0
- package/dist/pages/split-button-Be08-VI-.js +335 -0
- package/dist/pages/split-pane-lSNZgTKt.js +523 -0
- package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
- package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
- package/dist/pages/status-dot-D99gAGsV.js +567 -0
- package/dist/pages/stepper-CxKTbEA-.js +1093 -0
- package/dist/pages/success-mark-CqFTOBEu.js +142 -0
- package/dist/pages/swatch-H_kNvHuC.js +565 -0
- package/dist/pages/{switch-B-Qe4kcT.js → switch-C93K6j9h.js} +151 -51
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/{tabs-B4M-usCV.js → tabs-Dh0mUsLw.js} +256 -21
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/{textarea-fTuUZRQb.js → textarea-CCM-SnGN.js} +271 -15
- package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
- package/dist/pages/time-input-CA9-uZAa.js +442 -0
- package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
- package/dist/pages/timeline-BsMUTlpR.js +1798 -0
- package/dist/pages/{toast-CKP03zjy.js → toast-zXLRiMRT.js} +240 -25
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/{tooltip-CBYil3kt.js → tooltip-LHtCUkF-.js} +162 -33
- package/dist/pages/translation-field-CTRXiF2N.js +251 -0
- package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
- package/dist/pages/tree-select-DU1qXHy_.js +492 -0
- package/dist/pages/tree-view-g_RjLtAb.js +739 -0
- package/dist/pages/{typography-PCbg8Bhg.js → typography-BSijtiRl.js} +153 -12
- package/dist/pages/unit-input-Dml4fjmK.js +659 -0
- package/dist/pages/upload-rules-yozEzSah.js +419 -0
- package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
- package/dist/pages/value-change-CnubDKyO.js +489 -0
- package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
- package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
- package/dist/pages/working-status-CENemSsw.js +389 -0
- package/manifest.json +10984 -1108
- package/package.json +2 -2
- package/dist/pages/card-DUggbis3.js +0 -659
- package/dist/pages/checkbox-DwimQaK3.js +0 -365
- package/dist/pages/dialog-BRAf4LMh.js +0 -1451
- package/dist/pages/empty-state-C-mLrXW2.js +0 -417
- package/dist/pages/input-KF9Gkawf.js +0 -1093
- package/dist/pages/registry-CroHzK9I.js +0 -244
- package/dist/pages/skeleton-DLuBhP46.js +0 -561
- package/dist/pages/table-AMoODng4.js +0 -607
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section$1, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Field, NumberInput } from "@orbitcommerce/constellation";
|
|
7
|
+
//#region src/pages/components/number-input.tsx
|
|
8
|
+
function Preview() {
|
|
9
|
+
return /* @__PURE__ */ jsx("div", {
|
|
10
|
+
style: { width: 200 },
|
|
11
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
12
|
+
label: "Quantity",
|
|
13
|
+
hint: "Up to 20",
|
|
14
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
15
|
+
defaultValue: 4,
|
|
16
|
+
min: 1,
|
|
17
|
+
max: 20
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** A controlled field, with the value that was committed shown under it. Nothing calls back until the field is left. */
|
|
23
|
+
function Quantity() {
|
|
24
|
+
const [value, setValue] = useState(2);
|
|
25
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
26
|
+
className: "number-input-stack",
|
|
27
|
+
children: [/* @__PURE__ */ jsx(NumberInput, {
|
|
28
|
+
"aria-label": "Quantity",
|
|
29
|
+
value,
|
|
30
|
+
onChange: setValue,
|
|
31
|
+
min: 1,
|
|
32
|
+
max: 10
|
|
33
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
34
|
+
role: "status",
|
|
35
|
+
className: "number-input-status",
|
|
36
|
+
children: value === "" ? "Empty" : `Committed: ${value}`
|
|
37
|
+
})]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function Locales() {
|
|
41
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
42
|
+
className: "number-input-grid",
|
|
43
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: "number-input-labelled",
|
|
45
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
46
|
+
className: "number-input-label",
|
|
47
|
+
children: "en-GB (default)"
|
|
48
|
+
}), /* @__PURE__ */ jsx(NumberInput, {
|
|
49
|
+
"aria-label": "Price in British English",
|
|
50
|
+
defaultValue: 1234.5
|
|
51
|
+
})]
|
|
52
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: "number-input-labelled",
|
|
54
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
55
|
+
className: "number-input-label",
|
|
56
|
+
children: "de-DE"
|
|
57
|
+
}), /* @__PURE__ */ jsx(NumberInput, {
|
|
58
|
+
"aria-label": "Price in German",
|
|
59
|
+
defaultValue: 1234.5,
|
|
60
|
+
locale: "de-DE"
|
|
61
|
+
})]
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function Stepping() {
|
|
66
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
67
|
+
className: "number-input-stack",
|
|
68
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
69
|
+
label: "Weight",
|
|
70
|
+
hint: "Step 0.5kg",
|
|
71
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
72
|
+
suffix: "kg",
|
|
73
|
+
step: .5,
|
|
74
|
+
defaultValue: 12.5,
|
|
75
|
+
stepper: true
|
|
76
|
+
})
|
|
77
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
78
|
+
label: "Seats",
|
|
79
|
+
hint: "Whole numbers only",
|
|
80
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
81
|
+
step: 1,
|
|
82
|
+
decimals: 0,
|
|
83
|
+
defaultValue: 4,
|
|
84
|
+
min: 0,
|
|
85
|
+
stepper: true
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function Sizes() {
|
|
91
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
92
|
+
className: "number-input-grid",
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsxs("div", {
|
|
95
|
+
className: "number-input-labelled",
|
|
96
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: "number-input-label",
|
|
98
|
+
children: "sm, 30px"
|
|
99
|
+
}), /* @__PURE__ */ jsx(NumberInput, {
|
|
100
|
+
size: "sm",
|
|
101
|
+
"aria-label": "Seats, small",
|
|
102
|
+
decimals: 0,
|
|
103
|
+
min: 0,
|
|
104
|
+
defaultValue: 4,
|
|
105
|
+
stepper: true
|
|
106
|
+
})]
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ jsxs("div", {
|
|
109
|
+
className: "number-input-labelled",
|
|
110
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "number-input-label",
|
|
112
|
+
children: "md, 36px (default)"
|
|
113
|
+
}), /* @__PURE__ */ jsx(NumberInput, {
|
|
114
|
+
size: "md",
|
|
115
|
+
"aria-label": "Seats, medium",
|
|
116
|
+
decimals: 0,
|
|
117
|
+
min: 0,
|
|
118
|
+
defaultValue: 4,
|
|
119
|
+
stepper: true
|
|
120
|
+
})]
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsxs("div", {
|
|
123
|
+
className: "number-input-labelled",
|
|
124
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
125
|
+
className: "number-input-label",
|
|
126
|
+
children: "lg, 44px"
|
|
127
|
+
}), /* @__PURE__ */ jsx(NumberInput, {
|
|
128
|
+
size: "lg",
|
|
129
|
+
"aria-label": "Seats, large",
|
|
130
|
+
decimals: 0,
|
|
131
|
+
min: 0,
|
|
132
|
+
defaultValue: 4,
|
|
133
|
+
stepper: true
|
|
134
|
+
})]
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function Adornments() {
|
|
140
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
141
|
+
className: "number-input-grid",
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ jsx(Field, {
|
|
144
|
+
label: "Unit price",
|
|
145
|
+
hint: "To the penny",
|
|
146
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
147
|
+
prefix: "£",
|
|
148
|
+
decimals: 2,
|
|
149
|
+
defaultValue: 249
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ jsx(Field, {
|
|
153
|
+
label: "Discount",
|
|
154
|
+
hint: "Per cent off",
|
|
155
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
156
|
+
suffix: "%",
|
|
157
|
+
defaultValue: 10,
|
|
158
|
+
min: 0,
|
|
159
|
+
max: 100
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ jsx(Field, {
|
|
163
|
+
label: "Weight",
|
|
164
|
+
hint: "In kilograms",
|
|
165
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
166
|
+
suffix: "kg",
|
|
167
|
+
step: .1,
|
|
168
|
+
decimals: 1,
|
|
169
|
+
defaultValue: 14.2
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function EmptyValue() {
|
|
176
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
177
|
+
className: "number-input-stack",
|
|
178
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
179
|
+
label: "Reorder level",
|
|
180
|
+
hint: "Leave it empty to use the default",
|
|
181
|
+
children: /* @__PURE__ */ jsx(NumberInput, { placeholder: "Not set" })
|
|
182
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
183
|
+
label: "Low stock at",
|
|
184
|
+
hint: "Five by default",
|
|
185
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
186
|
+
min: 0,
|
|
187
|
+
decimals: 0,
|
|
188
|
+
suffix: "units"
|
|
189
|
+
})
|
|
190
|
+
})]
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function ReadOnlyAndDisabled() {
|
|
194
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
195
|
+
className: "number-input-stack",
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx(Field, {
|
|
198
|
+
label: "Units in stock",
|
|
199
|
+
hint: "Counted at the last stocktake",
|
|
200
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
201
|
+
value: 1042,
|
|
202
|
+
readOnly: true
|
|
203
|
+
})
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ jsx(Field, {
|
|
206
|
+
label: "Unit cost",
|
|
207
|
+
hint: "Set by the supplier",
|
|
208
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
209
|
+
prefix: "£",
|
|
210
|
+
decimals: 2,
|
|
211
|
+
defaultValue: 118.5,
|
|
212
|
+
readOnly: true
|
|
213
|
+
})
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsx(Field, {
|
|
216
|
+
label: "Sale price",
|
|
217
|
+
hint: "Turn on Put on sale to set a sale price",
|
|
218
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
219
|
+
prefix: "£",
|
|
220
|
+
decimals: 2,
|
|
221
|
+
disabled: true
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function InAField() {
|
|
228
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
229
|
+
className: "number-input-stack",
|
|
230
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
231
|
+
label: "Minimum order",
|
|
232
|
+
required: true,
|
|
233
|
+
description: "The smallest order we accept, in pounds.",
|
|
234
|
+
hint: "Whole pounds.",
|
|
235
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
236
|
+
prefix: "£",
|
|
237
|
+
min: 0,
|
|
238
|
+
defaultValue: 20
|
|
239
|
+
})
|
|
240
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
241
|
+
label: "Free delivery over",
|
|
242
|
+
optional: true,
|
|
243
|
+
hint: "In pounds",
|
|
244
|
+
error: "Enter an amount of £50 or more",
|
|
245
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
246
|
+
prefix: "£",
|
|
247
|
+
min: 0,
|
|
248
|
+
defaultValue: 25
|
|
249
|
+
})
|
|
250
|
+
})]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function Keyboard() {
|
|
254
|
+
const [value, setValue] = useState(5);
|
|
255
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
256
|
+
className: "number-input-stack",
|
|
257
|
+
children: [/* @__PURE__ */ jsx(NumberInput, {
|
|
258
|
+
"aria-label": "Quantity",
|
|
259
|
+
value,
|
|
260
|
+
onChange: setValue,
|
|
261
|
+
step: 1,
|
|
262
|
+
min: 0,
|
|
263
|
+
max: 20
|
|
264
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
265
|
+
role: "status",
|
|
266
|
+
className: "number-input-status",
|
|
267
|
+
children: value === "" ? "Empty" : `Committed: ${value}`
|
|
268
|
+
})]
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function Everything() {
|
|
272
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
273
|
+
className: "number-input-stack",
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx(Field, {
|
|
276
|
+
label: "Unit price",
|
|
277
|
+
required: true,
|
|
278
|
+
hint: "To the penny",
|
|
279
|
+
description: "What the customer pays.",
|
|
280
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
281
|
+
prefix: "£",
|
|
282
|
+
decimals: 2,
|
|
283
|
+
defaultValue: 249,
|
|
284
|
+
status: "valid"
|
|
285
|
+
})
|
|
286
|
+
}),
|
|
287
|
+
/* @__PURE__ */ jsx(Field, {
|
|
288
|
+
label: "Weight",
|
|
289
|
+
hint: "In kilograms",
|
|
290
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
291
|
+
suffix: "kg",
|
|
292
|
+
step: .1,
|
|
293
|
+
decimals: 1,
|
|
294
|
+
defaultValue: 14.2,
|
|
295
|
+
stepper: true
|
|
296
|
+
})
|
|
297
|
+
}),
|
|
298
|
+
/* @__PURE__ */ jsx(Field, {
|
|
299
|
+
label: "Units in stock",
|
|
300
|
+
hint: "Counted at the last stocktake",
|
|
301
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
302
|
+
value: 1042,
|
|
303
|
+
readOnly: true
|
|
304
|
+
})
|
|
305
|
+
}),
|
|
306
|
+
/* @__PURE__ */ jsx(Field, {
|
|
307
|
+
label: "Sale price",
|
|
308
|
+
hint: "Turn on Put on sale to set a sale price",
|
|
309
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
310
|
+
prefix: "£",
|
|
311
|
+
decimals: 2,
|
|
312
|
+
disabled: true
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
]
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function Page() {
|
|
319
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
320
|
+
title: "Number input",
|
|
321
|
+
status: "new",
|
|
322
|
+
importNames: ["NumberInput", "numberInputLabels"],
|
|
323
|
+
lead: "A number written the way the locale writes it. At rest the value is formatted, with the grouping, the locale's decimal separator and the decimals you ask for; the moment the field takes focus it is the raw number, selected, ready to be typed over. Nothing is committed while typing: leaving the field or pressing Enter parses what is there, rounds it, holds it to min and max, and calls onChange with a number.",
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
326
|
+
id: "basics",
|
|
327
|
+
title: "Basics",
|
|
328
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
329
|
+
/* @__PURE__ */ jsx("code", { children: "NumberInput" }),
|
|
330
|
+
" wraps the kit ",
|
|
331
|
+
/* @__PURE__ */ jsx("code", { children: "Input" }),
|
|
332
|
+
", so its ",
|
|
333
|
+
/* @__PURE__ */ jsx("code", { children: "prefix" }),
|
|
334
|
+
" and ",
|
|
335
|
+
/* @__PURE__ */ jsx("code", { children: "suffix" }),
|
|
336
|
+
" carry the currency sign or the unit, and it takes every Input prop. Give it a value, or a ",
|
|
337
|
+
/* @__PURE__ */ jsx("code", { children: "defaultValue" }),
|
|
338
|
+
" and let it hold its own. It calls ",
|
|
339
|
+
/* @__PURE__ */ jsx("code", { children: "onChange" }),
|
|
340
|
+
" with a number (or ",
|
|
341
|
+
/* @__PURE__ */ jsx("code", { children: "''" }),
|
|
342
|
+
" once cleared) only when the field is left, Enter is pressed or a step is taken, never on each keystroke, and never with ",
|
|
343
|
+
/* @__PURE__ */ jsx("code", { children: "NaN" }),
|
|
344
|
+
". Type below and press Tab: the committed value under the field changes then, not as you type."
|
|
345
|
+
] }),
|
|
346
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
347
|
+
code: `
|
|
348
|
+
const [value, setValue] = useState<number | ''>(2)
|
|
349
|
+
|
|
350
|
+
<NumberInput aria-label="Quantity" value={value} onChange={setValue} min={1} max={10} />
|
|
351
|
+
<span role="status">{value === '' ? 'Empty' : \`Committed: \${value}\`}</span>`,
|
|
352
|
+
children: /* @__PURE__ */ jsx(Quantity, {})
|
|
353
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
354
|
+
title: "When not to reach for it",
|
|
355
|
+
children: [
|
|
356
|
+
"A number field is for a value people think of as a number, one that a keyboard or a stepper can move: a quantity, a price, a weight, a rate. For something that only looks like one, use an ",
|
|
357
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
358
|
+
to: "/components/input",
|
|
359
|
+
children: "Input"
|
|
360
|
+
}),
|
|
361
|
+
": a product code, a phone number, a year someone types in a sentence, an account number with leading zeros, or anything people will copy out as text."
|
|
362
|
+
]
|
|
363
|
+
})]
|
|
364
|
+
}),
|
|
365
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
366
|
+
id: "locale",
|
|
367
|
+
title: "The locale",
|
|
368
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
369
|
+
"The field reads and writes the separators of one locale. ",
|
|
370
|
+
/* @__PURE__ */ jsx("code", { children: "locale" }),
|
|
371
|
+
" defaults to ",
|
|
372
|
+
/* @__PURE__ */ jsx("code", { children: "en-GB" }),
|
|
373
|
+
", whose decimal is a full stop and whose group is a comma; ",
|
|
374
|
+
/* @__PURE__ */ jsx("code", { children: "de-DE" }),
|
|
375
|
+
" swaps them, so the same number reads 1,234.5 in British English and 1.234,5 in German. A locale tag the platform cannot read falls back to ",
|
|
376
|
+
/* @__PURE__ */ jsx("code", { children: "en-GB" }),
|
|
377
|
+
" rather than throwing."
|
|
378
|
+
] }),
|
|
379
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
380
|
+
code: `
|
|
381
|
+
<NumberInput aria-label="Price in British English" defaultValue={1234.5} />
|
|
382
|
+
<NumberInput aria-label="Price in German" defaultValue={1234.5} locale="de-DE" />`,
|
|
383
|
+
children: /* @__PURE__ */ jsx(Locales, {})
|
|
384
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
385
|
+
title: "Reading and writing a number yourself",
|
|
386
|
+
children: [
|
|
387
|
+
"The helpers the field is built on are exported, for a figure you draw yourself: ",
|
|
388
|
+
/* @__PURE__ */ jsx("code", { children: "parseLocaleNumber" }),
|
|
389
|
+
" reads a number a person typed in any locale, ",
|
|
390
|
+
/* @__PURE__ */ jsx("code", { children: "formatLocaleNumber" }),
|
|
391
|
+
" writes one for display, ",
|
|
392
|
+
/* @__PURE__ */ jsx("code", { children: "roundTo" }),
|
|
393
|
+
" rounds half away from zero, ",
|
|
394
|
+
/* @__PURE__ */ jsx("code", { children: "clampNumber" }),
|
|
395
|
+
" holds a value between bounds, and ",
|
|
396
|
+
/* @__PURE__ */ jsx("code", { children: "stepNumber" }),
|
|
397
|
+
" steps without the floating-point drift. See the table at the end of this page."
|
|
398
|
+
]
|
|
399
|
+
})]
|
|
400
|
+
}),
|
|
401
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
402
|
+
id: "decimals",
|
|
403
|
+
title: "Decimals",
|
|
404
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
405
|
+
/* @__PURE__ */ jsx("code", { children: "decimals" }),
|
|
406
|
+
" sets how many places the value is rounded to and shown with, half away from zero. Leave it out and the value keeps its own places and a count reads as a count (5, not 5.00). With ",
|
|
407
|
+
/* @__PURE__ */ jsxs("code", { children: ["decimals=", "{2}"] }),
|
|
408
|
+
", 1.005 becomes 1.01, because the rounding happens on the decimal text rather than a floating-point multiply."
|
|
409
|
+
] }),
|
|
410
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
411
|
+
code: `
|
|
412
|
+
<Field label="Unit price" hint="To the penny">
|
|
413
|
+
<NumberInput prefix="£" decimals={2} defaultValue={1.005} />
|
|
414
|
+
</Field>`,
|
|
415
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
416
|
+
className: "number-input-stack",
|
|
417
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
418
|
+
label: "Unit price",
|
|
419
|
+
hint: "To the penny",
|
|
420
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
421
|
+
prefix: "£",
|
|
422
|
+
decimals: 2,
|
|
423
|
+
defaultValue: 1.005
|
|
424
|
+
})
|
|
425
|
+
})
|
|
426
|
+
})
|
|
427
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
428
|
+
title: "Decimals as a maximum",
|
|
429
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
430
|
+
"With ",
|
|
431
|
+
/* @__PURE__ */ jsxs("code", { children: ["fixedDecimals=", "{false}"] }),
|
|
432
|
+
", ",
|
|
433
|
+
/* @__PURE__ */ jsx("code", { children: "decimals" }),
|
|
434
|
+
" is the most places a value keeps rather than the places it always shows: 12.5 stays 12.5 and 12 stays 12, while 19.995 still rounds to 20 when it is committed. It suits an optional amount that reads better without padding, such as a compare-at price, a setup fee or a tier price, as react-number-format's ",
|
|
435
|
+
/* @__PURE__ */ jsx("code", { children: "decimalScale" }),
|
|
436
|
+
" does without ",
|
|
437
|
+
/* @__PURE__ */ jsx("code", { children: "fixedDecimalScale" }),
|
|
438
|
+
". Grouping stays off while you type, by design: the field groups the value when you leave it."
|
|
439
|
+
] }),
|
|
440
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
441
|
+
code: `
|
|
442
|
+
<Field label="Compare-at price" optional>
|
|
443
|
+
<NumberInput prefix="£" decimals={2} fixedDecimals={false} defaultValue={12.5} />
|
|
444
|
+
</Field>
|
|
445
|
+
<Field label="Setup fee" optional>
|
|
446
|
+
<NumberInput prefix="£" decimals={2} fixedDecimals={false} defaultValue={1250} />
|
|
447
|
+
</Field>`,
|
|
448
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
449
|
+
className: "number-input-grid",
|
|
450
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
451
|
+
label: "Compare-at price",
|
|
452
|
+
optional: true,
|
|
453
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
454
|
+
prefix: "£",
|
|
455
|
+
decimals: 2,
|
|
456
|
+
fixedDecimals: false,
|
|
457
|
+
defaultValue: 12.5
|
|
458
|
+
})
|
|
459
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
460
|
+
label: "Setup fee",
|
|
461
|
+
optional: true,
|
|
462
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
463
|
+
prefix: "£",
|
|
464
|
+
decimals: 2,
|
|
465
|
+
fixedDecimals: false,
|
|
466
|
+
defaultValue: 1250
|
|
467
|
+
})
|
|
468
|
+
})]
|
|
469
|
+
})
|
|
470
|
+
})
|
|
471
|
+
})]
|
|
472
|
+
}),
|
|
473
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
474
|
+
id: "limits",
|
|
475
|
+
title: "Min and max",
|
|
476
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
477
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
478
|
+
" and ",
|
|
479
|
+
/* @__PURE__ */ jsx("code", { children: "max" }),
|
|
480
|
+
" hold the value to a range. The value is clamped on commit, so typing 500 into a field of ",
|
|
481
|
+
/* @__PURE__ */ jsxs("code", { children: ["max=", "{500}"] }),
|
|
482
|
+
" is fine, and anything above it settles on 500 when the field is left. A negative number is only allowed when ",
|
|
483
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
484
|
+
" is below zero; otherwise the minus is dropped as it is typed."
|
|
485
|
+
] }),
|
|
486
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
487
|
+
code: `
|
|
488
|
+
<Field label="Stock on hand" hint="Between 0 and 500">
|
|
489
|
+
<NumberInput min={0} max={500} defaultValue={40} />
|
|
490
|
+
</Field>`,
|
|
491
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
492
|
+
className: "number-input-stack",
|
|
493
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
494
|
+
label: "Stock on hand",
|
|
495
|
+
hint: "Between 0 and 500",
|
|
496
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
497
|
+
min: 0,
|
|
498
|
+
max: 500,
|
|
499
|
+
defaultValue: 40
|
|
500
|
+
})
|
|
501
|
+
})
|
|
502
|
+
})
|
|
503
|
+
})
|
|
504
|
+
}),
|
|
505
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
506
|
+
id: "stepping",
|
|
507
|
+
title: "Step and the stepper buttons",
|
|
508
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
509
|
+
/* @__PURE__ */ jsx("code", { children: "step" }),
|
|
510
|
+
" is how far a step moves, 1 by default. The arrow keys and PageUp and PageDown step the value, and",
|
|
511
|
+
" ",
|
|
512
|
+
/* @__PURE__ */ jsx("code", { children: "stepper" }),
|
|
513
|
+
" adds a pair of small buttons at the end of the field, after any ",
|
|
514
|
+
/* @__PURE__ */ jsx("code", { children: "suffix" }),
|
|
515
|
+
". The buttons never take focus, so the field keeps it and the draft it is editing; at a limit, and while the field is disabled or read-only, a button reads as switched off with ",
|
|
516
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
517
|
+
" and does nothing. The field keeps to the step with no float drift, so 0.1 over 0.2 lands on 0.3."
|
|
518
|
+
] }),
|
|
519
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
520
|
+
code: `
|
|
521
|
+
<Field label="Weight" hint="Step 0.5kg">
|
|
522
|
+
<NumberInput suffix="kg" step={0.5} defaultValue={12.5} stepper />
|
|
523
|
+
</Field>
|
|
524
|
+
<Field label="Seats" hint="Whole numbers only">
|
|
525
|
+
<NumberInput step={1} decimals={0} defaultValue={4} min={0} stepper />
|
|
526
|
+
</Field>`,
|
|
527
|
+
children: /* @__PURE__ */ jsx(Stepping, {})
|
|
528
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
529
|
+
title: "The stepper buttons",
|
|
530
|
+
children: [
|
|
531
|
+
"Each button is named by ",
|
|
532
|
+
/* @__PURE__ */ jsx("code", { children: "numberInputLabels" }),
|
|
533
|
+
" and then the field: \"Increase Weight\" and \"Decrease Weight\" in a Field, or the words and the field's own ",
|
|
534
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
535
|
+
" when it stands alone, so the buttons of several number fields tell each other apart. Each points at the field with ",
|
|
536
|
+
/* @__PURE__ */ jsx("code", { children: "aria-controls" }),
|
|
537
|
+
" and is off the tab order: a keyboard user has the arrow keys. Replace the words through the ",
|
|
538
|
+
/* @__PURE__ */ jsx("code", { children: "labels" }),
|
|
539
|
+
" prop."
|
|
540
|
+
]
|
|
541
|
+
})]
|
|
542
|
+
}),
|
|
543
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
544
|
+
id: "sizes",
|
|
545
|
+
title: "Sizes",
|
|
546
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
547
|
+
/* @__PURE__ */ jsx("code", { children: "size" }),
|
|
548
|
+
" sets the height, as on an Input: ",
|
|
549
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
550
|
+
" 30px, ",
|
|
551
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
552
|
+
" (the default) 36px and",
|
|
553
|
+
" ",
|
|
554
|
+
/* @__PURE__ */ jsx("code", { children: "lg" }),
|
|
555
|
+
" 44px. The stepper follows the field: its two buttons stand 3px clear of the field's edge at every size, so a pressed or hovered step never covers the hairline. On a touch screen they sit side by side instead, each 26px wide and the stepper's full height, so a finger can find them."
|
|
556
|
+
] }),
|
|
557
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
558
|
+
code: `
|
|
559
|
+
<NumberInput size="sm" aria-label="Seats, small" decimals={0} min={0} defaultValue={4} stepper />
|
|
560
|
+
<NumberInput size="md" aria-label="Seats, medium" decimals={0} min={0} defaultValue={4} stepper />
|
|
561
|
+
<NumberInput size="lg" aria-label="Seats, large" decimals={0} min={0} defaultValue={4} stepper />`,
|
|
562
|
+
children: /* @__PURE__ */ jsx(Sizes, {})
|
|
563
|
+
})
|
|
564
|
+
}),
|
|
565
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
566
|
+
id: "adornments",
|
|
567
|
+
title: "Currency, unit and per cent",
|
|
568
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
569
|
+
/* @__PURE__ */ jsx("code", { children: "prefix" }),
|
|
570
|
+
" is text set tight against the value, so a price reads £249.00, never £ 249.00. ",
|
|
571
|
+
/* @__PURE__ */ jsx("code", { children: "suffix" }),
|
|
572
|
+
" ",
|
|
573
|
+
"trails it: a unit, a percentage, a status. Both come from the Input underneath, so the stepper buttons, when shown, sit after the suffix."
|
|
574
|
+
] }),
|
|
575
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
576
|
+
code: `
|
|
577
|
+
<Field label="Unit price" hint="To the penny">
|
|
578
|
+
<NumberInput prefix="£" decimals={2} defaultValue={249} />
|
|
579
|
+
</Field>
|
|
580
|
+
<Field label="Discount" hint="Per cent off">
|
|
581
|
+
<NumberInput suffix="%" defaultValue={10} min={0} max={100} />
|
|
582
|
+
</Field>
|
|
583
|
+
<Field label="Weight" hint="In kilograms">
|
|
584
|
+
<NumberInput suffix="kg" step={0.1} decimals={1} defaultValue={14.2} />
|
|
585
|
+
</Field>`,
|
|
586
|
+
children: /* @__PURE__ */ jsx(Adornments, {})
|
|
587
|
+
})
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
590
|
+
id: "empty",
|
|
591
|
+
title: "An empty value",
|
|
592
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
593
|
+
"An empty value is ",
|
|
594
|
+
/* @__PURE__ */ jsx("code", { children: "''" }),
|
|
595
|
+
", not zero and not ",
|
|
596
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
597
|
+
" (though a controlled field will take",
|
|
598
|
+
" ",
|
|
599
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
600
|
+
" for empty too). At rest the field shows nothing, or the ",
|
|
601
|
+
/* @__PURE__ */ jsx("code", { children: "placeholder" }),
|
|
602
|
+
" you give it. Clearing it calls ",
|
|
603
|
+
/* @__PURE__ */ jsx("code", { children: "onChange('')" }),
|
|
604
|
+
", and an empty field still answers the arrow keys: the first press starts at the lower bound, or zero."
|
|
605
|
+
] }),
|
|
606
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
607
|
+
code: `
|
|
608
|
+
<Field label="Reorder level" hint="Leave it empty to use the default">
|
|
609
|
+
<NumberInput placeholder="Not set" />
|
|
610
|
+
</Field>
|
|
611
|
+
<Field label="Low stock at" hint="Five by default">
|
|
612
|
+
<NumberInput min={0} decimals={0} suffix="units" />
|
|
613
|
+
</Field>`,
|
|
614
|
+
children: /* @__PURE__ */ jsx(EmptyValue, {})
|
|
615
|
+
})
|
|
616
|
+
}),
|
|
617
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
618
|
+
id: "states",
|
|
619
|
+
title: "Disabled and read-only",
|
|
620
|
+
description: /* @__PURE__ */ jsx("p", { children: "A read-only number can be tabbed to, selected and copied, and is sent with the form; a disabled one is skipped by Tab and is not sent. Neither can be changed: the arrow keys and the stepper buttons leave them alone, and the buttons read as switched off. Use read-only for a value people can see but not change here, and disabled for one that is off because of another setting." }),
|
|
621
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
622
|
+
code: `
|
|
623
|
+
<Field label="Units in stock" hint="Counted at the last stocktake">
|
|
624
|
+
<NumberInput value={1042} readOnly />
|
|
625
|
+
</Field>
|
|
626
|
+
<Field label="Unit cost" hint="Set by the supplier">
|
|
627
|
+
<NumberInput prefix="£" decimals={2} defaultValue={118.5} readOnly />
|
|
628
|
+
</Field>
|
|
629
|
+
<Field label="Sale price" hint="Turn on Put on sale to set a sale price">
|
|
630
|
+
<NumberInput prefix="£" decimals={2} disabled />
|
|
631
|
+
</Field>`,
|
|
632
|
+
children: /* @__PURE__ */ jsx(ReadOnlyAndDisabled, {})
|
|
633
|
+
})
|
|
634
|
+
}),
|
|
635
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
636
|
+
id: "field",
|
|
637
|
+
title: "In a Field",
|
|
638
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
639
|
+
"Put a NumberInput in a ",
|
|
640
|
+
/* @__PURE__ */ jsx("code", { children: "Field" }),
|
|
641
|
+
" for its label, hint, description and error. The label points at the number field, so pressing it focuses it, and the hint or error is linked to it for screen readers. A Field's error marks the number field invalid, as the ",
|
|
642
|
+
/* @__PURE__ */ jsx("code", { children: "invalid" }),
|
|
643
|
+
" prop does."
|
|
644
|
+
] }),
|
|
645
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
646
|
+
code: `
|
|
647
|
+
<Field
|
|
648
|
+
label="Minimum order"
|
|
649
|
+
required
|
|
650
|
+
description="The smallest order we accept, in pounds."
|
|
651
|
+
hint="Whole pounds."
|
|
652
|
+
>
|
|
653
|
+
<NumberInput prefix="£" min={0} defaultValue={20} />
|
|
654
|
+
</Field>
|
|
655
|
+
<Field label="Free delivery over" optional hint="In pounds" error="Enter an amount of £50 or more">
|
|
656
|
+
<NumberInput prefix="£" min={0} defaultValue={25} />
|
|
657
|
+
</Field>`,
|
|
658
|
+
children: /* @__PURE__ */ jsx(InAField, {})
|
|
659
|
+
})
|
|
660
|
+
}),
|
|
661
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
662
|
+
id: "keyboard",
|
|
663
|
+
title: "The keyboard",
|
|
664
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
665
|
+
"The field is a text input wearing ",
|
|
666
|
+
/* @__PURE__ */ jsx("code", { children: "role=\"spinbutton\"" }),
|
|
667
|
+
". Type in it as you would any field; the arrow keys, Shift with them, and PageUp and PageDown step the value. Enter commits without leaving the field, so a form it sits in still submits."
|
|
668
|
+
] }),
|
|
669
|
+
children: [
|
|
670
|
+
/* @__PURE__ */ jsx(Example, {
|
|
671
|
+
code: `
|
|
672
|
+
<NumberInput aria-label="Quantity" value={value} onChange={setValue} step={1} min={0} max={20} />
|
|
673
|
+
<span role="status">{value === '' ? 'Empty' : \`Committed: \${value}\`}</span>`,
|
|
674
|
+
children: /* @__PURE__ */ jsx(Keyboard, {})
|
|
675
|
+
}),
|
|
676
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
677
|
+
columns: ["Key", "What it does"],
|
|
678
|
+
rows: [
|
|
679
|
+
[/* @__PURE__ */ jsx("code", { children: "ArrowUp" }, "up"), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
680
|
+
"Steps up by ",
|
|
681
|
+
/* @__PURE__ */ jsx("code", { children: "step" }),
|
|
682
|
+
"."
|
|
683
|
+
] })],
|
|
684
|
+
[/* @__PURE__ */ jsx("code", { children: "ArrowDown" }, "down"), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
685
|
+
"Steps down by ",
|
|
686
|
+
/* @__PURE__ */ jsx("code", { children: "step" }),
|
|
687
|
+
"."
|
|
688
|
+
] })],
|
|
689
|
+
[/* @__PURE__ */ jsx("code", { children: "Shift + ArrowUp" }, "sup"), "Steps up ten times at once."],
|
|
690
|
+
[/* @__PURE__ */ jsx("code", { children: "Shift + ArrowDown" }, "sdown"), "Steps down ten times at once."],
|
|
691
|
+
[/* @__PURE__ */ jsx("code", { children: "PageUp" }, "pup"), "Steps up ten times at once."],
|
|
692
|
+
[/* @__PURE__ */ jsx("code", { children: "PageDown" }, "pdown"), "Steps down ten times at once."],
|
|
693
|
+
[/* @__PURE__ */ jsx("code", { children: "Enter" }, "enter"), "Commits the value, and does not stop a form submitting."],
|
|
694
|
+
[/* @__PURE__ */ jsx("code", { children: "Tab" }, "tab"), "Leaves the field and commits, as any press elsewhere does."],
|
|
695
|
+
["Typing", "Accepted as it is typed (digits, the separators, a sign and spaces keep); nothing is committed until the field is left."]
|
|
696
|
+
]
|
|
697
|
+
}),
|
|
698
|
+
/* @__PURE__ */ jsx(Note, {
|
|
699
|
+
title: "From an empty field",
|
|
700
|
+
children: "An arrow on an empty field starts at a bound rather than stepping from zero: up lands on the minimum, or zero when there is none, and down lands on the maximum, or zero. The first press is a way to reach a number from nothing."
|
|
701
|
+
})
|
|
702
|
+
]
|
|
703
|
+
}),
|
|
704
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
705
|
+
id: "both-themes",
|
|
706
|
+
title: "In both themes",
|
|
707
|
+
description: /* @__PURE__ */ jsx("p", { children: "A required price with a check, a stepped weight, a read-only stock count and a disabled field, light and dark side by side." }),
|
|
708
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
709
|
+
align: "fill",
|
|
710
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
711
|
+
className: "number-input-theme",
|
|
712
|
+
children: /* @__PURE__ */ jsx(Everything, {})
|
|
713
|
+
})
|
|
714
|
+
})
|
|
715
|
+
}),
|
|
716
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
717
|
+
id: "accessibility",
|
|
718
|
+
title: "Accessibility",
|
|
719
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
720
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
721
|
+
"The number field is one ",
|
|
722
|
+
/* @__PURE__ */ jsx("code", { children: "role=\"spinbutton\"" }),
|
|
723
|
+
" text input. Its name comes from ",
|
|
724
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
725
|
+
", or from the Field's label. It carries ",
|
|
726
|
+
/* @__PURE__ */ jsx("code", { children: "aria-valuenow" }),
|
|
727
|
+
" (omitted while empty), ",
|
|
728
|
+
/* @__PURE__ */ jsx("code", { children: "aria-valuemin" }),
|
|
729
|
+
" and",
|
|
730
|
+
" ",
|
|
731
|
+
/* @__PURE__ */ jsx("code", { children: "aria-valuemax" }),
|
|
732
|
+
" when set, and ",
|
|
733
|
+
/* @__PURE__ */ jsx("code", { children: "aria-valuetext" }),
|
|
734
|
+
", which is the words shown, so a screen reader hears the value as it is written and not only its digits."
|
|
735
|
+
] }),
|
|
736
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
737
|
+
"The stepper buttons sit after the field, named by ",
|
|
738
|
+
/* @__PURE__ */ jsx("code", { children: "numberInputLabels" }),
|
|
739
|
+
" and then the field (\"Increase Quantity\"). They are out of the tab order (a keyboard user has the arrow keys) and carry ",
|
|
740
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
741
|
+
" at a limit and while the field is disabled or read-only. A press keeps focus in the field, so a screen reader stays on the spinbutton while its value steps."
|
|
742
|
+
] }),
|
|
743
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
744
|
+
"Nothing changes the value while someone types, so a host can leave the field alone until it is committed: the field calls ",
|
|
745
|
+
/* @__PURE__ */ jsx("code", { children: "onChange" }),
|
|
746
|
+
" with a number, or ",
|
|
747
|
+
/* @__PURE__ */ jsx("code", { children: "''" }),
|
|
748
|
+
" once cleared, never with ",
|
|
749
|
+
/* @__PURE__ */ jsx("code", { children: "NaN" }),
|
|
750
|
+
". Mirror what is being typed with ",
|
|
751
|
+
/* @__PURE__ */ jsx("code", { children: "onDraftChange" }),
|
|
752
|
+
" if you need it."
|
|
753
|
+
] }),
|
|
754
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
755
|
+
"A number that is not one ('-', '.') is put back to the value the page holds when the field is left, with no call. An error, the ",
|
|
756
|
+
/* @__PURE__ */ jsx("code", { children: "invalid" }),
|
|
757
|
+
" prop or a Field's error marks the field ",
|
|
758
|
+
/* @__PURE__ */ jsx("code", { children: "aria-invalid" }),
|
|
759
|
+
"."
|
|
760
|
+
] }),
|
|
761
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
762
|
+
"A Field's error and hint are linked with ",
|
|
763
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
764
|
+
"; the Field's label names the field. Give the number its own ",
|
|
765
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
766
|
+
" only when it stands alone."
|
|
767
|
+
] }),
|
|
768
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
769
|
+
"The field commits on blur. A form that validates on submit should still work, because Enter commits without stopping the submit; check the value on the host's ",
|
|
770
|
+
/* @__PURE__ */ jsx("code", { children: "onChange" }),
|
|
771
|
+
"."
|
|
772
|
+
] })
|
|
773
|
+
] })
|
|
774
|
+
}),
|
|
775
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
776
|
+
id: "guidelines",
|
|
777
|
+
title: "Guidelines",
|
|
778
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
779
|
+
do: {
|
|
780
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
781
|
+
className: "number-input-dd",
|
|
782
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
783
|
+
label: "Unit price",
|
|
784
|
+
hint: "To the penny",
|
|
785
|
+
children: /* @__PURE__ */ jsx(NumberInput, {
|
|
786
|
+
prefix: "£",
|
|
787
|
+
decimals: 2,
|
|
788
|
+
defaultValue: 249
|
|
789
|
+
})
|
|
790
|
+
})
|
|
791
|
+
}),
|
|
792
|
+
caption: "A price with the currency in a prefix and the pennies fixed, so the column of figures lines up."
|
|
793
|
+
},
|
|
794
|
+
dont: {
|
|
795
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
796
|
+
className: "number-input-dd",
|
|
797
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
798
|
+
label: "Unit price (£, to the penny)",
|
|
799
|
+
children: /* @__PURE__ */ jsx(NumberInput, { defaultValue: 249 })
|
|
800
|
+
})
|
|
801
|
+
}),
|
|
802
|
+
caption: "The currency and the places in the label. The field should carry the format, so it can hold the value to it."
|
|
803
|
+
}
|
|
804
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
805
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
806
|
+
"Put the currency or unit in ",
|
|
807
|
+
/* @__PURE__ */ jsx("code", { children: "prefix" }),
|
|
808
|
+
" or ",
|
|
809
|
+
/* @__PURE__ */ jsx("code", { children: "suffix" }),
|
|
810
|
+
", not the label: \"Unit price\" with a £ prefix, not \"Unit price (£)\"."
|
|
811
|
+
] }),
|
|
812
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
813
|
+
"Set ",
|
|
814
|
+
/* @__PURE__ */ jsx("code", { children: "decimals" }),
|
|
815
|
+
" for money and weights, so every value is shown to the same place and a column reads down. Leave it out for a count."
|
|
816
|
+
] }),
|
|
817
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
818
|
+
"Give a range with ",
|
|
819
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
820
|
+
" and ",
|
|
821
|
+
/* @__PURE__ */ jsx("code", { children: "max" }),
|
|
822
|
+
" so the stepper and the arrows stop where the value stops. Do not rely on a validation message for a bound the field can hold itself to."
|
|
823
|
+
] }),
|
|
824
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
825
|
+
"Reach for the ",
|
|
826
|
+
/* @__PURE__ */ jsx("code", { children: "stepper" }),
|
|
827
|
+
" buttons for a value people nudge a little at a time: a quantity, a weight. For a figure typed once, the arrows alone are enough, and the buttons only take space."
|
|
828
|
+
] }),
|
|
829
|
+
"Say what an empty field means in the hint. An empty number is not zero, and the person cannot tell which you treat it as.",
|
|
830
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
831
|
+
"Use a NumberInput for one number. A range, a money pair or a size set is several fields in a",
|
|
832
|
+
" ",
|
|
833
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
834
|
+
to: "/components/input",
|
|
835
|
+
children: "Field"
|
|
836
|
+
}),
|
|
837
|
+
" group, each with its own label."
|
|
838
|
+
] })
|
|
839
|
+
] })]
|
|
840
|
+
}),
|
|
841
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
842
|
+
id: "props",
|
|
843
|
+
title: "Props",
|
|
844
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
845
|
+
"NumberInput takes these, and every ",
|
|
846
|
+
/* @__PURE__ */ jsx("code", { children: "Input" }),
|
|
847
|
+
" prop besides: ",
|
|
848
|
+
/* @__PURE__ */ jsx("code", { children: "size" }),
|
|
849
|
+
", ",
|
|
850
|
+
/* @__PURE__ */ jsx("code", { children: "prefix" }),
|
|
851
|
+
",",
|
|
852
|
+
" ",
|
|
853
|
+
/* @__PURE__ */ jsx("code", { children: "suffix" }),
|
|
854
|
+
", ",
|
|
855
|
+
/* @__PURE__ */ jsx("code", { children: "icon" }),
|
|
856
|
+
", ",
|
|
857
|
+
/* @__PURE__ */ jsx("code", { children: "status" }),
|
|
858
|
+
", ",
|
|
859
|
+
/* @__PURE__ */ jsx("code", { children: "invalid" }),
|
|
860
|
+
", ",
|
|
861
|
+
/* @__PURE__ */ jsx("code", { children: "readOnly" }),
|
|
862
|
+
",",
|
|
863
|
+
" ",
|
|
864
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
865
|
+
", ",
|
|
866
|
+
/* @__PURE__ */ jsx("code", { children: "placeholder" }),
|
|
867
|
+
", ",
|
|
868
|
+
/* @__PURE__ */ jsx("code", { children: "name" }),
|
|
869
|
+
" and the native input attributes. A",
|
|
870
|
+
" ",
|
|
871
|
+
/* @__PURE__ */ jsx("code", { children: "prefix" }),
|
|
872
|
+
" or ",
|
|
873
|
+
/* @__PURE__ */ jsx("code", { children: "suffix" }),
|
|
874
|
+
" carries the currency sign or the unit, as it does on an Input."
|
|
875
|
+
] }),
|
|
876
|
+
children: [/* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
877
|
+
{
|
|
878
|
+
name: "value",
|
|
879
|
+
type: "number | '' | null",
|
|
880
|
+
description: "The value, for a controlled field. null or an empty string is empty."
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
name: "defaultValue",
|
|
884
|
+
type: "number | '' | null",
|
|
885
|
+
description: "The value at first, when it is not controlled."
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
name: "onChange",
|
|
889
|
+
type: "(value: number | '') => void",
|
|
890
|
+
description: "Called when the value is committed: a number, or '' once cleared. Never while typing, never NaN."
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
name: "min",
|
|
894
|
+
type: "number",
|
|
895
|
+
description: "The smallest value allowed. The value is held to it on commit, and a minus is refused when it is not below zero."
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
name: "max",
|
|
899
|
+
type: "number",
|
|
900
|
+
description: "The largest value allowed. The value is held to it on commit."
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
name: "step",
|
|
904
|
+
type: "number",
|
|
905
|
+
default: "1",
|
|
906
|
+
description: "How far an arrow key or a stepper press moves the value."
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
name: "decimals",
|
|
910
|
+
type: "number",
|
|
911
|
+
description: "How many places to show and to round to, half away from zero. Left out, the value keeps its own places."
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
name: "fixedDecimals",
|
|
915
|
+
type: "boolean",
|
|
916
|
+
default: "true",
|
|
917
|
+
description: "Whether decimals is exact (12.50) or a maximum that pads nothing (12.5 stays 12.5). Rounding on commit is the same."
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
name: "locale",
|
|
921
|
+
type: "string",
|
|
922
|
+
default: "'en-GB'",
|
|
923
|
+
description: "The locale whose separators and digits are read and written. A tag the platform cannot read falls back to en-GB."
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
name: "stepper",
|
|
927
|
+
type: "boolean",
|
|
928
|
+
default: "false",
|
|
929
|
+
description: "Shows a pair of small step buttons at the end of the field, after any suffix."
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
name: "selectOnFocus",
|
|
933
|
+
type: "boolean",
|
|
934
|
+
default: "true",
|
|
935
|
+
description: "Selects the raw value when the field takes focus, so it can be typed over."
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
name: "labels",
|
|
939
|
+
type: "Partial<NumberInputLabels>",
|
|
940
|
+
description: "The words the stepper buttons use. numberInputLabels is the English set."
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
name: "onDraftChange",
|
|
944
|
+
type: "(text: string) => void",
|
|
945
|
+
description: "Reports the text in the field as it is typed, for a host that mirrors a draft."
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
name: "…Input props",
|
|
949
|
+
type: "InputProps",
|
|
950
|
+
description: "size, prefix, suffix, icon, status, invalid, readOnly, disabled, placeholder, name, className and the native input attributes."
|
|
951
|
+
}
|
|
952
|
+
] }), /* @__PURE__ */ jsx(DocTable, {
|
|
953
|
+
columns: ["Helper", "What it does"],
|
|
954
|
+
rows: [
|
|
955
|
+
[/* @__PURE__ */ jsx("code", { children: "parseLocaleNumber(text, locale?)" }, "p"), "Reads a number a person typed in any locale, or null for text that is no number."],
|
|
956
|
+
[/* @__PURE__ */ jsx("code", { children: "formatLocaleNumber(value, options?)" }, "f"), "Writes a number for display: the locale grouping and decimal, and exactly the decimals given (at most, with fixed: false)."],
|
|
957
|
+
[/* @__PURE__ */ jsx("code", { children: "roundTo(value, decimals)" }, "r"), "Rounds to a number of places, half away from zero, exact where a plain multiply is not (1.005 is 1.01)."],
|
|
958
|
+
[/* @__PURE__ */ jsx("code", { children: "clampNumber(value, min?, max?)" }, "c"), "Holds a value between the bounds it is given, either one left out."],
|
|
959
|
+
[/* @__PURE__ */ jsx("code", { children: "stepNumber(value, step, direction, times?)" }, "s"), "Steps by a step, float-safe: 0.1 over 0.2 lands on 0.3."]
|
|
960
|
+
]
|
|
961
|
+
})]
|
|
962
|
+
}),
|
|
963
|
+
/* @__PURE__ */ jsx(Fragment$1, {})
|
|
964
|
+
]
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
//#endregion
|
|
968
|
+
export { Page, Preview };
|