@loadbare/widgets 0.9.0 → 0.9.1
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/README.md +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lb-date.browser.d.ts +2 -0
- package/dist/lb-date.browser.d.ts.map +1 -0
- package/dist/lb-date.browser.js +47 -0
- package/dist/lb-date.browser.js.map +1 -0
- package/dist/lb-date.html +23 -0
- package/dist/lb-number.browser.d.ts +2 -0
- package/dist/lb-number.browser.d.ts.map +1 -0
- package/dist/lb-number.browser.js +40 -0
- package/dist/lb-number.browser.js.map +1 -0
- package/dist/lb-number.html +24 -0
- package/docs/lb-date.md +48 -0
- package/docs/lb-number.md +53 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,6 +17,8 @@ Inventory:
|
|
|
17
17
|
| [`lb-insert-dialog`](docs/lb-insert-dialog.md) | a row entered in a modal dialog, chosen in the picker that opened it |
|
|
18
18
|
| [`lb-master`](docs/lb-master.md) | a set, one of its rows, and the buttons that act on the set |
|
|
19
19
|
| [`lb-checkbox`](docs/lb-checkbox.md) | a checkbox and its label, as markup to style |
|
|
20
|
+
| [`lb-number`](docs/lb-number.md) | a number shown by `Intl.NumberFormat` |
|
|
21
|
+
| [`lb-date`](docs/lb-date.md) | a date or time shown by `Intl.DateTimeFormat` |
|
|
20
22
|
|
|
21
23
|
## Installing
|
|
22
24
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+BAA+B,CAAC;AACvC,OAAO,wBAAwB,CAAC;AAChC,OAAO,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+BAA+B,CAAC","sourcesContent":["import \"./lb-input.browser.js\";\nimport \"./lb-select.browser.js\";\nimport \"./lb-options.browser.js\";\nimport \"./lb-table.browser.js\";\nimport \"./lb-picker.browser.js\";\nimport \"./lb-confirm.browser.js\";\nimport \"./lb-insert-dialog.browser.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,+BAA+B,CAAC;AACvC,OAAO,wBAAwB,CAAC;AAChC,OAAO,sBAAsB,CAAC","sourcesContent":["import \"./lb-input.browser.js\";\nimport \"./lb-select.browser.js\";\nimport \"./lb-options.browser.js\";\nimport \"./lb-table.browser.js\";\nimport \"./lb-picker.browser.js\";\nimport \"./lb-confirm.browser.js\";\nimport \"./lb-insert-dialog.browser.js\";\nimport \"./lb-number.browser.js\";\nimport \"./lb-date.browser.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lb-date.browser.d.ts","sourceRoot":"","sources":["../widgets/lb-date.browser.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { ATTR_COLUMN_VALUE } from "@loadbare/app/constants";
|
|
3
|
+
/**
|
|
4
|
+
* Shows the value that landed on it through `Intl.DateTimeFormat`, in the
|
|
5
|
+
* `<time>` its definition holds, with the value itself as the `<time>`'s
|
|
6
|
+
* `datetime`. Not a control: the hub stamps `lb-column-value` on the tag and
|
|
7
|
+
* never gathers it.
|
|
8
|
+
*
|
|
9
|
+
* A date alone, `YYYY-MM-DD`, names a day and no instant, so it shows as
|
|
10
|
+
* that day in UTC rather than as the midnight it would be in UTC, shifted to
|
|
11
|
+
* the browser's zone. A value that is no date shows as it arrived.
|
|
12
|
+
*/
|
|
13
|
+
class LbDate extends HTMLElement {
|
|
14
|
+
static observedAttributes = [ATTR_COLUMN_VALUE];
|
|
15
|
+
formatters = new Map();
|
|
16
|
+
attributeChangedCallback(_name, _old, value) {
|
|
17
|
+
const time = this.querySelector("time");
|
|
18
|
+
if (!time)
|
|
19
|
+
return;
|
|
20
|
+
if (value === null) {
|
|
21
|
+
time.removeAttribute("datetime");
|
|
22
|
+
time.textContent = "";
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
time.dateTime = value;
|
|
26
|
+
const date = new Date(value);
|
|
27
|
+
time.textContent = Number.isNaN(date.getTime())
|
|
28
|
+
? value
|
|
29
|
+
: this.format(time, DAY.test(value)).format(date);
|
|
30
|
+
}
|
|
31
|
+
format(time, day) {
|
|
32
|
+
let formatter = this.formatters.get(day);
|
|
33
|
+
if (!formatter) {
|
|
34
|
+
const { locale, ...options } = time.dataset;
|
|
35
|
+
formatter = new Intl.DateTimeFormat(locale, {
|
|
36
|
+
...options,
|
|
37
|
+
...(day ? { timeZone: "UTC" } : {}),
|
|
38
|
+
});
|
|
39
|
+
this.formatters.set(day, formatter);
|
|
40
|
+
}
|
|
41
|
+
return formatter;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** A date with no time, as Postgres writes a `date`. */
|
|
45
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
46
|
+
customElements.define("lb-date", LbDate);
|
|
47
|
+
//# sourceMappingURL=lb-date.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lb-date.browser.js","sourceRoot":"","sources":["../widgets/lb-date.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,MAAO,SAAQ,WAAW;IAC9B,MAAM,CAAC,kBAAkB,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAExC,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE7D,wBAAwB,CACtB,KAAa,EACb,IAAmB,EACnB,KAAoB;QAEpB,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YACjC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7C,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAEO,MAAM,CAAC,IAAqB,EAAE,GAAY;QAChD,IAAI,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5C,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;gBAC1C,GAAI,OAAsC;gBAC1C,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpC,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;;AAGH,wDAAwD;AACxD,MAAM,GAAG,GAAG,qBAAqB,CAAC;AAElC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport { ATTR_COLUMN_VALUE } from \"@loadbare/app/constants\";\n\n/**\n * Shows the value that landed on it through `Intl.DateTimeFormat`, in the\n * `<time>` its definition holds, with the value itself as the `<time>`'s\n * `datetime`. Not a control: the hub stamps `lb-column-value` on the tag and\n * never gathers it.\n *\n * A date alone, `YYYY-MM-DD`, names a day and no instant, so it shows as\n * that day in UTC rather than as the midnight it would be in UTC, shifted to\n * the browser's zone. A value that is no date shows as it arrived.\n */\nclass LbDate extends HTMLElement {\n static observedAttributes = [ATTR_COLUMN_VALUE];\n\n private formatters = new Map<boolean, Intl.DateTimeFormat>();\n\n attributeChangedCallback(\n _name: string,\n _old: string | null,\n value: string | null,\n ): void {\n const time = this.querySelector(\"time\");\n if (!time) return;\n if (value === null) {\n time.removeAttribute(\"datetime\");\n time.textContent = \"\";\n return;\n }\n time.dateTime = value;\n const date = new Date(value);\n time.textContent = Number.isNaN(date.getTime())\n ? value\n : this.format(time, DAY.test(value)).format(date);\n }\n\n private format(time: HTMLTimeElement, day: boolean): Intl.DateTimeFormat {\n let formatter = this.formatters.get(day);\n if (!formatter) {\n const { locale, ...options } = time.dataset;\n formatter = new Intl.DateTimeFormat(locale, {\n ...(options as Intl.DateTimeFormatOptions),\n ...(day ? { timeZone: \"UTC\" } : {}),\n });\n this.formatters.set(day, formatter);\n }\n return formatter;\n }\n}\n\n/** A date with no time, as Postgres writes a `date`. */\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\ncustomElements.define(\"lb-date\", LbDate);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A date or a time, as the browser's Intl.DateTimeFormat shows it. Each
|
|
3
|
+
parameter is one of Intl's own options, in kebab-case, carried to the
|
|
4
|
+
script on the <time> as a data-* attribute; the dataset reads them back in
|
|
5
|
+
camelCase, as Intl names them. A parameter not given drops its attribute,
|
|
6
|
+
and Intl's default stands.
|
|
7
|
+
-->
|
|
8
|
+
<time
|
|
9
|
+
data-locale="{{locale}}"
|
|
10
|
+
data-date-style="{{date-style}}"
|
|
11
|
+
data-time-style="{{time-style}}"
|
|
12
|
+
data-time-zone="{{time-zone}}"
|
|
13
|
+
data-time-zone-name="{{time-zone-name}}"
|
|
14
|
+
data-hour-cycle="{{hour-cycle}}"
|
|
15
|
+
data-weekday="{{weekday}}"
|
|
16
|
+
data-era="{{era}}"
|
|
17
|
+
data-year="{{year}}"
|
|
18
|
+
data-month="{{month}}"
|
|
19
|
+
data-day="{{day}}"
|
|
20
|
+
data-hour="{{hour}}"
|
|
21
|
+
data-minute="{{minute}}"
|
|
22
|
+
data-second="{{second}}"
|
|
23
|
+
></time>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lb-number.browser.d.ts","sourceRoot":"","sources":["../widgets/lb-number.browser.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { ATTR_COLUMN_VALUE } from "@loadbare/app/constants";
|
|
3
|
+
/**
|
|
4
|
+
* Shows the value that landed on it through `Intl.NumberFormat`, in the
|
|
5
|
+
* `<data>` its definition holds, with the value itself as the `<data>`'s
|
|
6
|
+
* `value`. Not a control: the hub stamps `lb-column-value` on the tag and
|
|
7
|
+
* never gathers it.
|
|
8
|
+
*
|
|
9
|
+
* The value reaches `format` as the string it arrived as, so a decimal keeps
|
|
10
|
+
* every digit a number would round away. A value that is no number shows as
|
|
11
|
+
* it arrived.
|
|
12
|
+
*/
|
|
13
|
+
class LbNumber extends HTMLElement {
|
|
14
|
+
static observedAttributes = [ATTR_COLUMN_VALUE];
|
|
15
|
+
formatter;
|
|
16
|
+
attributeChangedCallback(_name, _old, value) {
|
|
17
|
+
const data = this.querySelector("data");
|
|
18
|
+
if (!data)
|
|
19
|
+
return;
|
|
20
|
+
if (value === null) {
|
|
21
|
+
data.removeAttribute("value");
|
|
22
|
+
data.textContent = "";
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
data.value = value;
|
|
26
|
+
data.textContent = isNumber(value)
|
|
27
|
+
? this.format(data).format(value)
|
|
28
|
+
: value;
|
|
29
|
+
}
|
|
30
|
+
format(data) {
|
|
31
|
+
const { locale, ...options } = data.dataset;
|
|
32
|
+
return (this.formatter ??= new Intl.NumberFormat(locale, options));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Whether a stamp holds a number: anything `Number` reads but blank. */
|
|
36
|
+
function isNumber(value) {
|
|
37
|
+
return value.trim() !== "" && !Number.isNaN(Number(value));
|
|
38
|
+
}
|
|
39
|
+
customElements.define("lb-number", LbNumber);
|
|
40
|
+
//# sourceMappingURL=lb-number.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lb-number.browser.js","sourceRoot":"","sources":["../widgets/lb-number.browser.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,CAAC,kBAAkB,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAExC,SAAS,CAAqB;IAEtC,wBAAwB,CACtB,KAAa,EACb,IAAmB,EACnB,KAAoB;QAEpB,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAC9B,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC;YAChC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAA0B,CAAC;YACtD,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC;IAEO,MAAM,CAAC,IAAqB;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC,YAAY,CAC9C,MAAM,EACN,OAAmC,CACpC,CAAC,CAAC;IACL,CAAC;;AAGH,yEAAyE;AACzE,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n\nimport { ATTR_COLUMN_VALUE } from \"@loadbare/app/constants\";\n\n/**\n * Shows the value that landed on it through `Intl.NumberFormat`, in the\n * `<data>` its definition holds, with the value itself as the `<data>`'s\n * `value`. Not a control: the hub stamps `lb-column-value` on the tag and\n * never gathers it.\n *\n * The value reaches `format` as the string it arrived as, so a decimal keeps\n * every digit a number would round away. A value that is no number shows as\n * it arrived.\n */\nclass LbNumber extends HTMLElement {\n static observedAttributes = [ATTR_COLUMN_VALUE];\n\n private formatter?: Intl.NumberFormat;\n\n attributeChangedCallback(\n _name: string,\n _old: string | null,\n value: string | null,\n ): void {\n const data = this.querySelector(\"data\");\n if (!data) return;\n if (value === null) {\n data.removeAttribute(\"value\");\n data.textContent = \"\";\n return;\n }\n data.value = value;\n data.textContent = isNumber(value)\n ? this.format(data).format(value as unknown as number)\n : value;\n }\n\n private format(data: HTMLDataElement): Intl.NumberFormat {\n const { locale, ...options } = data.dataset;\n return (this.formatter ??= new Intl.NumberFormat(\n locale,\n options as Intl.NumberFormatOptions,\n ));\n }\n}\n\n/** Whether a stamp holds a number: anything `Number` reads but blank. */\nfunction isNumber(value: string): boolean {\n return value.trim() !== \"\" && !Number.isNaN(Number(value));\n}\n\ncustomElements.define(\"lb-number\", LbNumber);\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A number, as the browser's Intl.NumberFormat shows it. Each parameter is
|
|
3
|
+
one of Intl's own options, in kebab-case, carried to the script on the
|
|
4
|
+
<data> as a data-* attribute; the dataset reads them back in camelCase, as
|
|
5
|
+
Intl names them. A parameter not given drops its attribute, and Intl's
|
|
6
|
+
default stands.
|
|
7
|
+
-->
|
|
8
|
+
<data
|
|
9
|
+
data-locale="{{locale}}"
|
|
10
|
+
data-style="{{style}}"
|
|
11
|
+
data-currency="{{currency}}"
|
|
12
|
+
data-currency-display="{{currency-display}}"
|
|
13
|
+
data-currency-sign="{{currency-sign}}"
|
|
14
|
+
data-unit="{{unit}}"
|
|
15
|
+
data-unit-display="{{unit-display}}"
|
|
16
|
+
data-notation="{{notation}}"
|
|
17
|
+
data-compact-display="{{compact-display}}"
|
|
18
|
+
data-sign-display="{{sign-display}}"
|
|
19
|
+
data-minimum-integer-digits="{{minimum-integer-digits}}"
|
|
20
|
+
data-minimum-fraction-digits="{{minimum-fraction-digits}}"
|
|
21
|
+
data-maximum-fraction-digits="{{maximum-fraction-digits}}"
|
|
22
|
+
data-minimum-significant-digits="{{minimum-significant-digits}}"
|
|
23
|
+
data-maximum-significant-digits="{{maximum-significant-digits}}"
|
|
24
|
+
></data>
|
package/docs/lb-date.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# `lb-date`
|
|
2
|
+
|
|
3
|
+
> Status: a barebones starter. Iterative use will drive improvements.
|
|
4
|
+
|
|
5
|
+
A date or a time shown by the browser's `Intl.DateTimeFormat`. Not a
|
|
6
|
+
control: write `lb-column` on the tag, and the hub lands the column on it
|
|
7
|
+
and never gathers it.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<lb-date lb-column="due" exp-date-style="medium"></lb-date>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Expansion Attributes
|
|
14
|
+
|
|
15
|
+
Each parameter is one of `Intl.DateTimeFormat`'s options, in kebab-case. A
|
|
16
|
+
parameter not given leaves Intl's default.
|
|
17
|
+
|
|
18
|
+
| Parameter | `Intl.DateTimeFormat` option |
|
|
19
|
+
| -------------------- | ------------------------------------- |
|
|
20
|
+
| `exp-locale` | the locale, the browser's when absent |
|
|
21
|
+
| `exp-date-style` | `dateStyle` |
|
|
22
|
+
| `exp-time-style` | `timeStyle` |
|
|
23
|
+
| `exp-time-zone` | `timeZone` |
|
|
24
|
+
| `exp-time-zone-name` | `timeZoneName` |
|
|
25
|
+
| `exp-hour-cycle` | `hourCycle` |
|
|
26
|
+
| `exp-weekday` | `weekday` |
|
|
27
|
+
| `exp-era` | `era` |
|
|
28
|
+
| `exp-year` | `year` |
|
|
29
|
+
| `exp-month` | `month` |
|
|
30
|
+
| `exp-day` | `day` |
|
|
31
|
+
| `exp-hour` | `hour` |
|
|
32
|
+
| `exp-minute` | `minute` |
|
|
33
|
+
| `exp-second` | `second` |
|
|
34
|
+
|
|
35
|
+
Intl refuses `exp-date-style` or `exp-time-style` beside any of
|
|
36
|
+
`exp-weekday` through `exp-second`.
|
|
37
|
+
|
|
38
|
+
## The value
|
|
39
|
+
|
|
40
|
+
The widget reads the value as JavaScript's `Date` does. A date alone, as
|
|
41
|
+
`YYYY-MM-DD`, shows as that day in every time zone. A value that is no
|
|
42
|
+
date shows as it arrived. Null shows nothing.
|
|
43
|
+
|
|
44
|
+
## Styling
|
|
45
|
+
|
|
46
|
+
The definition is a `<time>` whose text is the formatted date and whose
|
|
47
|
+
`datetime` is the value as it arrived. The hub stamps the tag with
|
|
48
|
+
`lb-column-value`, the value as it arrived.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# `lb-number`
|
|
2
|
+
|
|
3
|
+
> Status: a barebones starter. Iterative use will drive improvements.
|
|
4
|
+
|
|
5
|
+
A number shown by the browser's `Intl.NumberFormat`. Not a control: write
|
|
6
|
+
`lb-column` on the tag, and the hub lands the column on it and never gathers
|
|
7
|
+
it.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<lb-number lb-column="balance" exp-style="currency" exp-currency="USD"></lb-number>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Expansion Attributes
|
|
14
|
+
|
|
15
|
+
Each parameter is one of `Intl.NumberFormat`'s options, in kebab-case. A
|
|
16
|
+
parameter not given leaves Intl's default.
|
|
17
|
+
|
|
18
|
+
| Parameter | `Intl.NumberFormat` option |
|
|
19
|
+
| -------------------------------- | -------------------------------------- |
|
|
20
|
+
| `exp-locale` | the locale, the browser's when absent |
|
|
21
|
+
| `exp-style` | `style` |
|
|
22
|
+
| `exp-currency` | `currency` |
|
|
23
|
+
| `exp-currency-display` | `currencyDisplay` |
|
|
24
|
+
| `exp-currency-sign` | `currencySign` |
|
|
25
|
+
| `exp-unit` | `unit` |
|
|
26
|
+
| `exp-unit-display` | `unitDisplay` |
|
|
27
|
+
| `exp-notation` | `notation` |
|
|
28
|
+
| `exp-compact-display` | `compactDisplay` |
|
|
29
|
+
| `exp-sign-display` | `signDisplay` |
|
|
30
|
+
| `exp-minimum-integer-digits` | `minimumIntegerDigits` |
|
|
31
|
+
| `exp-minimum-fraction-digits` | `minimumFractionDigits` |
|
|
32
|
+
| `exp-maximum-fraction-digits` | `maximumFractionDigits` |
|
|
33
|
+
| `exp-minimum-significant-digits` | `minimumSignificantDigits` |
|
|
34
|
+
| `exp-maximum-significant-digits` | `maximumSignificantDigits` |
|
|
35
|
+
|
|
36
|
+
## The value
|
|
37
|
+
|
|
38
|
+
The widget formats the value as the string it arrived as, so a decimal the
|
|
39
|
+
query sends as a string keeps every digit. A value that is no number shows
|
|
40
|
+
as it arrived. Null shows nothing.
|
|
41
|
+
|
|
42
|
+
## Styling
|
|
43
|
+
|
|
44
|
+
The definition is a `<data>` whose text is the formatted number and whose
|
|
45
|
+
`value` is the number as it arrived. The hub stamps the tag with
|
|
46
|
+
`lb-column-value`, the number as it arrived, so a stylesheet selects on the
|
|
47
|
+
value itself:
|
|
48
|
+
|
|
49
|
+
```css
|
|
50
|
+
lb-number[lb-column-value^="-"] {
|
|
51
|
+
color: var(--negative);
|
|
52
|
+
}
|
|
53
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadbare/widgets",
|
|
3
|
-
"description": "The basic widget set for @loadbare/app: input, select, options, picker, table, unknown-page, confirm, form, insert-dialog, master, checkbox",
|
|
4
|
-
"version": "0.9.
|
|
3
|
+
"description": "The basic widget set for @loadbare/app: input, select, options, picker, table, unknown-page, confirm, form, insert-dialog, master, checkbox, number, date",
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|