@sfxcode/formkit-openvue 0.0.0-stage → 0.9.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.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +227 -2
  3. package/components.d.ts +1 -0
  4. package/dist/components/FormAutoComplete.vue +100 -0
  5. package/dist/components/FormCascadeSelect.vue +41 -0
  6. package/dist/components/FormCheckbox.vue +49 -0
  7. package/dist/components/FormColorPicker.vue +31 -0
  8. package/dist/components/FormDatePicker.vue +93 -0
  9. package/dist/components/FormInputMask.vue +67 -0
  10. package/dist/components/FormInputNumber.vue +72 -0
  11. package/dist/components/FormInputOtp.vue +40 -0
  12. package/dist/components/FormInputText.vue +63 -0
  13. package/dist/components/FormKitDataDebug.vue +25 -0
  14. package/dist/components/FormKitDataEdit.vue +123 -0
  15. package/dist/components/FormKitDataView.vue +56 -0
  16. package/dist/components/FormKitIcon.vue +23 -0
  17. package/dist/components/FormKitPrefix.vue +9 -0
  18. package/dist/components/FormKitSuffix.vue +9 -0
  19. package/dist/components/FormKnob.vue +48 -0
  20. package/dist/components/FormListbox.vue +482 -0
  21. package/dist/components/FormMultiSelect.vue +68 -0
  22. package/dist/components/FormOutputBoolean.vue +30 -0
  23. package/dist/components/FormOutputDate.vue +40 -0
  24. package/dist/components/FormOutputDuration.vue +24 -0
  25. package/dist/components/FormOutputLink.vue +39 -0
  26. package/dist/components/FormOutputList.vue +105 -0
  27. package/dist/components/FormOutputNumber.vue +47 -0
  28. package/dist/components/FormOutputReference.vue +52 -0
  29. package/dist/components/FormOutputText.vue +52 -0
  30. package/dist/components/FormPassword.vue +47 -0
  31. package/dist/components/FormRadioButton.vue +39 -0
  32. package/dist/components/FormRating.vue +38 -0
  33. package/dist/components/FormSelect.vue +69 -0
  34. package/dist/components/FormSelectButton.vue +42 -0
  35. package/dist/components/FormSlider.vue +40 -0
  36. package/dist/components/FormTextarea.vue +35 -0
  37. package/dist/components/FormToggleButton.vue +40 -0
  38. package/dist/components/FormToggleSwitch.vue +40 -0
  39. package/dist/components/FormTreeSelect.vue +46 -0
  40. package/dist/components/index.d.ts +24 -0
  41. package/dist/components/index.js +167 -0
  42. package/dist/components/index.mjs +48 -0
  43. package/dist/composables/index.d.ts +9 -0
  44. package/dist/composables/index.js +61 -0
  45. package/dist/composables/index.mjs +18 -0
  46. package/dist/composables/useFormInputs.d.ts +3 -0
  47. package/dist/composables/useFormInputs.js +62 -0
  48. package/dist/composables/useFormInputs.mjs +53 -0
  49. package/dist/composables/useFormKitInput.d.ts +11 -0
  50. package/dist/composables/useFormKitInput.js +58 -0
  51. package/dist/composables/useFormKitInput.mjs +45 -0
  52. package/dist/composables/useFormKitRepeater.d.ts +18 -0
  53. package/dist/composables/useFormKitRepeater.js +74 -0
  54. package/dist/composables/useFormKitRepeater.mjs +54 -0
  55. package/dist/composables/useFormKitSchema.d.ts +36 -0
  56. package/dist/composables/useFormKitSchema.js +83 -0
  57. package/dist/composables/useFormKitSchema.mjs +58 -0
  58. package/dist/composables/useFormKitSection.d.ts +7 -0
  59. package/dist/composables/useFormKitSection.js +31 -0
  60. package/dist/composables/useFormKitSection.mjs +19 -0
  61. package/dist/composables/useInputEditor.d.ts +8 -0
  62. package/dist/composables/useInputEditor.js +148 -0
  63. package/dist/composables/useInputEditor.mjs +143 -0
  64. package/dist/composables/useInputEditorSchema.d.ts +163 -0
  65. package/dist/composables/useInputEditorSchema.js +313 -0
  66. package/dist/composables/useInputEditorSchema.mjs +315 -0
  67. package/dist/composables/useOutputDuration.d.ts +4 -0
  68. package/dist/composables/useOutputDuration.js +40 -0
  69. package/dist/composables/useOutputDuration.mjs +35 -0
  70. package/dist/definitions/index.d.ts +35 -0
  71. package/dist/definitions/index.js +44 -0
  72. package/dist/definitions/index.mjs +70 -0
  73. package/dist/definitions/input.d.ts +23 -0
  74. package/dist/definitions/input.js +118 -0
  75. package/dist/definitions/input.mjs +111 -0
  76. package/dist/definitions/output.d.ts +9 -0
  77. package/dist/definitions/output.js +46 -0
  78. package/dist/definitions/output.mjs +136 -0
  79. package/dist/definitions/repeater.d.ts +2 -0
  80. package/dist/definitions/repeater.js +234 -0
  81. package/dist/definitions/repeater.mjs +215 -0
  82. package/dist/index.d.ts +148 -0
  83. package/dist/index.js +62 -0
  84. package/dist/index.mjs +14 -0
  85. package/dist/plugins/autoAnimate.d.ts +9 -0
  86. package/dist/plugins/autoAnimate.js +93 -0
  87. package/dist/plugins/autoAnimate.mjs +87 -0
  88. package/dist/plugins/index.d.ts +5 -0
  89. package/dist/plugins/index.js +67 -0
  90. package/dist/plugins/index.mjs +56 -0
  91. package/dist/sass/formkit-openvue.scss +491 -0
  92. package/dist/style.css +1 -0
  93. package/dist/utils/clonePlain.d.ts +10 -0
  94. package/dist/utils/clonePlain.js +25 -0
  95. package/dist/utils/clonePlain.mjs +24 -0
  96. package/package.json +136 -4
@@ -0,0 +1,9 @@
1
+ import type { AutoAnimateOptions } from '@formkit/auto-animate';
2
+ import type { FormKitNode } from '@formkit/core';
3
+ /** Sections to animate, per input type. `global` applies to every input. */
4
+ export type AutoAnimateTargets = Record<string, string[]>;
5
+ /**
6
+ * Drop-in replacement for `createAutoAnimatePlugin` from `@formkit/addons` with the same
7
+ * arguments, that does not stack animations on an element after inputs are added to it.
8
+ */
9
+ export declare function createAutoAnimatePlugin(options?: Partial<AutoAnimateOptions>, targets?: AutoAnimateTargets): (node: FormKitNode) => void;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createAutoAnimatePlugin = createAutoAnimatePlugin;
7
+ var _autoAnimate = _interopRequireDefault(require("@formkit/auto-animate"));
8
+ var _core = require("@formkit/core");
9
+ var _inputs = require("@formkit/inputs");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const DEFAULT_KEY = "true";
12
+ const optionsByKey = /* @__PURE__ */new Map();
13
+ const attached = /* @__PURE__ */new WeakSet();
14
+ const pendingIds = /* @__PURE__ */new Set();
15
+ let observer = null;
16
+ let attachTimer;
17
+ function attachNewTargets() {
18
+ if (typeof document === "undefined") return;
19
+ document.querySelectorAll("[data-auto-animate]").forEach(target => {
20
+ if (attached.has(target)) return;
21
+ attached.add(target);
22
+ (0, _autoAnimate.default)(target, optionsByKey.get(target.getAttribute("data-auto-animate") ?? "") ?? {});
23
+ });
24
+ }
25
+ function checkPendingIds() {
26
+ if (typeof document === "undefined") return;
27
+ pendingIds.forEach(id => {
28
+ if (!document.getElementById(id)) return;
29
+ pendingIds.delete(id);
30
+ clearTimeout(attachTimer);
31
+ attachTimer = setTimeout(attachNewTargets, 250);
32
+ });
33
+ }
34
+ function observeUntilRendered() {
35
+ if (observer || typeof document === "undefined") return;
36
+ checkPendingIds();
37
+ if (!pendingIds.size) return;
38
+ observer = new MutationObserver(() => {
39
+ checkPendingIds();
40
+ if (!pendingIds.size) {
41
+ observer?.disconnect();
42
+ observer = null;
43
+ }
44
+ });
45
+ observer.observe(document, {
46
+ childList: true,
47
+ subtree: true
48
+ });
49
+ }
50
+ function createAutoAnimatePlugin(options = {}, targets = {}) {
51
+ optionsByKey.set(DEFAULT_KEY, options);
52
+ return node => {
53
+ node.on("created", () => {
54
+ if (typeof node.props.definition?.schema !== "function") return;
55
+ const typeTargets = targets[node.props.type] ?? [];
56
+ const originalSchema = node.props.definition.schema;
57
+ node.props.definition.schema = extensions => {
58
+ const schema = originalSchema(extensions);
59
+ const finalSchema = Array.isArray(schema) ? schema[0] : schema;
60
+ let marked = false;
61
+ (0, _inputs.eachSection)(finalSchema, section => {
62
+ if (!(0, _core.isDOM)(section)) return;
63
+ let key;
64
+ const meta = section.meta;
65
+ if (meta?.autoAnimate) {
66
+ key = DEFAULT_KEY;
67
+ if (typeof meta.autoAnimate === "object") {
68
+ key = `${node.props.id}-${meta.section ?? "section"}`;
69
+ optionsByKey.set(key, {
70
+ ...options,
71
+ ...meta.autoAnimate
72
+ });
73
+ }
74
+ } else {
75
+ const sectionName = meta?.section;
76
+ if (typeof sectionName === "string" && (targets.global?.includes(sectionName) || typeTargets.includes(sectionName))) key = DEFAULT_KEY;
77
+ }
78
+ if (key === void 0) return;
79
+ section.attrs = {
80
+ ...section.attrs,
81
+ "data-auto-animate": key
82
+ };
83
+ marked = true;
84
+ });
85
+ if (marked && node.props.id && typeof window !== "undefined") {
86
+ pendingIds.add(node.props.id);
87
+ observeUntilRendered();
88
+ }
89
+ return finalSchema;
90
+ };
91
+ });
92
+ };
93
+ }
@@ -0,0 +1,87 @@
1
+ import autoAnimate from "@formkit/auto-animate";
2
+ import { isDOM } from "@formkit/core";
3
+ import { eachSection } from "@formkit/inputs";
4
+ const DEFAULT_KEY = "true";
5
+ const optionsByKey = /* @__PURE__ */ new Map();
6
+ const attached = /* @__PURE__ */ new WeakSet();
7
+ const pendingIds = /* @__PURE__ */ new Set();
8
+ let observer = null;
9
+ let attachTimer;
10
+ function attachNewTargets() {
11
+ if (typeof document === "undefined")
12
+ return;
13
+ document.querySelectorAll("[data-auto-animate]").forEach((target) => {
14
+ if (attached.has(target))
15
+ return;
16
+ attached.add(target);
17
+ autoAnimate(target, optionsByKey.get(target.getAttribute("data-auto-animate") ?? "") ?? {});
18
+ });
19
+ }
20
+ function checkPendingIds() {
21
+ if (typeof document === "undefined")
22
+ return;
23
+ pendingIds.forEach((id) => {
24
+ if (!document.getElementById(id))
25
+ return;
26
+ pendingIds.delete(id);
27
+ clearTimeout(attachTimer);
28
+ attachTimer = setTimeout(attachNewTargets, 250);
29
+ });
30
+ }
31
+ function observeUntilRendered() {
32
+ if (observer || typeof document === "undefined")
33
+ return;
34
+ checkPendingIds();
35
+ if (!pendingIds.size)
36
+ return;
37
+ observer = new MutationObserver(() => {
38
+ checkPendingIds();
39
+ if (!pendingIds.size) {
40
+ observer?.disconnect();
41
+ observer = null;
42
+ }
43
+ });
44
+ observer.observe(document, { childList: true, subtree: true });
45
+ }
46
+ export function createAutoAnimatePlugin(options = {}, targets = {}) {
47
+ optionsByKey.set(DEFAULT_KEY, options);
48
+ return (node) => {
49
+ node.on("created", () => {
50
+ if (typeof node.props.definition?.schema !== "function")
51
+ return;
52
+ const typeTargets = targets[node.props.type] ?? [];
53
+ const originalSchema = node.props.definition.schema;
54
+ node.props.definition.schema = (extensions) => {
55
+ const schema = originalSchema(extensions);
56
+ const finalSchema = Array.isArray(schema) ? schema[0] : schema;
57
+ let marked = false;
58
+ eachSection(finalSchema, (section) => {
59
+ if (!isDOM(section))
60
+ return;
61
+ let key;
62
+ const meta = section.meta;
63
+ if (meta?.autoAnimate) {
64
+ key = DEFAULT_KEY;
65
+ if (typeof meta.autoAnimate === "object") {
66
+ key = `${node.props.id}-${meta.section ?? "section"}`;
67
+ optionsByKey.set(key, { ...options, ...meta.autoAnimate });
68
+ }
69
+ } else {
70
+ const sectionName = meta?.section;
71
+ if (typeof sectionName === "string" && (targets.global?.includes(sectionName) || typeTargets.includes(sectionName)))
72
+ key = DEFAULT_KEY;
73
+ }
74
+ if (key === void 0)
75
+ return;
76
+ section.attrs = { ...section.attrs, "data-auto-animate": key };
77
+ marked = true;
78
+ });
79
+ if (marked && node.props.id && typeof window !== "undefined") {
80
+ pendingIds.add(node.props.id);
81
+ observeUntilRendered();
82
+ }
83
+ return finalSchema;
84
+ };
85
+ });
86
+ };
87
+ }
@@ -0,0 +1,5 @@
1
+ import type { FormKitNode } from '@formkit/core';
2
+ export declare function addFormAsteriskPlugin(node: FormKitNode): void;
3
+ export declare function addLabelPlugin(node: FormKitNode): void;
4
+ export { createAutoAnimatePlugin } from './autoAnimate';
5
+ export type { AutoAnimateTargets } from './autoAnimate';
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addFormAsteriskPlugin = addFormAsteriskPlugin;
7
+ exports.addLabelPlugin = addLabelPlugin;
8
+ Object.defineProperty(exports, "createAutoAnimatePlugin", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _autoAnimate.createAutoAnimatePlugin;
12
+ }
13
+ });
14
+ var _autoAnimate = require("./autoAnimate");
15
+ function addFormAsteriskPlugin(node) {
16
+ if (!/^form[A-Z]/.test(node.props.type) || node.props.type.startsWith("formOutput")) return;
17
+ node.on("created", () => {
18
+ if (node.props.definition?.schema) {
19
+ const schemaFn = node.props.definition?.schema;
20
+ node.props.definition.schema = (sectionsSchema = {}) => {
21
+ sectionsSchema.label = {
22
+ children: ["$label", {
23
+ $el: "span",
24
+ if: "$state.required",
25
+ attrs: {
26
+ class: "p-formkit-asterisk"
27
+ },
28
+ children: ["*"]
29
+ }]
30
+ };
31
+ return schemaFn(sectionsSchema);
32
+ };
33
+ }
34
+ });
35
+ }
36
+ function addLabelPlugin(node) {
37
+ if (!/^form[A-Z]/.test(node.props.type)) return;
38
+ node.on("created", () => {
39
+ if (node.props.definition?.schema) {
40
+ const schemaFn = node.props.definition?.schema;
41
+ node.props.definition.schema = (sectionsSchema = {}) => {
42
+ sectionsSchema.label = {
43
+ children: [{
44
+ $el: "span",
45
+ attrs: {
46
+ title: "$help",
47
+ class: "p-formkit-label"
48
+ },
49
+ children: ["$label"]
50
+ }, {
51
+ $el: "span",
52
+ if: "$state.required",
53
+ attrs: {
54
+ class: "p-formkit-required",
55
+ title: "$help"
56
+ },
57
+ children: ["*"]
58
+ }]
59
+ };
60
+ sectionsSchema.help = {
61
+ children: []
62
+ };
63
+ return schemaFn(sectionsSchema);
64
+ };
65
+ }
66
+ });
67
+ }
@@ -0,0 +1,56 @@
1
+ export function addFormAsteriskPlugin(node) {
2
+ if (!/^form[A-Z]/.test(node.props.type) || node.props.type.startsWith("formOutput"))
3
+ return;
4
+ node.on("created", () => {
5
+ if (node.props.definition?.schema) {
6
+ const schemaFn = node.props.definition?.schema;
7
+ node.props.definition.schema = (sectionsSchema = {}) => {
8
+ sectionsSchema.label = {
9
+ children: ["$label", {
10
+ $el: "span",
11
+ if: "$state.required",
12
+ attrs: {
13
+ class: "p-formkit-asterisk"
14
+ },
15
+ children: ["*"]
16
+ }]
17
+ };
18
+ return schemaFn(sectionsSchema);
19
+ };
20
+ }
21
+ });
22
+ }
23
+ export function addLabelPlugin(node) {
24
+ if (!/^form[A-Z]/.test(node.props.type))
25
+ return;
26
+ node.on("created", () => {
27
+ if (node.props.definition?.schema) {
28
+ const schemaFn = node.props.definition?.schema;
29
+ node.props.definition.schema = (sectionsSchema = {}) => {
30
+ sectionsSchema.label = {
31
+ children: [{
32
+ $el: "span",
33
+ attrs: {
34
+ title: "$help",
35
+ class: "p-formkit-label"
36
+ },
37
+ children: ["$label"]
38
+ }, {
39
+ $el: "span",
40
+ if: "$state.required",
41
+ attrs: {
42
+ class: "p-formkit-required",
43
+ title: "$help"
44
+ },
45
+ children: ["*"]
46
+ }]
47
+ };
48
+ sectionsSchema.help = {
49
+ children: []
50
+ };
51
+ return schemaFn(sectionsSchema);
52
+ };
53
+ }
54
+ });
55
+ }
56
+ export { createAutoAnimatePlugin } from "./autoAnimate.mjs";