@destyler/tabs 0.1.0 → 0.2.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.
|
@@ -22,8 +22,7 @@ const dom = createScope({
|
|
|
22
22
|
getTriggerEl: (ctx, id) => dom.getById(ctx, dom.getTriggerId(ctx, id)),
|
|
23
23
|
getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
|
|
24
24
|
getElements: (ctx) => {
|
|
25
|
-
const
|
|
26
|
-
const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`;
|
|
25
|
+
const selector = `[role=tab][data-ownedby='${CSS.escape(dom.getListId(ctx))}']:not([disabled])`;
|
|
27
26
|
return queryAll(dom.getListEl(ctx), selector);
|
|
28
27
|
},
|
|
29
28
|
getFirstTriggerEl: (ctx) => first(dom.getElements(ctx)),
|
|
@@ -87,10 +86,9 @@ function connect(state, send, normalize) {
|
|
|
87
86
|
send({ type: "CLEAR_VALUE" });
|
|
88
87
|
},
|
|
89
88
|
setIndicatorRect(value) {
|
|
90
|
-
const id = dom.getTriggerId(state.context, value);
|
|
91
89
|
send({
|
|
92
90
|
type: "SET_INDICATOR_RECT",
|
|
93
|
-
id
|
|
91
|
+
id: dom.getTriggerId(state.context, value)
|
|
94
92
|
});
|
|
95
93
|
},
|
|
96
94
|
syncTabIndex() {
|
|
@@ -144,7 +142,7 @@ function connect(state, send, normalize) {
|
|
|
144
142
|
if (event.defaultPrevented) return;
|
|
145
143
|
if (!isSelfTarget(event)) return;
|
|
146
144
|
if (isComposingEvent(event)) return;
|
|
147
|
-
const
|
|
145
|
+
const exec = {
|
|
148
146
|
ArrowDown() {
|
|
149
147
|
if (isHorizontal) return;
|
|
150
148
|
send({
|
|
@@ -182,9 +180,7 @@ function connect(state, send, normalize) {
|
|
|
182
180
|
Enter() {
|
|
183
181
|
send({ type: "ENTER" });
|
|
184
182
|
}
|
|
185
|
-
};
|
|
186
|
-
const key = getEventKey(event, state.context);
|
|
187
|
-
const exec = keyMap[key];
|
|
183
|
+
}[getEventKey(event, state.context)];
|
|
188
184
|
if (exec) {
|
|
189
185
|
event.preventDefault();
|
|
190
186
|
exec(event);
|
|
@@ -221,8 +217,7 @@ function connect(state, send, normalize) {
|
|
|
221
217
|
});
|
|
222
218
|
},
|
|
223
219
|
onBlur(event) {
|
|
224
|
-
|
|
225
|
-
if (target?.getAttribute("role") !== "tab") send({ type: "TAB_BLUR" });
|
|
220
|
+
if (event.relatedTarget?.getAttribute("role") !== "tab") send({ type: "TAB_BLUR" });
|
|
226
221
|
},
|
|
227
222
|
onClick(event) {
|
|
228
223
|
if (event.defaultPrevented) return;
|
|
@@ -403,8 +398,7 @@ function machine(userContext) {
|
|
|
403
398
|
},
|
|
404
399
|
selectFocusedTab(ctx$1) {
|
|
405
400
|
raf(() => {
|
|
406
|
-
const
|
|
407
|
-
const value = nullable ? null : ctx$1.focusedValue;
|
|
401
|
+
const value = ctx$1.deselectable && ctx$1.value === ctx$1.focusedValue ? null : ctx$1.focusedValue;
|
|
408
402
|
set.value(ctx$1, value);
|
|
409
403
|
});
|
|
410
404
|
},
|
|
@@ -416,8 +410,7 @@ function machine(userContext) {
|
|
|
416
410
|
set.focusedValue(ctx$1, null);
|
|
417
411
|
},
|
|
418
412
|
setValue(ctx$1, evt) {
|
|
419
|
-
const
|
|
420
|
-
const value = nullable ? null : evt.value;
|
|
413
|
+
const value = ctx$1.deselectable && ctx$1.value === ctx$1.focusedValue ? null : evt.value;
|
|
421
414
|
set.value(ctx$1, value);
|
|
422
415
|
},
|
|
423
416
|
clearValue(ctx$1) {
|
|
@@ -456,8 +449,7 @@ function machine(userContext) {
|
|
|
456
449
|
raf(() => {
|
|
457
450
|
const contentEl = dom.getSelectedContentEl(ctx$1);
|
|
458
451
|
if (!contentEl) return;
|
|
459
|
-
|
|
460
|
-
if (focusables.length > 0) contentEl.removeAttribute("tabindex");
|
|
452
|
+
if (getFocusables(contentEl).length > 0) contentEl.removeAttribute("tabindex");
|
|
461
453
|
else contentEl.setAttribute("tabindex", "0");
|
|
462
454
|
});
|
|
463
455
|
},
|
|
@@ -470,8 +462,7 @@ function machine(userContext) {
|
|
|
470
462
|
setIndicatorRect(ctx$1, evt) {
|
|
471
463
|
const value = evt.id ?? ctx$1.value;
|
|
472
464
|
if (!ctx$1.indicatorState.rendered || !value) return;
|
|
473
|
-
|
|
474
|
-
if (!triggerEl) return;
|
|
465
|
+
if (!dom.getTriggerEl(ctx$1, value)) return;
|
|
475
466
|
ctx$1.indicatorState.rect = dom.getRectById(ctx$1, value);
|
|
476
467
|
nextTick(() => {
|
|
477
468
|
ctx$1.indicatorState.transition = false;
|
package/package.json
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/tabs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "A set of layered sections of content—known as tab panels—that are displayed one at a time.",
|
|
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/tabs"
|
|
13
|
+
},
|
|
8
14
|
"exports": {
|
|
9
|
-
".": "./dist/index.
|
|
15
|
+
".": "./dist/index.mjs"
|
|
10
16
|
},
|
|
11
|
-
"main": "dist/index.
|
|
12
|
-
"module": "dist/index.
|
|
13
|
-
"types": "dist/index.d.
|
|
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.
|
|
20
|
-
"@destyler/element-rect": "0.
|
|
21
|
-
"@destyler/dom": "0.
|
|
22
|
-
"@destyler/
|
|
23
|
-
"@destyler/
|
|
24
|
-
"@destyler/
|
|
25
|
+
"@destyler/anatomy": "0.2.0",
|
|
26
|
+
"@destyler/element-rect": "0.2.0",
|
|
27
|
+
"@destyler/dom": "0.2.0",
|
|
28
|
+
"@destyler/types": "0.2.0",
|
|
29
|
+
"@destyler/xstate": "0.2.0",
|
|
30
|
+
"@destyler/utils": "0.2.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
25
34
|
},
|
|
26
35
|
"scripts": {
|
|
27
36
|
"clear": "rimraf ./dist",
|
|
File without changes
|