@destyler/combobox 0.1.0 → 0.2.0-beta.5

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.
@@ -7,7 +7,7 @@ import { FocusOutsideEvent, InteractOutsideEvent, InteractOutsideHandlers, Point
7
7
  import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
8
8
 
9
9
  //#region src/anatomy.d.ts
10
- declare const anatomy: _destyler_anatomy0.AnatomyInstance<"root" | "label" | "control" | "input" | "content" | "trigger" | "clearTrigger" | "item" | "positioner" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "list">;
10
+ declare const anatomy: _destyler_anatomy0.AnatomyInstance<"root" | "clearTrigger" | "content" | "control" | "input" | "item" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "label" | "list" | "positioner" | "trigger">;
11
11
  //#endregion
12
12
  //#region src/collection.d.ts
13
13
  declare function collection<T extends CollectionItem$1>(options: CollectionOptions$1<T>): ListCollection<T>;
@@ -211,12 +211,12 @@ function connect(state, send, normalize) {
211
211
  "autoCorrect": "off",
212
212
  "autoCapitalize": "none",
213
213
  "spellCheck": "false",
214
- "readOnly": readOnly,
214
+ ...readOnly ? { readOnly: true } : {},
215
215
  "placeholder": state.context.placeholder,
216
216
  "id": dom.getInputId(state.context),
217
217
  "type": "text",
218
218
  "role": "combobox",
219
- "defaultValue": state.context.inputValue,
219
+ "value": state.context.inputValue,
220
220
  "aria-autocomplete": state.context.autoComplete ? "both" : "list",
221
221
  "aria-controls": dom.getContentId(state.context),
222
222
  "aria-expanded": open,
@@ -249,7 +249,7 @@ function connect(state, send, normalize) {
249
249
  const openOnKeyPress = state.context.openOnKeyPress;
250
250
  const isModifierKey = event.ctrlKey || event.metaKey || event.shiftKey;
251
251
  const keypress = true;
252
- const keymap = {
252
+ const exec = {
253
253
  ArrowDown(event$1) {
254
254
  if (!openOnKeyPress && !open) return;
255
255
  send({
@@ -301,9 +301,7 @@ function connect(state, send, normalize) {
301
301
  });
302
302
  event.preventDefault();
303
303
  }
304
- };
305
- const key = getEventKey(event, state.context);
306
- const exec = keymap[key];
304
+ }[getEventKey(event, state.context)];
307
305
  exec?.(event);
308
306
  }
309
307
  });
@@ -349,7 +347,7 @@ function connect(state, send, normalize) {
349
347
  onKeyDown(event) {
350
348
  if (event.defaultPrevented) return;
351
349
  if (composite) return;
352
- const keyMap = {
350
+ const exec = {
353
351
  ArrowDown() {
354
352
  send({
355
353
  type: "INPUT.ARROW_DOWN",
@@ -362,9 +360,7 @@ function connect(state, send, normalize) {
362
360
  src: "trigger"
363
361
  });
364
362
  }
365
- };
366
- const key = getEventKey(event, state.context);
367
- const exec = keyMap[key];
363
+ }[getEventKey(event, state.context)];
368
364
  if (exec) {
369
365
  exec(event);
370
366
  event.preventDefault();
@@ -449,8 +445,7 @@ function connect(state, send, normalize) {
449
445
  onPointerLeave() {
450
446
  if (props.persistFocus) return;
451
447
  if (itemState.disabled) return;
452
- const mouseMoved = state.previousEvent.type.includes("POINTER");
453
- if (!mouseMoved) return;
448
+ if (!state.previousEvent.type.includes("POINTER")) return;
454
449
  send({
455
450
  type: "ITEM.POINTER_LEAVE",
456
451
  value
@@ -1164,9 +1159,7 @@ function machine(userContext) {
1164
1159
  const inputEl = dom.getInputEl(ctx$1);
1165
1160
  const cleanups = [];
1166
1161
  const exec = (immediate) => {
1167
- const state = getState();
1168
- const pointer = state.event.type.includes("POINTER");
1169
- if (pointer || !ctx$1.highlightedValue) return;
1162
+ if (getState().event.type.includes("POINTER") || !ctx$1.highlightedValue) return;
1170
1163
  const itemEl = dom.getHighlightedItemEl(ctx$1);
1171
1164
  const contentEl = dom.getContentEl(ctx$1);
1172
1165
  if (ctx$1.scrollToIndexFn) {
@@ -1240,8 +1233,7 @@ function machine(userContext) {
1240
1233
  },
1241
1234
  setFinalFocus(ctx$1) {
1242
1235
  raf(() => {
1243
- const triggerEl = dom.getTriggerEl(ctx$1);
1244
- if (triggerEl?.dataset.focusable == null) dom.focusInputEl(ctx$1);
1236
+ if (dom.getTriggerEl(ctx$1)?.dataset.focusable == null) dom.focusInputEl(ctx$1);
1245
1237
  else dom.focusTriggerEl(ctx$1);
1246
1238
  });
1247
1239
  },
package/package.json CHANGED
@@ -1,30 +1,39 @@
1
1
  {
2
2
  "name": "@destyler/combobox",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.0-beta.5",
5
5
  "description": "autocomplete input and command palette with a list of suggestions.",
6
6
  "author": "Elone Hoo <elonehoo@gmail.com>",
7
7
  "license": "MIT",
8
+ "homepage": "https://github.com/destyler/destyler",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/destyler/destyler.git",
12
+ "directory": "packages/components/combobox"
13
+ },
8
14
  "exports": {
9
- ".": "./dist/index.js"
15
+ ".": "./dist/index.mjs"
10
16
  },
11
- "main": "dist/index.js",
12
- "module": "dist/index.js",
13
- "types": "dist/index.d.ts",
17
+ "main": "dist/index.mjs",
18
+ "module": "dist/index.mjs",
19
+ "types": "dist/index.d.mts",
14
20
  "files": [
15
21
  "*.d.ts",
16
22
  "dist"
17
23
  ],
18
24
  "dependencies": {
19
- "@destyler/anatomy": "0.1.0",
20
- "@destyler/aria-hidden": "0.1.0",
21
- "@destyler/dismissable": "0.1.0",
22
- "@destyler/collection": "0.1.0",
23
- "@destyler/dom": "0.1.0",
24
- "@destyler/popper": "0.1.0",
25
- "@destyler/types": "0.1.0",
26
- "@destyler/utils": "0.1.0",
27
- "@destyler/xstate": "0.1.0"
25
+ "@destyler/aria-hidden": "0.2.0-beta.5",
26
+ "@destyler/collection": "0.2.0-beta.5",
27
+ "@destyler/anatomy": "0.2.0-beta.5",
28
+ "@destyler/dismissable": "0.2.0-beta.5",
29
+ "@destyler/dom": "0.2.0-beta.5",
30
+ "@destyler/popper": "0.2.0-beta.5",
31
+ "@destyler/types": "0.2.0-beta.5",
32
+ "@destyler/utils": "0.2.0-beta.5",
33
+ "@destyler/xstate": "0.2.0-beta.5"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
28
37
  },
29
38
  "scripts": {
30
39
  "clear": "rimraf ./dist",