@fusion.dev/helix-core 0.58.1 → 0.59.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.
Files changed (28) hide show
  1. package/custom-elements.json +612 -40
  2. package/dist/controllers/aria-forward-controller/aria-forward-controller.js +2 -2
  3. package/dist/controllers/chart-pointer-controller/chart-pointer-controller.d.ts +2 -2
  4. package/dist/controllers/chart-pointer-controller/chart-pointer-controller.js +2 -1
  5. package/dist/controllers/indicator-controller/indicator-controller.js +2 -1
  6. package/dist/controllers/paint-gate-controller/paint-gate-controller.d.ts +135 -0
  7. package/dist/controllers/paint-gate-controller/paint-gate-controller.js +97 -0
  8. package/dist/controllers/source-controller/source-controller.js +2 -2
  9. package/dist/index.d.ts +8 -3
  10. package/dist/index.js +8 -3
  11. package/dist/mixins/mixin-chart-source/mixin-chart-source.d.ts +2 -2
  12. package/dist/utils/css-color/css-color.d.ts +0 -14
  13. package/dist/utils/css-color/css-color.js +0 -22
  14. package/dist/utils/draw-tooltip/draw-tooltip.d.ts +6 -6
  15. package/dist/utils/element-by-id/element-by-id.d.ts +64 -0
  16. package/dist/utils/element-by-id/element-by-id.js +10 -0
  17. package/dist/utils/inline-step/inline-step.js +2 -2
  18. package/dist/utils/is-rtl/is-rtl.d.ts +19 -0
  19. package/dist/utils/is-rtl/is-rtl.js +1 -0
  20. package/dist/utils/split-values/split-values.d.ts +24 -0
  21. package/dist/utils/split-values/split-values.js +23 -0
  22. package/dist/utils/value-as/value-as.d.ts +20 -0
  23. package/dist/utils/value-as/value-as.js +12 -0
  24. package/dist/utils/write-time/write-time.d.ts +14 -0
  25. package/dist/utils/write-time/write-time.js +12 -0
  26. package/dist/utils/written-list/written-list.d.ts +13 -0
  27. package/dist/utils/written-list/written-list.js +3 -0
  28. package/package.json +5 -4
@@ -35,6 +35,26 @@ export declare const valueAsTime: (value: string) => Date | null;
35
35
  * format change dressed as a conversion.
36
36
  */
37
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;
38
58
  /**
39
59
  * The number a value holds, or `NaN`.
40
60
  *
@@ -41,5 +41,17 @@ export const timeAsValue = (date) => {
41
41
  const hm = `${pad(clock.getUTCHours())}:${pad(clock.getUTCMinutes())}`;
42
42
  return seconds === 0 ? hm : `${hm}:${pad(clock.getUTCSeconds())}`;
43
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;
44
56
  export const valueAsNumber = (value) => value.trim() === '' ? Number.NaN : Number(value);
45
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[];
@@ -1 +1,4 @@
1
1
  export const writtenList = (source) => (source ?? '').split(/[\s,]+/).filter((one) => one !== '');
2
+ export const writtenNumbers = (source) => writtenList(source)
3
+ .map(Number)
4
+ .filter((one) => Number.isFinite(one));
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.58.1",
4
+ "version": "0.59.1",
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.58.1"
37
+ "@fusion.dev/helix-icons": "0.59.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@custom-elements-manifest/analyzer": "^0.11.0",
41
- "@fusion.dev/helix-cem": "0.58.1",
42
- "@fusion.dev/helix-testing": "0.58.1",
41
+ "@fusion.dev/helix-cem": "0.59.1",
42
+ "@fusion.dev/helix-testing": "0.59.1",
43
+ "@lit-labs/ssr": "^4.1.0",
43
44
  "lit": "^3.2.1"
44
45
  },
45
46
  "homepage": "https://fusion.dev",