@fusion.dev/helix-core 0.165.0 → 0.167.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.
@@ -38,8 +38,7 @@ export const MixinSegmentedField = (Base) => {
38
38
  event.preventDefault();
39
39
  if (event.inputType === 'deleteContentBackward' ||
40
40
  event.inputType === 'deleteContentForward') {
41
- this.typed = '';
42
- this.edit(element, 'Backspace');
41
+ this.erase(element);
43
42
  return;
44
43
  }
45
44
  for (const character of latinDigits(event.data ?? '')) {
@@ -105,6 +104,11 @@ export const MixinSegmentedField = (Base) => {
105
104
  this.typed = '';
106
105
  return;
107
106
  }
107
+ if (event.key === 'Backspace' || event.key === 'Delete') {
108
+ event.preventDefault();
109
+ this.erase(element);
110
+ return;
111
+ }
108
112
  if (this.edit(element, latinDigits(event.key))) {
109
113
  event.preventDefault();
110
114
  }
@@ -233,6 +237,15 @@ export const MixinSegmentedField = (Base) => {
233
237
  }
234
238
  return true;
235
239
  }
240
+ erase(element) {
241
+ if (this.edit(element, 'Backspace')) {
242
+ return;
243
+ }
244
+ if (!this.readOnly && !this.isDisabled) {
245
+ this.typed = '';
246
+ this.moveFocus(element, -1);
247
+ }
248
+ }
236
249
  willUpdate(changed) {
237
250
  super.willUpdate(changed);
238
251
  const own = this.own;
@@ -91,7 +91,8 @@ export interface SegmentKeyState {
91
91
  * nothing.
92
92
  *
93
93
  * The arrows step it and wrap, Page Up and Page Down step it by a page, Home
94
- * and End take it to its lowest and highest, Backspace and Delete empty it, a
94
+ * and End take it to its lowest and highest, Backspace and Delete take off its
95
+ * last digit and empty it from the last one, a
95
96
  * digit is typed as `typeDigit` types it, and on the meridiem a letter picks
96
97
  * the half whose word starts with it. `advance` says the segment is full and
97
98
  * focus moves on.
@@ -185,7 +185,15 @@ export const segmentKey = (key, { kind, locale, segments, system, twelve, typed
185
185
  return done(setSegment(segments, kind, key === 'Home' ? min : max, twelve, system));
186
186
  }
187
187
  if (key === 'Backspace' || key === 'Delete') {
188
- return done(setSegment(segments, kind, undefined, twelve, system));
188
+ const shown = shownValue(kind, segments, twelve);
189
+ if (shown === undefined || Number.isNaN(shown)) {
190
+ return null;
191
+ }
192
+ const left = kind === 'dayPeriod' ? '' : String(shown).slice(0, -1);
193
+ const rest = Number(left);
194
+ return left === '' || rest === 0
195
+ ? done(setSegment(segments, kind, undefined, twelve, system))
196
+ : { advance: false, segments: setSegment(segments, kind, rest, twelve, system), typed: left };
189
197
  }
190
198
  if (/^\d$/.test(key) && kind !== 'dayPeriod') {
191
199
  return typeDigit(segments, kind, typed, key, twelve, system);
@@ -34,3 +34,12 @@ export declare const rangeOf: (root: Element, needle: string) => Range[];
34
34
  * answer nothing can paint.
35
35
  */
36
36
  export declare const markMatches: (owner: Element, elements: Iterable<Element>, needle: string) => void;
37
+ /**
38
+ * Whether a filter keeps an item: its words hold the filter, in any case, or
39
+ * `match` says so where the page gave one. An empty filter keeps everything.
40
+ *
41
+ * One answer for every family that filters, so Listbox, Command and a
42
+ * filterable Menu keep the same items for the same words, and a `filterMatch`
43
+ * the page writes once means the same thing in each.
44
+ */
45
+ export declare const filterKeeps: (text: string, filter: string, match?: ((text: string, filter: string) => boolean) | undefined) => boolean;
@@ -39,3 +39,4 @@ export const markMatches = (owner, elements, needle) => {
39
39
  registry.set(FILTER_MARK, new Highlight(...all));
40
40
  }
41
41
  };
42
+ export const filterKeeps = (text, filter, match) => filter === '' || (match ? match(text, filter) : text.toLowerCase().includes(filter.toLowerCase()));
package/dist/version.d.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  * release, so the two never disagree; a spec beside this holds them to it.
7
7
  * Nothing else in the running code knows which release it is.
8
8
  */
9
- export declare const VERSION = "0.165.0";
9
+ export declare const VERSION = "0.167.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.165.0';
1
+ export const VERSION = '0.167.0';
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.165.0",
4
+ "version": "0.167.0",
5
5
  "license": "MIT",
6
6
  "author": "Ross Sheppard <ross.sheppard@fusion.dev>",
7
7
  "repository": {
@@ -56,11 +56,11 @@
56
56
  "bugs": "https://github.com/project-fusion/fusion/issues",
57
57
  "dependencies": {
58
58
  "@floating-ui/dom": "^1.8.0",
59
- "@fusion.dev/helix-icons": "0.165.0"
59
+ "@fusion.dev/helix-icons": "0.167.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@fusion.dev/helix-cem": "0.165.0",
63
- "@fusion.dev/helix-testing": "0.165.0",
62
+ "@fusion.dev/helix-cem": "0.167.0",
63
+ "@fusion.dev/helix-testing": "0.167.0",
64
64
  "@lit-labs/ssr": "^4.1.0",
65
65
  "lit": "^3.2.1"
66
66
  },