@destyler/edit 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.
|
@@ -5,7 +5,7 @@ import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
|
5
5
|
import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
6
6
|
|
|
7
7
|
//#region src/anatomy.d.ts
|
|
8
|
-
declare const anatomy: _destyler_anatomy0.AnatomyInstance<"
|
|
8
|
+
declare const anatomy: _destyler_anatomy0.AnatomyInstance<"root" | "area" | "label" | "preview" | "input" | "editTrigger" | "submitTrigger" | "cancelTrigger" | "control">;
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/types.d.ts
|
|
11
11
|
interface ValueChangeDetails {
|
|
@@ -105,8 +105,7 @@ function connect(state, send, normalize) {
|
|
|
105
105
|
"data-invalid": dataAttr(invalid),
|
|
106
106
|
onClick() {
|
|
107
107
|
if (editing) return;
|
|
108
|
-
|
|
109
|
-
previewEl?.focus({ preventScroll: true });
|
|
108
|
+
dom.getPreviewEl(state.context)?.focus({ preventScroll: true });
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
},
|
|
@@ -124,7 +123,7 @@ function connect(state, send, normalize) {
|
|
|
124
123
|
"required": state.context.required,
|
|
125
124
|
"disabled": disabled,
|
|
126
125
|
"data-disabled": dataAttr(disabled),
|
|
127
|
-
"readOnly": readOnly,
|
|
126
|
+
"readOnly": readOnly ? true : void 0,
|
|
128
127
|
"data-readonly": dataAttr(readOnly),
|
|
129
128
|
"aria-invalid": ariaAttr(invalid),
|
|
130
129
|
"data-invalid": dataAttr(invalid),
|
|
@@ -141,7 +140,7 @@ function connect(state, send, normalize) {
|
|
|
141
140
|
onKeyDown(event) {
|
|
142
141
|
if (event.defaultPrevented) return;
|
|
143
142
|
if (isComposingEvent(event)) return;
|
|
144
|
-
const
|
|
143
|
+
const exec = {
|
|
145
144
|
Escape() {
|
|
146
145
|
send("CANCEL");
|
|
147
146
|
event.preventDefault();
|
|
@@ -150,8 +149,7 @@ function connect(state, send, normalize) {
|
|
|
150
149
|
if (!state.context.submitOnEnter) return;
|
|
151
150
|
const { localName } = event$1.currentTarget;
|
|
152
151
|
if (localName === "textarea") {
|
|
153
|
-
|
|
154
|
-
if (!submitMod) return;
|
|
152
|
+
if (!(isApple() ? event$1.metaKey : event$1.ctrlKey)) return;
|
|
155
153
|
send({
|
|
156
154
|
type: "SUBMIT",
|
|
157
155
|
src: "keydown.enter"
|
|
@@ -166,8 +164,7 @@ function connect(state, send, normalize) {
|
|
|
166
164
|
event$1.preventDefault();
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
|
-
};
|
|
170
|
-
const exec = keyMap[event.key];
|
|
167
|
+
}[event.key];
|
|
171
168
|
if (exec) exec(event);
|
|
172
169
|
},
|
|
173
170
|
"style": autoResize ? {
|
|
@@ -183,7 +180,7 @@ function connect(state, send, normalize) {
|
|
|
183
180
|
"dir": state.context.dir,
|
|
184
181
|
"data-placeholder-shown": dataAttr(empty),
|
|
185
182
|
"aria-readonly": ariaAttr(readOnly),
|
|
186
|
-
"data-readonly": dataAttr(
|
|
183
|
+
"data-readonly": dataAttr(readOnly),
|
|
187
184
|
"data-disabled": dataAttr(disabled),
|
|
188
185
|
"aria-disabled": ariaAttr(disabled),
|
|
189
186
|
"aria-invalid": ariaAttr(invalid),
|
|
@@ -420,8 +417,7 @@ function machine(userContext) {
|
|
|
420
417
|
activities: { trackInteractOutside(ctx$1, _evt, { send }) {
|
|
421
418
|
return trackInteractOutside(dom.getInputEl(ctx$1), {
|
|
422
419
|
exclude(target) {
|
|
423
|
-
|
|
424
|
-
return ignore.some((el) => contains(el, target));
|
|
420
|
+
return [dom.getCancelTriggerEl(ctx$1), dom.getSubmitTriggerEl(ctx$1)].some((el) => contains(el, target));
|
|
425
421
|
},
|
|
426
422
|
onFocusOutside: ctx$1.onFocusOutside,
|
|
427
423
|
onPointerDownOutside: ctx$1.onPointerDownOutside,
|
|
@@ -441,8 +437,7 @@ function machine(userContext) {
|
|
|
441
437
|
restoreFocus(ctx$1, evt) {
|
|
442
438
|
if (evt.focusable) return;
|
|
443
439
|
raf(() => {
|
|
444
|
-
|
|
445
|
-
finalEl?.focus({ preventScroll: true });
|
|
440
|
+
(ctx$1.finalFocusEl?.() ?? dom.getEditTriggerEl(ctx$1))?.focus({ preventScroll: true });
|
|
446
441
|
});
|
|
447
442
|
},
|
|
448
443
|
focusInput(ctx$1) {
|
package/package.json
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/edit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "a component that allows users to edit text in place.",
|
|
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/edit"
|
|
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/
|
|
20
|
-
"@destyler/
|
|
21
|
-
"@destyler/
|
|
22
|
-
"@destyler/
|
|
23
|
-
"@destyler/
|
|
24
|
-
"@destyler/xstate": "0.
|
|
25
|
+
"@destyler/dom": "0.2.0",
|
|
26
|
+
"@destyler/types": "0.2.0",
|
|
27
|
+
"@destyler/utils": "0.2.0",
|
|
28
|
+
"@destyler/interact-outside": "0.2.0",
|
|
29
|
+
"@destyler/anatomy": "0.2.0",
|
|
30
|
+
"@destyler/xstate": "0.2.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
25
34
|
},
|
|
26
35
|
"scripts": {
|
|
27
36
|
"clear": "rimraf ./dist",
|