@fusion.dev/helix-core 0.58.0 → 0.59.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/custom-elements.json +647 -41
- package/dist/controllers/aria-forward-controller/aria-forward-controller.js +2 -2
- package/dist/controllers/chart-pointer-controller/chart-pointer-controller.d.ts +2 -2
- package/dist/controllers/chart-pointer-controller/chart-pointer-controller.js +2 -1
- package/dist/controllers/indicator-controller/indicator-controller.js +2 -1
- package/dist/controllers/paint-gate-controller/paint-gate-controller.d.ts +135 -0
- package/dist/controllers/paint-gate-controller/paint-gate-controller.js +97 -0
- package/dist/controllers/source-controller/source-controller.js +2 -2
- package/dist/index.d.ts +8 -3
- package/dist/index.js +8 -3
- package/dist/mixins/mixin-chart-source/mixin-chart-source.d.ts +2 -2
- package/dist/utils/css-color/css-color.d.ts +0 -14
- package/dist/utils/css-color/css-color.js +0 -22
- package/dist/utils/draw-tooltip/draw-tooltip.d.ts +6 -6
- package/dist/utils/element-by-id/element-by-id.d.ts +64 -0
- package/dist/utils/element-by-id/element-by-id.js +10 -0
- package/dist/utils/inline-step/inline-step.js +2 -2
- package/dist/utils/is-rtl/is-rtl.d.ts +19 -0
- package/dist/utils/is-rtl/is-rtl.js +1 -0
- package/dist/utils/split-values/split-values.d.ts +24 -0
- package/dist/utils/split-values/split-values.js +23 -0
- package/dist/utils/value-as/value-as.d.ts +31 -0
- package/dist/utils/value-as/value-as.js +13 -0
- package/dist/utils/write-time/write-time.d.ts +14 -0
- package/dist/utils/write-time/write-time.js +12 -0
- package/dist/utils/written-list/written-list.d.ts +13 -0
- package/dist/utils/written-list/written-list.js +3 -0
- package/package.json +5 -4
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
* control would report a date the reader never typed and never saw.
|
|
7
7
|
*/
|
|
8
8
|
export declare const valueAsDate: (value: string) => Date | null;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a value names a real day, which is the shape *and* the range.
|
|
11
|
+
*
|
|
12
|
+
* The predicate form of the conversion above, here rather than in a family
|
|
13
|
+
* because a family writing its own gets the shape right and the range wrong.
|
|
14
|
+
* Two did: one tested `\d{4}-\d{2}-\d{2}` and reported `2026-02-31` as whole
|
|
15
|
+
* while its own `valueAsDate` answered `null`, and the other guarded
|
|
16
|
+
* `Number.isNaN(date.getTime())`, which never fires, `Date.UTC(2026, 1, 31)`
|
|
17
|
+
* being a perfectly good third of March.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isDateValue: (value: string) => boolean;
|
|
9
20
|
/** The `YYYY-MM-DD` value for a date, or the empty string, which is how a control says nothing. */
|
|
10
21
|
export declare const dateAsValue: (date: Date | null) => string;
|
|
11
22
|
/**
|
|
@@ -24,6 +35,26 @@ export declare const valueAsTime: (value: string) => Date | null;
|
|
|
24
35
|
* format change dressed as a conversion.
|
|
25
36
|
*/
|
|
26
37
|
export declare const timeAsValue: (date: Date | null) => string;
|
|
38
|
+
/**
|
|
39
|
+
* The minutes since midnight an `HH:mm` value names, or `null`.
|
|
40
|
+
*
|
|
41
|
+
* **Minute precision, which is narrower than `valueAsTime` above and is meant
|
|
42
|
+
* to be.** That one takes seconds because `<input type="time">` does at a step
|
|
43
|
+
* below a minute. This library's time controls have no such step: theirs is in
|
|
44
|
+
* minutes and floored at one, so nothing they offer or write ever carries a
|
|
45
|
+
* second, and a value that did would lose it here silently. Two readings of one
|
|
46
|
+
* string, and a control picks the one it can hold.
|
|
47
|
+
*/
|
|
48
|
+
export declare const valueAsMinutes: (value: string) => number | null;
|
|
49
|
+
/**
|
|
50
|
+
* Minutes since midnight as `HH:mm`, wrapping rather than running off the day.
|
|
51
|
+
*
|
|
52
|
+
* A step past midnight is the next morning, which is what a list of offered
|
|
53
|
+
* times does at its end and what an arrow key does at either.
|
|
54
|
+
*/
|
|
55
|
+
export declare const minutesAsValue: (minutes: number) => string;
|
|
56
|
+
/** Whether a value is a time these controls can hold, which is minute precision. */
|
|
57
|
+
export declare const isTimeValue: (value: string) => boolean;
|
|
27
58
|
/**
|
|
28
59
|
* The number a value holds, or `NaN`.
|
|
29
60
|
*
|
|
@@ -11,6 +11,7 @@ export const valueAsDate = (value) => {
|
|
|
11
11
|
const rolled = date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day;
|
|
12
12
|
return rolled ? null : date;
|
|
13
13
|
};
|
|
14
|
+
export const isDateValue = (value) => valueAsDate(value) !== null;
|
|
14
15
|
export const dateAsValue = (date) => {
|
|
15
16
|
if (!date || Number.isNaN(date.getTime())) {
|
|
16
17
|
return '';
|
|
@@ -40,5 +41,17 @@ export const timeAsValue = (date) => {
|
|
|
40
41
|
const hm = `${pad(clock.getUTCHours())}:${pad(clock.getUTCMinutes())}`;
|
|
41
42
|
return seconds === 0 ? hm : `${hm}:${pad(clock.getUTCSeconds())}`;
|
|
42
43
|
};
|
|
44
|
+
export const valueAsMinutes = (value) => {
|
|
45
|
+
const parts = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(value);
|
|
46
|
+
if (!parts) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return Number(parts[1]) * 60 + Number(parts[2]);
|
|
50
|
+
};
|
|
51
|
+
export const minutesAsValue = (minutes) => {
|
|
52
|
+
const whole = ((Math.round(minutes) % 1440) + 1440) % 1440;
|
|
53
|
+
return `${String(Math.floor(whole / 60)).padStart(2, '0')}:${String(whole % 60).padStart(2, '0')}`;
|
|
54
|
+
};
|
|
55
|
+
export const isTimeValue = (value) => valueAsMinutes(value) !== null;
|
|
43
56
|
export const valueAsNumber = (value) => value.trim() === '' ? Number.NaN : Number(value);
|
|
44
57
|
export const numberAsValue = (count) => (Number.isNaN(count) ? '' : String(count));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A time written the way the reader's locale writes one.
|
|
3
|
+
*
|
|
4
|
+
* `Intl` decides between a twelve and a twenty-four hour clock, because that is
|
|
5
|
+
* a property of the locale rather than of any component: `en-US` gets `2:30 PM`
|
|
6
|
+
* and `en-GB` gets `14:30` without either being configured. There is no flag to
|
|
7
|
+
* force one, deliberately. A product that needs to override its reader's own
|
|
8
|
+
* convention has a locale problem rather than a component one, and the value is
|
|
9
|
+
* 24 hour regardless.
|
|
10
|
+
*
|
|
11
|
+
* A value this cannot read is handed back unchanged, so a field showing what is
|
|
12
|
+
* being typed shows the letters rather than blanking under the reader.
|
|
13
|
+
*/
|
|
14
|
+
export declare const writeTime: (value: string, locale?: string) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { valueAsMinutes } from '../value-as/value-as.js';
|
|
2
|
+
export const writeTime = (value, locale) => {
|
|
3
|
+
const minutes = valueAsMinutes(value);
|
|
4
|
+
if (minutes === null) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
const at = new Date(Date.UTC(2000, 0, 1, Math.floor(minutes / 60), minutes % 60));
|
|
8
|
+
return new Intl.DateTimeFormat(locale || undefined, {
|
|
9
|
+
timeStyle: 'short',
|
|
10
|
+
timeZone: 'UTC',
|
|
11
|
+
}).format(at);
|
|
12
|
+
};
|
|
@@ -21,3 +21,16 @@
|
|
|
21
21
|
* resolve an id nobody can write.
|
|
22
22
|
*/
|
|
23
23
|
export declare const writtenList: (source: string | undefined) => string[];
|
|
24
|
+
/**
|
|
25
|
+
* The same list read as numbers, with everything that is not one dropped.
|
|
26
|
+
*
|
|
27
|
+
* **A stray entry leaves rather than becoming `NaN`.** A comparison against
|
|
28
|
+
* `NaN` is false in both directions and a `NaN` drawn is nothing at all, so one
|
|
29
|
+
* mistyped bound in `thresholds="0, 1, x, 6"` would color cells by a rule no
|
|
30
|
+
* reader can see. Dropped, the rest of the list still means what it says.
|
|
31
|
+
*
|
|
32
|
+
* **Which numbers count is the caller's question.** Finiteness is all this can
|
|
33
|
+
* answer, because a number that makes sense here is a bound, a reading and a
|
|
34
|
+
* playback rate, and only the caller knows that a rate of zero is not a rate.
|
|
35
|
+
*/
|
|
36
|
+
export declare const writtenNumbers: (source: string | undefined) => number[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusion.dev/helix-core",
|
|
3
3
|
"description": "Helix element primitives: base classes, mixins, decorators, utilities.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.59.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ross Sheppard <ross.sheppard@fusion.dev>",
|
|
7
7
|
"repository": {
|
|
@@ -34,12 +34,13 @@
|
|
|
34
34
|
"bugs": "https://github.com/project-fusion/fusion/issues",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@floating-ui/dom": "^1.8.0",
|
|
37
|
-
"@fusion.dev/helix-icons": "0.
|
|
37
|
+
"@fusion.dev/helix-icons": "0.59.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|
|
41
|
-
"@fusion.dev/helix-cem": "0.
|
|
42
|
-
"@fusion.dev/helix-testing": "0.
|
|
41
|
+
"@fusion.dev/helix-cem": "0.59.0",
|
|
42
|
+
"@fusion.dev/helix-testing": "0.59.0",
|
|
43
|
+
"@lit-labs/ssr": "^4.1.0",
|
|
43
44
|
"lit": "^3.2.1"
|
|
44
45
|
},
|
|
45
46
|
"homepage": "https://fusion.dev",
|