@silver-formily/element-plus 2.2.0 → 2.3.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.
- package/README.en-US.md +32 -32
- package/README.md +32 -32
- package/esm/__builtins__/index.mjs +19 -23
- package/esm/__builtins__/index.mjs.map +1 -1
- package/esm/__builtins__/shared/index.d.ts +0 -1
- package/esm/__builtins__/shared/index.mjs +17 -21
- package/esm/__builtins__/shared/index.mjs.map +1 -1
- package/esm/__builtins__/shared/loading.mjs +5 -5
- package/esm/__builtins__/shared/loading.mjs.map +1 -1
- package/esm/__builtins__/shared/use-enter-submit.d.ts +9 -0
- package/esm/__builtins__/shared/use-enter-submit.mjs +25 -0
- package/esm/__builtins__/shared/use-enter-submit.mjs.map +1 -0
- package/esm/autocomplete/autocomplete.d.ts +1222 -0
- package/esm/autocomplete/index.d.ts +639 -0
- package/esm/autocomplete/index.mjs +110 -0
- package/esm/autocomplete/index.mjs.map +1 -0
- package/esm/checkbox/index.d.ts +42 -42
- package/esm/color-picker/index.d.ts +210 -0
- package/esm/color-picker/index.mjs +14 -0
- package/esm/color-picker/index.mjs.map +1 -0
- package/esm/color-picker-panel/index.d.ts +129 -0
- package/esm/color-picker-panel/index.mjs +22 -0
- package/esm/color-picker-panel/index.mjs.map +1 -0
- package/esm/date-picker/index.mjs +12 -34
- package/esm/date-picker/index.mjs.map +1 -1
- package/esm/date-picker/utils.d.ts +4 -0
- package/esm/date-picker/utils.mjs +27 -0
- package/esm/date-picker/utils.mjs.map +1 -0
- package/esm/date-picker-panel/index.d.ts +143 -0
- package/esm/date-picker-panel/index.mjs +27 -0
- package/esm/date-picker-panel/index.mjs.map +1 -0
- package/esm/env.d.mjs +2 -0
- package/esm/env.d.mjs.map +1 -0
- package/esm/form-button-group/form-button-group.d.ts +1 -1
- package/esm/form-button-group/index.d.ts +3 -3
- package/esm/form-dialog/dialog-content.d.ts +789 -3
- package/esm/form-dialog/index.mjs +98 -87
- package/esm/form-dialog/index.mjs.map +1 -1
- package/esm/form-dialog/types.d.ts +1 -0
- package/esm/form-drawer/drawer-content.d.ts +919 -3
- package/esm/form-drawer/index.mjs +91 -81
- package/esm/form-drawer/index.mjs.map +1 -1
- package/esm/form-drawer/types.d.ts +1 -0
- package/esm/form-item/index.mjs +17 -17
- package/esm/form-item/index.mjs.map +1 -1
- package/esm/form-layout/form-layout.mjs +10 -10
- package/esm/form-layout/form-layout.mjs.map +1 -1
- package/esm/form-layout/utils.mjs +1 -1
- package/esm/form-layout/utils.mjs.map +1 -1
- package/esm/index.d.ts +6 -0
- package/esm/index.mjs +90 -78
- package/esm/index.mjs.map +1 -1
- package/esm/input-number/index.d.ts +21 -21
- package/esm/input-tag/index.d.ts +32 -0
- package/esm/input-tag/index.mjs +46 -0
- package/esm/input-tag/index.mjs.map +1 -0
- package/esm/input-tag/input-tag.d.ts +32 -0
- package/esm/mention/index.d.ts +50 -0
- package/esm/mention/index.mjs +93 -0
- package/esm/mention/index.mjs.map +1 -0
- package/esm/mention/mention.d.ts +51 -0
- package/esm/pagination/pagination.mjs.map +1 -1
- package/esm/preview-text/color-picker.d.ts +5 -0
- package/esm/preview-text/index.d.ts +5 -0
- package/esm/preview-text/index.mjs +180 -145
- package/esm/preview-text/index.mjs.map +1 -1
- package/esm/radio/index.d.ts +36 -36
- package/esm/rate/index.mjs.map +1 -1
- package/esm/segmented/index.mjs.map +1 -1
- package/esm/shared/overlay-elements.d.ts +6 -0
- package/esm/shared/overlay-elements.mjs +16 -0
- package/esm/shared/overlay-elements.mjs.map +1 -0
- package/esm/slider/index.mjs.map +1 -1
- package/esm/styles/preview-text/index.css +1 -1
- package/esm/switch/index.d.ts +12 -12
- package/esm/upload/index.d.ts +1 -1
- package/esm/upload/upload.d.ts +2 -2
- package/package.json +3 -1
- package/esm/__builtins__/shared/hooks.d.ts +0 -7
- package/esm/__builtins__/shared/hooks.mjs +0 -59
- package/esm/__builtins__/shared/hooks.mjs.map +0 -1
package/README.en-US.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
# Silver Formily Element Plus
|
|
2
|
-
|
|
3
|
-
[](https://codecov.io/gh/hezhengxu2018/silver-formily-element-plus)
|
|
4
|
-
|
|
5
|
-
English | [简体中文](README.md)
|
|
6
|
-
|
|
7
|
-
Formily bindings for Element Plus, focused on consistent UI behavior, flexible configuration, and richer form scenarios.
|
|
8
|
-
|
|
9
|
-
## Documentation
|
|
10
|
-
|
|
11
|
-
https://element-plus.silver-formily.org/
|
|
12
|
-
|
|
13
|
-
## Features
|
|
14
|
-
|
|
15
|
-
- 💡 Unified component style
|
|
16
|
-
- 🔌 Flexible dependencies (Formily + Element Plus as peerDependencies)
|
|
17
|
-
- 🔑 Complete form components plus scenario components
|
|
18
|
-
- ♿️ Better accessibility with enhanced FormItem
|
|
19
|
-
- ✅ Comprehensive testing for new components
|
|
20
|
-
- 📝 Vue template syntax based for readability and performance
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
pnpm add @silver-formily/element-plus
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
This package relies on peer dependencies such as Formily, Element Plus, Vue, and @silver-formily/vue. Refer to the documentation or package.json for compatible versions and setup details.
|
|
29
|
-
|
|
30
|
-
## License
|
|
31
|
-
|
|
32
|
-
MIT
|
|
1
|
+
# Silver Formily Element Plus
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/hezhengxu2018/silver-formily-element-plus)
|
|
4
|
+
|
|
5
|
+
English | [简体中文](README.md)
|
|
6
|
+
|
|
7
|
+
Formily bindings for Element Plus, focused on consistent UI behavior, flexible configuration, and richer form scenarios.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
https://element-plus.silver-formily.org/
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 💡 Unified component style
|
|
16
|
+
- 🔌 Flexible dependencies (Formily + Element Plus as peerDependencies)
|
|
17
|
+
- 🔑 Complete form components plus scenario components
|
|
18
|
+
- ♿️ Better accessibility with enhanced FormItem
|
|
19
|
+
- ✅ Comprehensive testing for new components
|
|
20
|
+
- 📝 Vue template syntax based for readability and performance
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @silver-formily/element-plus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This package relies on peer dependencies such as Formily, Element Plus, Vue, and @silver-formily/vue. Refer to the documentation or package.json for compatible versions and setup details.
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
package/README.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
# Silver Formily Element Plus
|
|
2
|
-
|
|
3
|
-
[](https://codecov.io/gh/hezhengxu2018/silver-formily-element-plus)
|
|
4
|
-
|
|
5
|
-
简体中文 | [English](README.en-US.md)
|
|
6
|
-
|
|
7
|
-
基于 Element Plus 的 Formily 组件库封装,提供一致的组件风格、灵活的配置能力以及更丰富的表单场景。
|
|
8
|
-
|
|
9
|
-
## 文档
|
|
10
|
-
|
|
11
|
-
https://element-plus.silver-formily.org/
|
|
12
|
-
|
|
13
|
-
## 特性
|
|
14
|
-
|
|
15
|
-
- 💡 统一的组件风格
|
|
16
|
-
- 🔌 灵活的依赖策略(Formily 与 Element Plus 作为 peerDependencies)
|
|
17
|
-
- 🔑 完整的表单组件与扩展场景组件
|
|
18
|
-
- ♿️ 更好的无障碍支持与 FormItem 体验
|
|
19
|
-
- ✅ 新组件具备完善测试保障
|
|
20
|
-
- 📝 基于 Vue 模板语法,易读且性能友好
|
|
21
|
-
|
|
22
|
-
## 安装
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
pnpm add @silver-formily/element-plus
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
本包依赖 Formily、Element Plus、Vue、@silver-formily/vue 等 peerDependencies。请查看文档或 package.json 获取兼容版本与配置说明。
|
|
29
|
-
|
|
30
|
-
## 开源协议
|
|
31
|
-
|
|
32
|
-
MIT
|
|
1
|
+
# Silver Formily Element Plus
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/hezhengxu2018/silver-formily-element-plus)
|
|
4
|
+
|
|
5
|
+
简体中文 | [English](README.en-US.md)
|
|
6
|
+
|
|
7
|
+
基于 Element Plus 的 Formily 组件库封装,提供一致的组件风格、灵活的配置能力以及更丰富的表单场景。
|
|
8
|
+
|
|
9
|
+
## 文档
|
|
10
|
+
|
|
11
|
+
https://element-plus.silver-formily.org/
|
|
12
|
+
|
|
13
|
+
## 特性
|
|
14
|
+
|
|
15
|
+
- 💡 统一的组件风格
|
|
16
|
+
- 🔌 灵活的依赖策略(Formily 与 Element Plus 作为 peerDependencies)
|
|
17
|
+
- 🔑 完整的表单组件与扩展场景组件
|
|
18
|
+
- ♿️ 更好的无障碍支持与 FormItem 体验
|
|
19
|
+
- ✅ 新组件具备完善测试保障
|
|
20
|
+
- 📝 基于 Vue 模板语法,易读且性能友好
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @silver-formily/element-plus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
本包依赖 Formily、Element Plus、Vue、@silver-formily/vue 等 peerDependencies。请查看文档或 package.json 获取兼容版本与配置说明。
|
|
29
|
+
|
|
30
|
+
## 开源协议
|
|
31
|
+
|
|
32
|
+
MIT
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { stylePrefix as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { composeExport as y, hasSlotContent as D, isVnodeEmpty as E, isVueOptions as P, useCleanAttrs as V } from "./shared/utils.mjs";
|
|
1
|
+
import { stylePrefix as t } from "./configs/index.mjs";
|
|
2
|
+
import { loadElConfigProvider as i } from "./shared/load-config-provider.mjs";
|
|
3
|
+
import { getTransitionDuration as p, loading as m, useDebonceSubmitting as s } from "./shared/loading.mjs";
|
|
4
|
+
import { lt as f, quickVersionCompare as x } from "./shared/simple-version-compare.mjs";
|
|
5
|
+
import { mapReadPretty as u } from "./shared/transform-component.mjs";
|
|
6
|
+
import { composeExport as g, hasSlotContent as C, isVnodeEmpty as c, isVueOptions as y, useCleanAttrs as E } from "./shared/utils.mjs";
|
|
8
7
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
n as useDebounceFn,
|
|
23
|
-
s as useResizeObserver,
|
|
24
|
-
i as useThrottleFn
|
|
8
|
+
g as composeExport,
|
|
9
|
+
p as getTransitionDuration,
|
|
10
|
+
C as hasSlotContent,
|
|
11
|
+
c as isVnodeEmpty,
|
|
12
|
+
y as isVueOptions,
|
|
13
|
+
i as loadElConfigProvider,
|
|
14
|
+
m as loading,
|
|
15
|
+
f as lt,
|
|
16
|
+
u as mapReadPretty,
|
|
17
|
+
x as quickVersionCompare,
|
|
18
|
+
t as stylePrefix,
|
|
19
|
+
E as useCleanAttrs,
|
|
20
|
+
s as useDebonceSubmitting
|
|
25
21
|
};
|
|
26
22
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { composeExport as g, hasSlotContent as C, isVnodeEmpty as D, isVueOptions as E, useCleanAttrs as V } from "./utils.mjs";
|
|
1
|
+
import { loadElConfigProvider as e } from "./load-config-provider.mjs";
|
|
2
|
+
import { getTransitionDuration as i, loading as n, useDebonceSubmitting as p } from "./loading.mjs";
|
|
3
|
+
import { lt as s, quickVersionCompare as a } from "./simple-version-compare.mjs";
|
|
4
|
+
import { mapReadPretty as l } from "./transform-component.mjs";
|
|
5
|
+
import { composeExport as x, hasSlotContent as d, isVnodeEmpty as g, isVueOptions as C, useCleanAttrs as c } from "./utils.mjs";
|
|
7
6
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
r as useDebounceFn,
|
|
21
|
-
t as useResizeObserver,
|
|
22
|
-
n as useThrottleFn
|
|
7
|
+
x as composeExport,
|
|
8
|
+
i as getTransitionDuration,
|
|
9
|
+
d as hasSlotContent,
|
|
10
|
+
g as isVnodeEmpty,
|
|
11
|
+
C as isVueOptions,
|
|
12
|
+
e as loadElConfigProvider,
|
|
13
|
+
n as loading,
|
|
14
|
+
s as lt,
|
|
15
|
+
l as mapReadPretty,
|
|
16
|
+
a as quickVersionCompare,
|
|
17
|
+
c as useCleanAttrs,
|
|
18
|
+
p as useDebonceSubmitting
|
|
23
19
|
};
|
|
24
20
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { reaction as r } from "@formily/reactive";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useDebounceFn as s } from "@vueuse/core";
|
|
3
|
+
import { ElLoading as a } from "element-plus";
|
|
4
|
+
import { ref as u } from "vue";
|
|
5
5
|
async function p(i = "Loading...", t) {
|
|
6
6
|
let n;
|
|
7
7
|
const e = setTimeout(() => {
|
|
8
|
-
n =
|
|
8
|
+
n = a.service({
|
|
9
9
|
text: i,
|
|
10
10
|
background: "transparent"
|
|
11
11
|
});
|
|
@@ -32,7 +32,7 @@ function c(i = "--el-transition-duration", t = 200) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
function b(i) {
|
|
35
|
-
const t =
|
|
35
|
+
const t = u(!1), n = c(), e = s(() => {
|
|
36
36
|
t.value = !1;
|
|
37
37
|
}, () => n);
|
|
38
38
|
return r(() => i.submitting, (o) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading.mjs","sources":["../../../src/__builtins__/shared/loading.ts"],"sourcesContent":["import type { Form } from '@formily/core'\r\nimport { reaction } from '@formily/reactive'\r\nimport {
|
|
1
|
+
{"version":3,"file":"loading.mjs","sources":["../../../src/__builtins__/shared/loading.ts"],"sourcesContent":["import type { Form } from '@formily/core'\r\nimport { reaction } from '@formily/reactive'\r\nimport { useDebounceFn } from '@vueuse/core'\r\nimport { ElLoading } from 'element-plus'\r\nimport { ref } from 'vue'\r\n\r\nexport async function loading(loadingText = 'Loading...', processor: () => Promise<any>) {\r\n let loadingInstance\r\n const loading = setTimeout(() => {\r\n loadingInstance = ElLoading.service({\r\n text: loadingText,\r\n background: 'transparent',\r\n })\r\n }, 100)\r\n try {\r\n return await processor()\r\n }\r\n finally {\r\n loadingInstance?.close()\r\n clearTimeout(loading)\r\n }\r\n}\r\n\r\n/**\r\n * 获取当前element-plus的过渡时长并转换为毫秒\r\n * @param cssVarName CSS 变量名,默认为 '--el-transition-duration'\r\n * @param defaultValue 默认值(毫秒),默认为 200\r\n * @returns 过渡时长(毫秒)\r\n */\r\nexport function getTransitionDuration(cssVarName = '--el-transition-duration', defaultValue = 200): number {\r\n const cssVar = getComputedStyle(document.documentElement)\r\n .getPropertyValue(cssVarName)\r\n .trim()\r\n if (!cssVar) {\r\n return defaultValue\r\n }\r\n const durationMatch = cssVar.match(/^([\\d.]+)\\s*(s|ms)?$/)\r\n if (!durationMatch) {\r\n return defaultValue\r\n }\r\n\r\n const value = Number.parseFloat(durationMatch[1])\r\n const unit = durationMatch[2] || 'ms'\r\n\r\n switch (unit) {\r\n case 's': {\r\n return value * 1000\r\n }\r\n case 'ms': {\r\n return value\r\n }\r\n }\r\n}\r\n\r\nexport function useDebonceSubmitting(form: Form) {\r\n const internalSubmitting = ref(false)\r\n const transitionDuration = getTransitionDuration()\r\n\r\n const setSubmittingFalse = useDebounceFn(() => {\r\n internalSubmitting.value = false\r\n }, () => transitionDuration)\r\n\r\n reaction(() => form.submitting, (val) => {\r\n if (val === false) {\r\n setSubmittingFalse()\r\n }\r\n else {\r\n internalSubmitting.value = val\r\n }\r\n })\r\n\r\n return {\r\n internalSubmitting,\r\n }\r\n}\r\n"],"names":["loading","loadingText","processor","loadingInstance","ElLoading","getTransitionDuration","cssVarName","defaultValue","cssVar","durationMatch","value","useDebonceSubmitting","form","internalSubmitting","ref","transitionDuration","setSubmittingFalse","useDebounceFn","reaction","val"],"mappings":";;;;AAMA,eAAsBA,EAAQC,IAAc,cAAcC,GAA+B;AACvF,MAAIC;AACJ,QAAMH,IAAU,WAAW,MAAM;AAC/B,IAAAG,IAAkBC,EAAU,QAAQ;AAAA,MAClC,MAAMH;AAAA,MACN,YAAY;AAAA,IAAA,CACb;AAAA,EACH,GAAG,GAAG;AACN,MAAI;AACF,WAAO,MAAMC,EAAA;AAAA,EACf,UAAA;AAEE,IAAAC,GAAiB,MAAA,GACjB,aAAaH,CAAO;AAAA,EACtB;AACF;AAQO,SAASK,EAAsBC,IAAa,4BAA4BC,IAAe,KAAa;AACzG,QAAMC,IAAS,iBAAiB,SAAS,eAAe,EACrD,iBAAiBF,CAAU,EAC3B,KAAA;AACH,MAAI,CAACE;AACH,WAAOD;AAET,QAAME,IAAgBD,EAAO,MAAM,sBAAsB;AACzD,MAAI,CAACC;AACH,WAAOF;AAGT,QAAMG,IAAQ,OAAO,WAAWD,EAAc,CAAC,CAAC;AAGhD,UAFaA,EAAc,CAAC,KAAK,MAEzB;AAAA,IACN,KAAK;AACH,aAAOC,IAAQ;AAAA,IAEjB,KAAK;AACH,aAAOA;AAAA,EACT;AAEJ;AAEO,SAASC,EAAqBC,GAAY;AAC/C,QAAMC,IAAqBC,EAAI,EAAK,GAC9BC,IAAqBV,EAAA,GAErBW,IAAqBC,EAAc,MAAM;AAC7C,IAAAJ,EAAmB,QAAQ;AAAA,EAC7B,GAAG,MAAME,CAAkB;AAE3B,SAAAG,EAAS,MAAMN,EAAK,YAAY,CAACO,MAAQ;AACvC,IAAIA,MAAQ,KACVH,EAAA,IAGAH,EAAmB,QAAQM;AAAA,EAE/B,CAAC,GAEM;AAAA,IACL,oBAAAN;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export interface UseEnterSubmitOptions {
|
|
3
|
+
visible: Ref<boolean>;
|
|
4
|
+
resolve: () => void;
|
|
5
|
+
submitting: Ref<boolean>;
|
|
6
|
+
getContainer: () => HTMLElement | null;
|
|
7
|
+
enabled?: Ref<boolean> | boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useEnterSubmit({ visible, resolve, submitting, getContainer, enabled }: UseEnterSubmitOptions): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEventListener as d } from "@vueuse/core";
|
|
2
|
+
import { computed as g, watch as p, onBeforeUnmount as y } from "vue";
|
|
3
|
+
const a = globalThis.window === void 0 ? void 0 : globalThis;
|
|
4
|
+
function E({ visible: n, resolve: s, submitting: l, getContainer: f, enabled: o = !0 }) {
|
|
5
|
+
let e = null;
|
|
6
|
+
const i = g(() => typeof o == "boolean" ? o : o?.value ?? !0), c = (t) => {
|
|
7
|
+
if (t.isComposing || t.shiftKey || t.altKey || t.ctrlKey || t.metaKey || !n.value || !i.value || l.value || t.defaultPrevented)
|
|
8
|
+
return !0;
|
|
9
|
+
const r = f();
|
|
10
|
+
return !!(!r || !(t.target instanceof Node) || !r.contains(t.target) || t.target?.closest("textarea,[contenteditable=true]"));
|
|
11
|
+
}, m = (t) => {
|
|
12
|
+
t.key !== "Enter" || c(t) || (t.preventDefault(), s());
|
|
13
|
+
}, u = (t) => {
|
|
14
|
+
e && (e(), e = null), t && a && (e = d(a, "keydown", m, {
|
|
15
|
+
passive: !1
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
p([n, i], ([t, r]) => {
|
|
19
|
+
u(t && r);
|
|
20
|
+
}, { immediate: !0 }), y(() => u(!1));
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
E as useEnterSubmit
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=use-enter-submit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-enter-submit.mjs","sources":["../../../src/__builtins__/shared/use-enter-submit.ts"],"sourcesContent":["import type { Ref } from 'vue'\r\nimport { useEventListener } from '@vueuse/core'\r\nimport { computed, onBeforeUnmount, watch } from 'vue'\r\n\r\nexport interface UseEnterSubmitOptions {\r\n visible: Ref<boolean>\r\n resolve: () => void\r\n submitting: Ref<boolean>\r\n getContainer: () => HTMLElement | null\r\n enabled?: Ref<boolean> | boolean\r\n}\r\n\r\nconst runtimeWindow = globalThis.window === undefined ? undefined : globalThis\r\n\r\nexport function useEnterSubmit({ visible, resolve, submitting, getContainer, enabled = true }: UseEnterSubmitOptions) {\r\n let stopListener: (() => void) | null = null\r\n const enabledRef = computed(() => {\r\n if (typeof enabled === 'boolean')\r\n return enabled\r\n\r\n return enabled?.value ?? true\r\n })\r\n\r\n const shouldSkipSubmit = (event: KeyboardEvent) => {\r\n if (\r\n event.isComposing\r\n || event.shiftKey\r\n || event.altKey\r\n || event.ctrlKey\r\n || event.metaKey\r\n || !visible.value\r\n || !enabledRef.value\r\n || submitting.value\r\n || event.defaultPrevented\r\n ) {\r\n return true\r\n }\r\n\r\n const container = getContainer()\r\n if (!container || !(event.target instanceof Node) || !container.contains(event.target))\r\n return true\r\n\r\n const target = event.target as HTMLElement | null\r\n if (target?.closest('textarea,[contenteditable=true]'))\r\n return true\r\n\r\n return false\r\n }\r\n\r\n const handleEnterSubmit = (event: KeyboardEvent) => {\r\n if (event.key !== 'Enter' || shouldSkipSubmit(event))\r\n return\r\n\r\n event.preventDefault()\r\n resolve()\r\n }\r\n\r\n const toggleListener = (shouldListen: boolean) => {\r\n if (stopListener) {\r\n stopListener()\r\n stopListener = null\r\n }\r\n\r\n if (shouldListen && runtimeWindow) {\r\n stopListener = useEventListener(runtimeWindow, 'keydown', handleEnterSubmit, {\r\n passive: false,\r\n })\r\n }\r\n }\r\n\r\n watch([visible, enabledRef], ([visibleValue, enabledValue]) => {\r\n toggleListener(visibleValue && enabledValue)\r\n }, { immediate: true })\r\n\r\n onBeforeUnmount(() => toggleListener(false))\r\n}\r\n"],"names":["runtimeWindow","useEnterSubmit","visible","resolve","submitting","getContainer","enabled","stopListener","enabledRef","computed","shouldSkipSubmit","event","container","handleEnterSubmit","toggleListener","shouldListen","useEventListener","watch","visibleValue","enabledValue","onBeforeUnmount"],"mappings":";;AAYA,MAAMA,IAAgB,WAAW,WAAW,SAAY,SAAY;AAE7D,SAASC,EAAe,EAAE,SAAAC,GAAS,SAAAC,GAAS,YAAAC,GAAY,cAAAC,GAAc,SAAAC,IAAU,MAA+B;AACpH,MAAIC,IAAoC;AACxC,QAAMC,IAAaC,EAAS,MACtB,OAAOH,KAAY,YACdA,IAEFA,GAAS,SAAS,EAC1B,GAEKI,IAAmB,CAACC,MAAyB;AACjD,QACEA,EAAM,eACHA,EAAM,YACNA,EAAM,UACNA,EAAM,WACNA,EAAM,WACN,CAACT,EAAQ,SACT,CAACM,EAAW,SACZJ,EAAW,SACXO,EAAM;AAET,aAAO;AAGT,UAAMC,IAAYP,EAAA;AAKlB,WAJI,IAACO,KAAa,EAAED,EAAM,kBAAkB,SAAS,CAACC,EAAU,SAASD,EAAM,MAAM,KAGtEA,EAAM,QACT,QAAQ,iCAAiC;AAAA,EAIvD,GAEME,IAAoB,CAACF,MAAyB;AAClD,IAAIA,EAAM,QAAQ,WAAWD,EAAiBC,CAAK,MAGnDA,EAAM,eAAA,GACNR,EAAA;AAAA,EACF,GAEMW,IAAiB,CAACC,MAA0B;AAChD,IAAIR,MACFA,EAAA,GACAA,IAAe,OAGbQ,KAAgBf,MAClBO,IAAeS,EAAiBhB,GAAe,WAAWa,GAAmB;AAAA,MAC3E,SAAS;AAAA,IAAA,CACV;AAAA,EAEL;AAEA,EAAAI,EAAM,CAACf,GAASM,CAAU,GAAG,CAAC,CAACU,GAAcC,CAAY,MAAM;AAC7D,IAAAL,EAAeI,KAAgBC,CAAY;AAAA,EAC7C,GAAG,EAAE,WAAW,IAAM,GAEtBC,EAAgB,MAAMN,EAAe,EAAK,CAAC;AAC7C;"}
|