@sfxcode/formkit-primevue 2.2.3 → 2.3.1

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.
@@ -1,4 +1,5 @@
1
1
  import { useFormKitInput } from './useFormKitInput';
2
2
  import { useFormKitSchema } from './useFormKitSchema';
3
+ import { useInputEditor } from './useInputEditor';
3
4
  import { useInputEditorSchema } from './useInputEditorSchema';
4
- export { useFormKitInput, useFormKitSchema, useInputEditorSchema, };
5
+ export { useFormKitInput, useFormKitSchema, useInputEditor, useInputEditorSchema, };
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "useFormKitSchema", {
15
15
  return _useFormKitSchema.useFormKitSchema;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "useInputEditor", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _useInputEditor.useInputEditor;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "useInputEditorSchema", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -23,4 +29,5 @@ Object.defineProperty(exports, "useInputEditorSchema", {
23
29
  });
24
30
  var _useFormKitInput = require("./useFormKitInput");
25
31
  var _useFormKitSchema = require("./useFormKitSchema");
32
+ var _useInputEditor = require("./useInputEditor");
26
33
  var _useInputEditorSchema = require("./useInputEditorSchema");
@@ -1,8 +1,10 @@
1
1
  import { useFormKitInput } from "./useFormKitInput.mjs";
2
2
  import { useFormKitSchema } from "./useFormKitSchema.mjs";
3
+ import { useInputEditor } from "./useInputEditor.mjs";
3
4
  import { useInputEditorSchema } from "./useInputEditorSchema.mjs";
4
5
  export {
5
6
  useFormKitInput,
6
7
  useFormKitSchema,
8
+ useInputEditor,
7
9
  useInputEditorSchema
8
10
  };
@@ -0,0 +1,7 @@
1
+ export declare function useInputEditor(): {
2
+ primeInputNames: string[];
3
+ editorDataToSchema: (data: any) => any;
4
+ editorDataToJson: (data: any) => string;
5
+ editorDataToCode: (data: any) => string;
6
+ schemaToEditorData: (schema: any) => any;
7
+ };
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useInputEditor = useInputEditor;
7
+ function useInputEditor() {
8
+ const primeInputWithOptionNames = ["CascadeSelect", "Listbox", "MultiSelect", "RadioButton", "Select", "SelectButton", "TreeSelect"];
9
+ const primeInputNames = [...primeInputWithOptionNames, "AutoComplete", "Checkbox", "ColorPicker", "DatePicker", "Editor", "InputMask", "InputNumber", "InputOtp", "InputText", "Knob", "Password", "Rating", "Slider", "Textarea", "ToggleButton", "ToggleSwitch"].sort();
10
+ function editorDataToSchema(data) {
11
+ const formkitInput = data?._dollar_formkit;
12
+ let tempData = {};
13
+ if (data.prime?.length > 0) {
14
+ const mapped = data.prime?.map(entry => {
15
+ const key = entry.prime_key;
16
+ let value = entry.prime_value;
17
+ if (formkitInput === "primeInputOtp" && key === "length") value = +value;
18
+ return [key, value];
19
+ });
20
+ tempData = Object.assign(...mapped.map(([key, val]) => ({
21
+ [key]: val
22
+ })));
23
+ }
24
+ const readonlyValue = data.readonly ? true : void 0;
25
+ const disabledValue = data.disabled ? true : void 0;
26
+ const preserveValue = data.preserve ? true : void 0;
27
+ const defaultObject = {
28
+ readonly: readonlyValue,
29
+ disabled: disabledValue,
30
+ preserve: preserveValue
31
+ };
32
+ const undefinedObject = {
33
+ prime: void 0,
34
+ schemaResultFormKey: void 0,
35
+ _dollar_formkit: void 0,
36
+ slots: void 0,
37
+ selectButton: void 0
38
+ };
39
+ const useOptions = primeInputWithOptionNames.map(s => `prime${s}`).includes(formkitInput);
40
+ let result = {};
41
+ if (useOptions) result = {
42
+ ...data,
43
+ $formkit: formkitInput,
44
+ ...tempData,
45
+ ...undefinedObject,
46
+ ...defaultObject,
47
+ optionLabel: "label",
48
+ optionValue: "value"
49
+ };else result = {
50
+ ...data,
51
+ $formkit: formkitInput,
52
+ ...tempData,
53
+ ...undefinedObject,
54
+ ...defaultObject,
55
+ options: void 0
56
+ };
57
+ return result;
58
+ }
59
+ function dataToSchema(data) {
60
+ const schema = editorDataToSchema(data);
61
+ if (schema.options) {
62
+ const options = schema.options.map(o => JSON.parse(JSON.stringify(o)));
63
+ return {
64
+ ...schema,
65
+ options
66
+ };
67
+ } else {
68
+ return schema;
69
+ }
70
+ }
71
+ function editorDataToJson(data) {
72
+ return JSON.stringify(dataToSchema(data));
73
+ }
74
+ function objectToString(data) {
75
+ return `{${Object.entries(data).map(([key, value]) => {
76
+ if (key === "options" && value.length > 0) {
77
+ let result = "[";
78
+ value.forEach(o => result = `${result + objectToString(o)}, `);
79
+ return `${key}: ${result.substring(0, result.length - 2)}]`;
80
+ } else if (key === "primeInputOtp") {
81
+ return `${key}: ${value}`;
82
+ } else {
83
+ return `${key}: '${value}'`;
84
+ }
85
+ }).join()}}`;
86
+ }
87
+ function editorDataToObject(data) {
88
+ return objectToString(JSON.parse(editorDataToJson(data)));
89
+ }
90
+ function schemaToEditorData(schema) {
91
+ const formkitInput = schema?.$formkit;
92
+ return {
93
+ ...schema,
94
+ _dollar_formkit: formkitInput
95
+ };
96
+ }
97
+ return {
98
+ primeInputNames,
99
+ editorDataToSchema,
100
+ editorDataToJson,
101
+ editorDataToCode: editorDataToObject,
102
+ schemaToEditorData
103
+ };
104
+ }
@@ -0,0 +1,63 @@
1
+ export function useInputEditor() {
2
+ const primeInputWithOptionNames = ["CascadeSelect", "Listbox", "MultiSelect", "RadioButton", "Select", "SelectButton", "TreeSelect"];
3
+ const primeInputNames = [...primeInputWithOptionNames, "AutoComplete", "Checkbox", "ColorPicker", "DatePicker", "Editor", "InputMask", "InputNumber", "InputOtp", "InputText", "Knob", "Password", "Rating", "Slider", "Textarea", "ToggleButton", "ToggleSwitch"].sort();
4
+ function editorDataToSchema(data) {
5
+ const formkitInput = data?._dollar_formkit;
6
+ let tempData = {};
7
+ if (data.prime?.length > 0) {
8
+ const mapped = data.prime?.map((entry) => {
9
+ const key = entry.prime_key;
10
+ let value = entry.prime_value;
11
+ if (formkitInput === "primeInputOtp" && key === "length")
12
+ value = +value;
13
+ return [key, value];
14
+ });
15
+ tempData = Object.assign(...mapped.map(([key, val]) => ({ [key]: val })));
16
+ }
17
+ const readonlyValue = data.readonly ? true : void 0;
18
+ const disabledValue = data.disabled ? true : void 0;
19
+ const preserveValue = data.preserve ? true : void 0;
20
+ const defaultObject = { readonly: readonlyValue, disabled: disabledValue, preserve: preserveValue };
21
+ const undefinedObject = { prime: void 0, schemaResultFormKey: void 0, _dollar_formkit: void 0, slots: void 0, selectButton: void 0 };
22
+ const useOptions = primeInputWithOptionNames.map((s) => `prime${s}`).includes(formkitInput);
23
+ let result = {};
24
+ if (useOptions)
25
+ result = { ...data, $formkit: formkitInput, ...tempData, ...undefinedObject, ...defaultObject, optionLabel: "label", optionValue: "value" };
26
+ else
27
+ result = { ...data, $formkit: formkitInput, ...tempData, ...undefinedObject, ...defaultObject, options: void 0 };
28
+ return result;
29
+ }
30
+ function dataToSchema(data) {
31
+ const schema = editorDataToSchema(data);
32
+ if (schema.options) {
33
+ const options = schema.options.map((o) => JSON.parse(JSON.stringify(o)));
34
+ return { ...schema, options };
35
+ } else {
36
+ return schema;
37
+ }
38
+ }
39
+ function editorDataToJson(data) {
40
+ return JSON.stringify(dataToSchema(data));
41
+ }
42
+ function objectToString(data) {
43
+ return `{${Object.entries(data).map(([key, value]) => {
44
+ if (key === "options" && value.length > 0) {
45
+ let result = "[";
46
+ value.forEach((o) => result = `${result + objectToString(o)}, `);
47
+ return `${key}: ${result.substring(0, result.length - 2)}]`;
48
+ } else if (key === "primeInputOtp") {
49
+ return `${key}: ${value}`;
50
+ } else {
51
+ return `${key}: '${value}'`;
52
+ }
53
+ }).join()}}`;
54
+ }
55
+ function editorDataToObject(data) {
56
+ return objectToString(JSON.parse(editorDataToJson(data)));
57
+ }
58
+ function schemaToEditorData(schema) {
59
+ const formkitInput = schema?.$formkit;
60
+ return { ...schema, _dollar_formkit: formkitInput };
61
+ }
62
+ return { primeInputNames, editorDataToSchema, editorDataToJson, editorDataToCode: editorDataToObject, schemaToEditorData };
63
+ }
@@ -56,13 +56,8 @@ export declare function useInputEditorSchema(): {
56
56
  id?: undefined;
57
57
  allowEmpty?: undefined;
58
58
  })[];
59
- primeInputNames: string[];
60
59
  primeInputOptions: (list: string[]) => {
61
60
  label: string;
62
61
  value: string;
63
62
  }[];
64
- editorDataToSchema: (data: any) => any;
65
- editorDataToJson: (data: any) => string;
66
- editorDataToCode: (data: any) => string;
67
- schemaToEditorData: (schema: any) => any;
68
63
  };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useInputEditorSchema = useInputEditorSchema;
7
7
  var _useFormKitSchema = require("./useFormKitSchema");
8
+ var _useInputEditor = require("./useInputEditor");
8
9
  function useInputEditorSchema() {
9
10
  const {
10
11
  addElement,
@@ -12,6 +13,9 @@ function useInputEditorSchema() {
12
13
  addListGroup,
13
14
  addComponent
14
15
  } = (0, _useFormKitSchema.useFormKitSchema)();
16
+ const {
17
+ primeInputNames
18
+ } = (0, _useInputEditor.useInputEditor)();
15
19
  function addFlexElement(children) {
16
20
  return addElement("div", children, {
17
21
  style: "max-width: 40rem;display: flex;gap: 1rem;"
@@ -41,8 +45,6 @@ function useInputEditorSchema() {
41
45
  style: "padding-top: 1.5rem;"
42
46
  });
43
47
  }
44
- const primeInputWithOptionNames = ["CascadeSelect", "Listbox", "MultiSelect", "RadioButton", "Select", "SelectButton", "TreeSelect"];
45
- const primeInputNames = [...primeInputWithOptionNames, "AutoComplete", "Checkbox", "ColorPicker", "DatePicker", "Editor", "InputMask", "InputNumber", "InputOtp", "InputText", "Knob", "Password", "Rating", "Slider", "Textarea", "ToggleButton", "ToggleSwitch"].sort();
46
48
  function primeInputOptions(list) {
47
49
  return list.map(name => {
48
50
  return {
@@ -87,66 +89,6 @@ function useInputEditorSchema() {
87
89
  label: "Right",
88
90
  value: "right"
89
91
  }];
90
- function editorDataToSchema(data) {
91
- const formkitInput = data?._dollar_formkit;
92
- let tempData = {};
93
- if (data.prime?.length > 0) {
94
- const mapped = data.prime?.map(entry => {
95
- const key = entry.prime_key;
96
- let value = entry.prime_value;
97
- if (formkitInput === "primeInputOtp" && key === "length") value = +value;
98
- return [key, value];
99
- });
100
- tempData = Object.assign(...mapped.map(([key, val]) => ({
101
- [key]: val
102
- })));
103
- }
104
- const readonlyValue = data.readonly ? true : void 0;
105
- const disabledValue = data.disabled ? true : void 0;
106
- const preserveValue = data.preserve ? true : void 0;
107
- const defaultObject = {
108
- readonly: readonlyValue,
109
- disabled: disabledValue,
110
- preserve: preserveValue
111
- };
112
- const undefinedObject = {
113
- prime: void 0,
114
- schemaResultFormKey: void 0,
115
- _dollar_formkit: void 0,
116
- slots: void 0,
117
- selectButton: void 0
118
- };
119
- const useOptions = primeInputWithOptionNames.map(s => `prime${s}`).includes(formkitInput);
120
- if (useOptions) return {
121
- ...data,
122
- $formkit: formkitInput,
123
- ...tempData,
124
- ...undefinedObject,
125
- ...defaultObject,
126
- optionLabel: "label",
127
- optionValue: "value"
128
- };else return {
129
- ...data,
130
- $formkit: formkitInput,
131
- ...tempData,
132
- ...undefinedObject,
133
- ...defaultObject,
134
- options: void 0
135
- };
136
- }
137
- function editorDataToJson(data) {
138
- return JSON.stringify(editorDataToSchema(data));
139
- }
140
- function editorDataToObject(data) {
141
- return `{${Object.entries(JSON.parse(editorDataToJson(data))).map(([key, value]) => `${key}: '${value}'`).join()}}`;
142
- }
143
- function schemaToEditorData(schema) {
144
- const formkitInput = schema?.$formkit;
145
- return {
146
- ...schema,
147
- _dollar_formkit: formkitInput
148
- };
149
- }
150
92
  function editorSchema(inputOptions = primeInputOptions(primeInputNames)) {
151
93
  return [addGridElement([{
152
94
  $formkit: "primeSelect",
@@ -345,11 +287,6 @@ function useInputEditorSchema() {
345
287
  }
346
288
  return {
347
289
  editorSchema,
348
- primeInputNames,
349
- primeInputOptions,
350
- editorDataToSchema,
351
- editorDataToJson,
352
- editorDataToCode: editorDataToObject,
353
- schemaToEditorData
290
+ primeInputOptions
354
291
  };
355
292
  }
@@ -1,6 +1,8 @@
1
1
  import { useFormKitSchema } from "./useFormKitSchema.mjs";
2
+ import { useInputEditor } from "./useInputEditor.mjs";
2
3
  export function useInputEditorSchema() {
3
4
  const { addElement, addList, addListGroup, addComponent } = useFormKitSchema();
5
+ const { primeInputNames } = useInputEditor();
4
6
  function addFlexElement(children) {
5
7
  return addElement("div", children, { style: "max-width: 40rem;display: flex;gap: 1rem;" });
6
8
  }
@@ -20,8 +22,6 @@ export function useInputEditorSchema() {
20
22
  addElement("span", [], { style: "margin-left: 0.5rem;margin-right: 2.5rem;" }, "$index == $node.value.length -1")
21
23
  ], { style: "padding-top: 1.5rem;" });
22
24
  }
23
- const primeInputWithOptionNames = ["CascadeSelect", "Listbox", "MultiSelect", "RadioButton", "Select", "SelectButton", "TreeSelect"];
24
- const primeInputNames = [...primeInputWithOptionNames, "AutoComplete", "Checkbox", "ColorPicker", "DatePicker", "Editor", "InputMask", "InputNumber", "InputOtp", "InputText", "Knob", "Password", "Rating", "Slider", "Textarea", "ToggleButton", "ToggleSwitch"].sort();
25
25
  function primeInputOptions(list) {
26
26
  return list.map((name) => {
27
27
  return { label: name, value: `prime${name}` };
@@ -44,40 +44,6 @@ export function useInputEditorSchema() {
44
44
  { label: "Left", value: "left" },
45
45
  { label: "Right", value: "right" }
46
46
  ];
47
- function editorDataToSchema(data) {
48
- const formkitInput = data?._dollar_formkit;
49
- let tempData = {};
50
- if (data.prime?.length > 0) {
51
- const mapped = data.prime?.map((entry) => {
52
- const key = entry.prime_key;
53
- let value = entry.prime_value;
54
- if (formkitInput === "primeInputOtp" && key === "length")
55
- value = +value;
56
- return [key, value];
57
- });
58
- tempData = Object.assign(...mapped.map(([key, val]) => ({ [key]: val })));
59
- }
60
- const readonlyValue = data.readonly ? true : void 0;
61
- const disabledValue = data.disabled ? true : void 0;
62
- const preserveValue = data.preserve ? true : void 0;
63
- const defaultObject = { readonly: readonlyValue, disabled: disabledValue, preserve: preserveValue };
64
- const undefinedObject = { prime: void 0, schemaResultFormKey: void 0, _dollar_formkit: void 0, slots: void 0, selectButton: void 0 };
65
- const useOptions = primeInputWithOptionNames.map((s) => `prime${s}`).includes(formkitInput);
66
- if (useOptions)
67
- return { ...data, $formkit: formkitInput, ...tempData, ...undefinedObject, ...defaultObject, optionLabel: "label", optionValue: "value" };
68
- else
69
- return { ...data, $formkit: formkitInput, ...tempData, ...undefinedObject, ...defaultObject, options: void 0 };
70
- }
71
- function editorDataToJson(data) {
72
- return JSON.stringify(editorDataToSchema(data));
73
- }
74
- function editorDataToObject(data) {
75
- return `{${Object.entries(JSON.parse(editorDataToJson(data))).map(([key, value]) => `${key}: '${value}'`).join()}}`;
76
- }
77
- function schemaToEditorData(schema) {
78
- const formkitInput = schema?.$formkit;
79
- return { ...schema, _dollar_formkit: formkitInput };
80
- }
81
47
  function editorSchema(inputOptions = primeInputOptions(primeInputNames)) {
82
48
  return [
83
49
  addGridElement([
@@ -313,5 +279,5 @@ export function useInputEditorSchema() {
313
279
  ], true, "$get(selectButton).value === 'showPrime'", { key: "schema_prime", preserve: true })
314
280
  ];
315
281
  }
316
- return { editorSchema, primeInputNames, primeInputOptions, editorDataToSchema, editorDataToJson, editorDataToCode: editorDataToObject, schemaToEditorData };
282
+ return { editorSchema, primeInputOptions };
317
283
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { useFormKitSchema, useInputEditorSchema } from './composables';
1
+ import { useFormKitSchema, useInputEditor, useInputEditorSchema } from './composables';
2
2
  import { primeInputs } from './definitions';
3
- export { useFormKitSchema, useInputEditorSchema, primeInputs, };
3
+ export { useFormKitSchema, useInputEditor, useInputEditorSchema, primeInputs, };
package/dist/index.js CHANGED
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "useFormKitSchema", {
15
15
  return _composables.useFormKitSchema;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "useInputEditor", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _composables.useInputEditor;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "useInputEditorSchema", {
19
25
  enumerable: true,
20
26
  get: function () {
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { useFormKitSchema, useInputEditorSchema } from "./composables/index.mjs";
1
+ import { useFormKitSchema, useInputEditor, useInputEditorSchema } from "./composables/index.mjs";
2
2
  import { primeInputs } from "./definitions/index.mjs";
3
3
  export {
4
4
  useFormKitSchema,
5
+ useInputEditor,
5
6
  useInputEditorSchema,
6
7
  primeInputs
7
8
  };
@@ -0,0 +1 @@
1
+ export declare function addPrimeAsteriskPlugin(node: any): any;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.addPrimeAsteriskPlugin = addPrimeAsteriskPlugin;
7
+ function addPrimeAsteriskPlugin(node) {
8
+ if (!node.props.type.startsWith("prime")) return;
9
+ node.on("created", () => {
10
+ const schemaFn = node.props.definition.schema;
11
+ node.props.definition.schema = (sectionsSchema = {}) => {
12
+ sectionsSchema.label = {
13
+ children: ["$label", {
14
+ $el: "span",
15
+ if: "$state.required",
16
+ attrs: {
17
+ class: "p-formkit-asterisk"
18
+ },
19
+ children: ["*"]
20
+ }]
21
+ };
22
+ return schemaFn(sectionsSchema);
23
+ };
24
+ });
25
+ }
@@ -0,0 +1,20 @@
1
+ export function addPrimeAsteriskPlugin(node) {
2
+ if (!node.props.type.startsWith("prime"))
3
+ return;
4
+ node.on("created", () => {
5
+ const schemaFn = node.props.definition.schema;
6
+ node.props.definition.schema = (sectionsSchema = {}) => {
7
+ sectionsSchema.label = {
8
+ children: ["$label", {
9
+ $el: "span",
10
+ if: "$state.required",
11
+ attrs: {
12
+ class: "p-formkit-asterisk"
13
+ },
14
+ children: ["*"]
15
+ }]
16
+ };
17
+ return schemaFn(sectionsSchema);
18
+ };
19
+ });
20
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sfxcode/formkit-primevue",
3
3
  "type": "module",
4
- "version": "2.2.3",
4
+ "version": "2.3.1",
5
5
  "packageManager": "pnpm@9.4.0+sha256.b6fd0bfda555e7e584ad7e56b30c68b01d5a04f9ee93989f4b93ca8473c49c74",
6
6
  "author": {
7
7
  "name": "Tom",
@@ -34,6 +34,11 @@
34
34
  "import": "./dist/definitions/index.mjs",
35
35
  "require": "./dist/definitions/index.js"
36
36
  },
37
+ "./plugins": {
38
+ "types": "./dist/plugins/index.d.ts",
39
+ "import": "./dist/plugins/index.mjs",
40
+ "require": "./dist/plugins/index.js"
41
+ },
37
42
  "./dist/sass/formkit-primevue.scss": {
38
43
  "import": "./dist/sass/formkit-primevue.scss",
39
44
  "require": "./dist/sass/formkit-primevue.scss"
@@ -67,7 +72,7 @@
67
72
  "dev": "vite serve dev",
68
73
  "dev:build": "vite build dev",
69
74
  "dev:preview": "vite preview dev",
70
- "release": "npm run lint && npm run build && changelogen --release && npm publish --access public && git push --follow-tags",
75
+ "release": "npm run lint && npm run build && changelogen --patch --release && npm publish --access public && git push --follow-tags",
71
76
  "lint": "eslint ./src",
72
77
  "lint:fix": "eslint . --fix",
73
78
  "prepublishOnly": "pnpm build",