@fusion.dev/helix-core 0.148.0 → 0.149.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 (70) hide show
  1. package/custom-elements.json +8518 -6050
  2. package/dist/controllers/aria-forward-controller/aria-forward-controller.js +1 -1
  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 +5 -4
  5. package/dist/controllers/machine-controller/machine-controller.d.ts +69 -0
  6. package/dist/controllers/machine-controller/machine-controller.js +78 -0
  7. package/dist/controllers/machine-controller/machine.d.ts +93 -0
  8. package/dist/controllers/machine-controller/machine.js +20 -0
  9. package/dist/controllers/reorder-controller/reorder-controller.d.ts +285 -0
  10. package/dist/controllers/reorder-controller/reorder-controller.js +497 -0
  11. package/dist/controllers/source-controller/source-controller.js +1 -1
  12. package/dist/controllers/virtualize-controller/heights.js +1 -1
  13. package/dist/controllers/virtualize-controller/virtualize-controller.d.ts +117 -3
  14. package/dist/controllers/virtualize-controller/virtualize-controller.js +134 -32
  15. package/dist/events/before-reorder.d.ts +14 -0
  16. package/dist/events/before-reorder.js +11 -0
  17. package/dist/events/details.d.ts +28 -0
  18. package/dist/events/events.d.ts +4 -2
  19. package/dist/events/events.js +3 -1
  20. package/dist/events/names.js +1 -1
  21. package/dist/events/reorder.d.ts +18 -12
  22. package/dist/events/reordered.d.ts +4 -4
  23. package/dist/helix-element/helix-element.js +2 -1
  24. package/dist/helix-element/react-audit-off.d.ts +11 -0
  25. package/dist/helix-element/react-audit-off.js +1 -0
  26. package/dist/helix-element/react-audit.d.ts +20 -0
  27. package/dist/helix-element/react-audit.js +56 -0
  28. package/dist/helix-element/react-bridge.d.ts +2 -22
  29. package/dist/helix-element/react-bridge.js +1 -56
  30. package/dist/index.d.ts +10 -4
  31. package/dist/index.js +10 -4
  32. package/dist/mixins/mixin-chart-source/mixin-chart-source.d.ts +2 -2
  33. package/dist/mixins/mixin-chart-source/mixin-chart-source.js +3 -0
  34. package/dist/mixins/mixin-collection/mixin-collection.js +4 -0
  35. package/dist/mixins/mixin-dismissible/mixin-dismissible.js +3 -0
  36. package/dist/mixins/mixin-field/mixin-field.js +1 -1
  37. package/dist/mixins/mixin-segmented-field/mixin-segmented-field.d.ts +12 -0
  38. package/dist/mixins/mixin-segmented-field/mixin-segmented-field.js +15 -2
  39. package/dist/mixins/mixin-tokens/mixin-tokens.d.ts +5 -0
  40. package/dist/mixins/mixin-tokens/mixin-tokens.js +13 -2
  41. package/dist/mixins/mixin-viewport/mixin-viewport.d.ts +17 -15
  42. package/dist/mixins/mixin-viewport/mixin-viewport.js +15 -34
  43. package/dist/utils/calendar/calendar.d.ts +27 -0
  44. package/dist/utils/calendar/calendar.js +17 -0
  45. package/dist/utils/count-label/count-label.d.ts +7 -4
  46. package/dist/utils/count-label/count-label.js +2 -5
  47. package/dist/utils/date-segments/date-segments.d.ts +2 -1
  48. package/dist/utils/date-segments/date-segments.js +10 -0
  49. package/dist/utils/locale-of/locale-of.d.ts +5 -0
  50. package/dist/utils/locale-of/locale-of.js +8 -2
  51. package/dist/utils/reorder/drag-preview.d.ts +46 -0
  52. package/dist/utils/reorder/drag-preview.js +58 -0
  53. package/dist/utils/reorder/reorder.d.ts +178 -0
  54. package/dist/utils/reorder/reorder.js +112 -0
  55. package/dist/utils/report-runtime/report-runtime.d.ts +7 -4
  56. package/dist/utils/slotted-words/slotted-words.d.ts +3 -2
  57. package/dist/utils/slotted-words/slotted-words.js +3 -1
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/dist/words/index.d.ts +3 -0
  61. package/dist/words/index.js +3 -0
  62. package/dist/words/message.d.ts +47 -0
  63. package/dist/words/message.js +152 -0
  64. package/dist/words/registry.d.ts +89 -0
  65. package/dist/words/registry.js +101 -0
  66. package/dist/words/words-locale.d.ts +34 -0
  67. package/dist/words/words-locale.js +30 -0
  68. package/dist/words/words.d.ts +52 -0
  69. package/dist/words/words.js +100 -0
  70. package/package.json +40 -25
@@ -0,0 +1,52 @@
1
+ import type { ReactiveElement } from 'lit';
2
+ import { type MessageValues } from './message.js';
3
+ /** An element that reads words: a Lit element, perhaps with a `locale`. */
4
+ type Host = ReactiveElement & {
5
+ locale?: string | undefined;
6
+ };
7
+ /**
8
+ * Makes a property a word property: one a page can set, register for a
9
+ * locale with `registerWords`, or leave in English. Written above
10
+ * `@property`, which declares its attribute:
11
+ *
12
+ * ```ts
13
+ * static words = 'helix-combobox'
14
+ *
15
+ * @words
16
+ * @property({ attribute: 'empty-text' })
17
+ * emptyText = 'No matches'
18
+ * ```
19
+ *
20
+ * **Reading the property gives the word in the element's locale**: a value
21
+ * you set, then the words registered for the element's locale, then the
22
+ * initializer, which is the English. Setting any value, the English included,
23
+ * makes it yours. Setting `null` or `undefined`, or removing the attribute,
24
+ * gives the registry's word back. So does an empty validation message, a
25
+ * property whose name ends in `Message`: a field never reports a failed check
26
+ * with no sentence, and a template that renders an empty variable into
27
+ * `range-overflow-message=""` gets the built-in sentence.
28
+ *
29
+ * **A subclass or a family that overrides a word's English writes `@words`
30
+ * above the override**, and its initializer is the English: a family's
31
+ * `Remove filter` over a mixin's `Dismiss`. Every `@words` declaration has an
32
+ * initializer, so an element knows how many of its sets are English.
33
+ *
34
+ * The class's static `words` names the key its words are registered under, the
35
+ * family's styled tag, so the headless and styled tiers share one key. A mixin
36
+ * that declares words writes `static words = ''`, which its host's key
37
+ * replaces; a host with no key of its own reads its tag name. An element whose
38
+ * words change updates once, with each changed property named.
39
+ */
40
+ export declare const words: (proto: object, name: string) => void;
41
+ /**
42
+ * A word property of an element, formatted: its values put in, its numbers
43
+ * written in the element's locale, and its plural forms picked by the rules
44
+ * of the language its words are in. A property no `@words` declares is
45
+ * formatted as it reads, with the element's own plural rules.
46
+ *
47
+ * ```ts
48
+ * formatWords(this, 'resultsLabel', { count: 3 }) // '3 results'
49
+ * ```
50
+ */
51
+ export declare const formatWords: (host: Host, name: string, values?: MessageValues) => string;
52
+ export {};
@@ -0,0 +1,100 @@
1
+ import { formatMessage } from './message.js';
2
+ import { lookupWord, watchWords, wordsRegistered } from './registry.js';
3
+ import { wordsLocale } from './words-locale.js';
4
+ const HELD = Symbol();
5
+ const heldBy = (host) => host[HELD] ?? {};
6
+ const declared = new WeakMap();
7
+ const initializers = (host, name) => {
8
+ let count = 0;
9
+ for (let proto = Object.getPrototypeOf(host); proto; proto = Object.getPrototypeOf(proto)) {
10
+ count += declared.get(proto)?.has(name) ? 1 : 0;
11
+ }
12
+ return count;
13
+ };
14
+ const resolve = (host, name) => {
15
+ const word = heldBy(host)[name];
16
+ if (!word) {
17
+ return [host[name], ''];
18
+ }
19
+ const { e: english, o: own } = word;
20
+ const table = typeof english === 'object' && english;
21
+ let found = [own, ''];
22
+ if (own == null || table) {
23
+ const registered = wordsRegistered()
24
+ ? lookupWord(wordsLocale(host), host.constructor.words || host.localName, name)
25
+ : undefined;
26
+ found = table
27
+ ? [{ ...table, ...registered?.[0], ...own }, '']
28
+ : (registered ?? [english, 'en']);
29
+ }
30
+ word.l = found[0];
31
+ return found;
32
+ };
33
+ const same = (one, two) => one === two || JSON.stringify(one) === JSON.stringify(two);
34
+ const recheck = (host) => {
35
+ for (const [name, word] of Object.entries(heldBy(host))) {
36
+ const before = word.l;
37
+ if ('l' in word && !same(before, resolve(host, name)[0])) {
38
+ host.requestUpdate(name, before);
39
+ }
40
+ }
41
+ };
42
+ const watcher = (host) => {
43
+ let stop;
44
+ let locale = '';
45
+ return {
46
+ hostConnected: () => {
47
+ locale = wordsLocale(host);
48
+ stop = watchWords(() => {
49
+ recheck(host);
50
+ const now = wordsLocale(host);
51
+ if (now !== locale) {
52
+ locale = now;
53
+ host.requestUpdate();
54
+ }
55
+ });
56
+ },
57
+ hostDisconnected: () => stop?.(),
58
+ hostUpdated: () => {
59
+ if (host.hydrating === true) {
60
+ queueMicrotask(() => recheck(host));
61
+ }
62
+ },
63
+ };
64
+ };
65
+ export const words = (proto, name) => {
66
+ if (!Object.getOwnPropertyDescriptor(proto, name)) {
67
+ ;
68
+ proto.constructor.createProperty(name);
69
+ }
70
+ const names = declared.get(proto) ?? new Set();
71
+ declared.set(proto, names.add(name));
72
+ Object.defineProperty(proto, name, {
73
+ configurable: true,
74
+ enumerable: true,
75
+ get() {
76
+ return resolve(this, name)[0];
77
+ },
78
+ set(value) {
79
+ if (!this[HELD]) {
80
+ this[HELD] = {};
81
+ this.addController(watcher(this));
82
+ }
83
+ const word = (this[HELD][name] ??= { i: 0 });
84
+ if (word.i < initializers(this, name)) {
85
+ word.i++;
86
+ word.e = value;
87
+ this.requestUpdate(name, undefined, undefined, true, value);
88
+ return;
89
+ }
90
+ const before = this[name];
91
+ word.o = value === '' && name.endsWith('Message') ? undefined : value;
92
+ this.requestUpdate(name, before);
93
+ },
94
+ });
95
+ };
96
+ export const formatWords = (host, name, values = {}) => {
97
+ const [message, from] = resolve(host, name);
98
+ const locale = wordsLocale(host);
99
+ return formatMessage(String(message ?? ''), values, locale, { plurals: from || locale });
100
+ };
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.148.0",
4
+ "version": "0.149.1",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -17,7 +17,29 @@
17
17
  "types": "./dist/index.d.ts",
18
18
  "default": "./dist/index.js"
19
19
  },
20
- "./custom-elements.json": "./custom-elements.json"
20
+ "./audits/name": {
21
+ "types": "./dist/utils/audit-name/audit-name.d.ts",
22
+ "development": "./dist/utils/audit-name/audit-name.js",
23
+ "helix-development": "./dist/utils/audit-name/audit-name.js",
24
+ "default": "./dist/utils/audit-name/audit-name-off.js"
25
+ },
26
+ "./audits/react": {
27
+ "types": "./dist/helix-element/react-audit.d.ts",
28
+ "development": "./dist/helix-element/react-audit.js",
29
+ "helix-development": "./dist/helix-element/react-audit.js",
30
+ "default": "./dist/helix-element/react-audit-off.js"
31
+ },
32
+ "./audits/source": {
33
+ "types": "./dist/utils/audit-source/audit-source.d.ts",
34
+ "development": "./dist/utils/audit-source/audit-source.js",
35
+ "helix-development": "./dist/utils/audit-source/audit-source.js",
36
+ "default": "./dist/utils/audit-source/audit-source-off.js"
37
+ },
38
+ "./custom-elements.json": "./custom-elements.json",
39
+ "./words": {
40
+ "types": "./dist/words/index.d.ts",
41
+ "default": "./dist/words/index.js"
42
+ }
21
43
  },
22
44
  "files": [
23
45
  "custom-elements.json",
@@ -27,44 +49,37 @@
27
49
  "sideEffects": false,
28
50
  "scripts": {
29
51
  "analyze": "bun --bun helix-cem",
30
- "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.types.json",
31
- "test": "bun test src --conditions helix-source --conditions helix-development",
52
+ "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.types.json && bun scripts/development-imports.mjs",
53
+ "test": "bun test src --conditions helix-development",
32
54
  "typecheck": "tsc -p tsconfig.json --noEmit"
33
55
  },
34
56
  "bugs": "https://github.com/project-fusion/fusion/issues",
35
57
  "dependencies": {
36
58
  "@floating-ui/dom": "^1.8.0",
37
- "@fusion.dev/helix-icons": "0.148.0"
59
+ "@fusion.dev/helix-icons": "0.149.1"
38
60
  },
39
61
  "devDependencies": {
40
- "@fusion.dev/helix-cem": "0.148.0",
41
- "@fusion.dev/helix-testing": "0.148.0",
62
+ "@fusion.dev/helix-cem": "0.149.1",
63
+ "@fusion.dev/helix-testing": "0.149.1",
42
64
  "@lit-labs/ssr": "^4.1.0",
43
65
  "lit": "^3.2.1"
44
66
  },
45
67
  "homepage": "https://fusion.dev",
46
68
  "imports": {
47
69
  "#audit-name": {
48
- "helix-source": {
49
- "development": "./src/utils/audit-name/audit-name.ts",
50
- "helix-development": "./src/utils/audit-name/audit-name.ts",
51
- "default": "./src/utils/audit-name/audit-name-off.ts"
52
- },
53
- "types": "./dist/utils/audit-name/audit-name.d.ts",
54
- "development": "./dist/utils/audit-name/audit-name.js",
55
- "helix-development": "./dist/utils/audit-name/audit-name.js",
56
- "default": "./dist/utils/audit-name/audit-name-off.js"
70
+ "development": "./src/utils/audit-name/audit-name.ts",
71
+ "helix-development": "./src/utils/audit-name/audit-name.ts",
72
+ "default": "./src/utils/audit-name/audit-name-off.ts"
57
73
  },
58
74
  "#audit-source": {
59
- "helix-source": {
60
- "development": "./src/utils/audit-source/audit-source.ts",
61
- "helix-development": "./src/utils/audit-source/audit-source.ts",
62
- "default": "./src/utils/audit-source/audit-source-off.ts"
63
- },
64
- "types": "./dist/utils/audit-source/audit-source.d.ts",
65
- "development": "./dist/utils/audit-source/audit-source.js",
66
- "helix-development": "./dist/utils/audit-source/audit-source.js",
67
- "default": "./dist/utils/audit-source/audit-source-off.js"
75
+ "development": "./src/utils/audit-source/audit-source.ts",
76
+ "helix-development": "./src/utils/audit-source/audit-source.ts",
77
+ "default": "./src/utils/audit-source/audit-source-off.ts"
78
+ },
79
+ "#react-audit": {
80
+ "development": "./src/helix-element/react-audit.ts",
81
+ "helix-development": "./src/helix-element/react-audit.ts",
82
+ "default": "./src/helix-element/react-audit-off.ts"
68
83
  }
69
84
  },
70
85
  "keywords": [