@stonecrop/aform 0.3.4 → 0.3.6
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/dist/aform.d.ts +108 -28
- package/dist/aform.js +423 -419
- package/dist/aform.js.map +1 -1
- package/dist/aform.umd.cjs +2 -2
- package/dist/aform.umd.cjs.map +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/directives/mask.js +33 -0
- package/dist/index.js +0 -4
- package/dist/src/directives/mask.d.ts +7 -0
- package/dist/src/directives/mask.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +144 -28
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/form/ACheckbox.vue +8 -1
- package/src/components/form/ADate.vue +1 -0
- package/src/components/form/ADatePicker.vue +2 -0
- package/src/components/form/AFieldset.vue +2 -0
- package/src/components/form/ANumericInput.vue +8 -1
- package/src/components/form/ATextInput.vue +9 -1
- package/src/directives/mask.ts +34 -1
- package/src/index.ts +2 -6
- package/src/types/index.ts +163 -28
package/dist/assets/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.aform_checkbox[data-v-
|
|
1
|
+
.aform_checkbox[data-v-9f382ad4]{cursor:pointer;width:auto;margin-top:0;display:block}.aform_checkbox[data-v-9f382ad4]:checked{accent-color:var(--sc-primary-color);border:1px solid black}.aform_checkbox-container[data-v-9f382ad4]{width:100%;display:inline-block;text-align:left}.aform_checkbox-container input[data-v-9f382ad4]{width:auto}.aform_checkbox-container:hover+.aform_field-label[data-v-9f382ad4]{color:var(--sc-input-active-label-color)}div[data-v-280b3d1a]{min-width:40ch;width:100%;box-sizing:border-box;border:1px solid transparent;padding:0rem;margin:0rem;margin-right:1ch}input[data-v-280b3d1a]{width:calc(100% - 1ch);box-sizing:border-box;outline:1px solid transparent;border:1px solid var(--sc-input-border-color);padding:1ch .5ch .5ch 1ch;margin:.575rem 0 0;min-height:1.15rem;border-radius:.25rem}p[data-v-280b3d1a],label[data-v-280b3d1a]{color:var(--sc-input-label-color);display:block;min-height:1.15rem;padding:0rem;margin:0rem 0rem .25rem;border:1px solid transparent;box-sizing:border-box}p[data-v-280b3d1a]{width:100%;color:red;font-size:85%;box-sizing:border-box}label[data-v-280b3d1a]{z-index:2;font-size:80%;position:absolute;background:#fff;margin:-2.575rem 0 0 1ch;padding:0 .25ch;box-sizing:border-box}input[data-v-280b3d1a]:focus{border:1px solid var(--sc-input-active-border-color)}input:focus+label[data-v-280b3d1a]{color:var(--sc-input-active-label-color)}.autocomplete[data-v-4e77785f]{position:relative}.input-wrapper[data-v-4e77785f]{min-width:40ch;border:1px solid transparent;padding:0rem;margin:0rem;margin-right:1ch}input[data-v-4e77785f]{width:calc(100% - 1ch);outline:1px solid transparent;border:1px solid var(--sc-input-border-color);padding:1ch .5ch .5ch 1ch;margin:.575rem 0 0;min-height:1.15rem;border-radius:.25rem}input[data-v-4e77785f]:focus{border:1px solid var(--sc-input-active-border-color);border-radius:.25rem .25rem 0 0;border-bottom:none}label[data-v-4e77785f]{display:block;min-height:1.15rem;padding:0rem;margin:0rem 0rem .25rem;border:1px solid transparent;z-index:2;font-size:80%;position:absolute;background:#fff;margin:-2.575rem 0 0 1ch;padding:0 .25ch}.autocomplete-results[data-v-4e77785f]{position:absolute;width:calc(100% - 1ch + 1.5px);z-index:1;padding:0;margin:0;color:#000;border:1px solid var(--sc-input-active-border-color);border-radius:0 0 .25rem .25rem;border-top:none}.autocomplete-result[data-v-4e77785f]{list-style:none;text-align:left;padding:4px 6px;cursor:pointer}.autocomplete-result.is-active[data-v-4e77785f],.autocomplete-result[data-v-4e77785f]:hover{background-color:var(--sc-row-color-zebra-light);color:#000}.adatepicker[data-v-f49cfd40]{font-size:var(--sc-table-font-size);display:inline-table;color:var(--sc-cell-text-color);outline:none;border-collapse:collapse}.adatepicker tr[data-v-f49cfd40]{height:1.15rem;text-align:center;vertical-align:middle}.adatepicker td[data-v-f49cfd40]{border:2px solid transparent;outline:2px solid transparent;min-width:3ch;max-width:3ch}.adatepicker td[data-v-f49cfd40]:focus,.adatepicker td[data-v-f49cfd40]:focus-within{outline:1px dashed black;box-shadow:none;min-height:1.15em;max-height:1.15em;overflow:hidden}.adatepicker .selectedDate[data-v-f49cfd40]{outline:1px solid black;background:var(--sc-gray-20);font-weight:bolder}.adatepicker .todaysDate[data-v-f49cfd40]{font-weight:bolder;text-decoration:underline;color:#000}.days-header>td[data-v-f49cfd40]{font-weight:700}.prev-date[data-v-f49cfd40]{color:var(--sc-gray-20)}.collapse-button[data-v-6f1c1b45]{width:2ch;min-width:calc(66px - 4ch);background-color:transparent;font-size:150%;text-align:center;border:none;margin-top:-.5rem}.rotated[data-v-6f1c1b45]{transform:rotate(45deg);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transition:transform .25s;transform-origin:center center}.unrotated[data-v-6f1c1b45]{transform:rotate(0);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg);transition:transform .25s}.aform_form-element{padding:0;margin:0;position:relative;box-sizing:border-box;flex-grow:1;min-width:20ch;margin-bottom:1rem}.aform_input-field{outline:1px solid var(--sc-input-border-color);outline-offset:-1px;font-size:1rem;padding:.5rem;margin:0;border-radius:0;box-sizing:border-box;width:100%;min-height:auto;position:relative;color:var(--sc-cell-text-color);background:var(--sc-input-field-background)}.aform_input-field:focus{outline:1px solid var(--sc-input-active-border-color)}.aform_input-field:focus+.aform_field-label{color:var(--sc-input-active-label-color)}.aform_field-label{color:var(--sc-input-label-color);display:inline-block;position:absolute;padding:0 .25rem;margin:0rem;z-index:2;font-size:.7rem;font-weight:300;letter-spacing:.05rem;background:linear-gradient(var(--sc-form-background) 50%,var(--sc-input-field-background) 50%);width:auto;box-sizing:border-box;background:#fff;margin:0;grid-row:1;top:0;left:10px;border:none;line-height:0;transform:translateY(-50%)}.aform_input-field:disabled{background:var(--sc-input-field-disabled-background)}.aform_input-field:disabled+.aform_field-label{background:linear-gradient(var(--sc-form-background) 50%,var(--sc-input-field-disabled-background) 50%)}.aform_input-field:disabled~p.aform_error{background:linear-gradient(var(--sc-form-background) 50%,var(--sc-input-field-disabled-background) 50%)}.aform_field-label:after{margin:0;padding:0;box-sizing:border-box;content:"";line-height:normal}p.aform_error{display:block;display:inline-block;display:none;background:linear-gradient(var(--sc-form-background) 50%,var(--sc-input-field-background) 50%);padding:0 .25rem;margin:0rem;width:auto;color:var(--sc-brand-danger);font-size:.7rem;position:absolute;right:0;top:0;line-height:0;background:#fff;padding:.25rem;transform:translate(-1rem,-50%);margin:0}.aform[data-v-68845234]{display:flex;flex-wrap:wrap;gap:1rem;padding:1rem;border:1px solid var(--sc-form-border);border-left:4px solid var(--sc-form-border);margin-bottom:1rem;max-width:100%}@media screen and (max-width: 400px){.aform[data-v-68845234]{flex-direction:column}}fieldset[data-v-e7ea7e12]{max-width:100%;width:100%;margin-right:2ch;border:1px solid transparent;border-bottom:1px solid var(--sc-gray-50)}legend[data-v-e7ea7e12]{width:100%;height:1.15rem;border:1px solid transparent;padding-bottom:.5rem;font-size:110%;font-weight:600;-webkit-user-select:none;user-select:none}.collapse-button[data-v-e7ea7e12]{float:right}.aform_file-attach[data-v-0b3a11cc]{padding:1rem;display:flex;flex-wrap:wrap;gap:1rem;flex-direction:row;justify-content:center;align-items:center;border:1px dashed var(--sc-input-border-color);width:100%}@media screen and (max-width: 400px){.aform_file-attach>.aform_form-btn[data-v-0b3a11cc]{width:100%}}.aform_file-attach-feedback[data-v-0b3a11cc]{color:var(--sc-input-label-color);width:100%;padding:.5rem;text-align:center;align-self:center}.aform_file-attach-feedback>li[data-v-0b3a11cc]{list-style:none;font-style:italic}.aform_file-attach-feedback>p[data-v-0b3a11cc]{margin-top:0}.aform_form-btn[data-v-0b3a11cc]{padding:.5rem 2rem;width:auto;border:1px solid var(--sc-input-border-color);color:var(--sc-input-label-color);cursor:pointer;background-color:#fff}.aform_form-btn[data-v-0b3a11cc]:disabled{background-color:var(--sc-gray-5)}.login-container[data-v-6cbd3add]{width:100%;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;font-family:var(--sc-font-family)}.account-container[data-v-6cbd3add]{width:100%;margin-left:auto;margin-top:.5rem;margin-right:auto;display:flex;flex-direction:column;justify-content:center}.account-header[data-v-6cbd3add]{display:flex;flex-direction:column;text-align:center;margin-top:.5rem}#account-title[data-v-6cbd3add]{font-size:1.5rem;line-height:2rem;font-weight:600;letter-spacing:-.025em;margin:0}#account-subtitle[data-v-6cbd3add]{font-size:.875rem;line-height:1.25rem;margin:1rem}.login-form-container[data-v-6cbd3add]{display:grid;gap:.5rem}.login-form-element[data-v-6cbd3add]{display:grid;margin:.5rem 0;position:relative}.login-field[data-v-6cbd3add]{padding:.5rem .25rem .25rem .5rem;outline:1px solid transparent;border:1px solid var(--sc-input-border-color);border-radius:.25rem}.login-field[data-v-6cbd3add]:focus{border:1px solid black}.btn[data-v-6cbd3add]{background-color:var(--sc-btn-color);color:var(--sc-btn-label-color);border:1px solid var(--sc-btn-border);margin:.5rem 0;padding:.25rem;position:relative;cursor:pointer}.btn[data-v-6cbd3add]:hover{background-color:var(--sc-btn-hover)}.btn[data-v-6cbd3add]:disabled{background-color:var(--sc-input-field-disabled-background)}.disabled[data-v-6cbd3add]{opacity:.5}.loading-icon[data-v-6cbd3add]{animation:spin-6cbd3add 1s linear infinite forwards;display:inline-block;margin-right:.2rem;line-height:0;font-size:1rem;position:relative;top:.2rem}@keyframes spin-6cbd3add{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
package/dist/directives/mask.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named masks for common input types
|
|
3
|
+
*/
|
|
1
4
|
const NAMED_MASKS = {
|
|
2
5
|
date: '##/##/####',
|
|
3
6
|
datetime: '####/##/## ##:##',
|
|
@@ -6,6 +9,11 @@ const NAMED_MASKS = {
|
|
|
6
9
|
phone: '(###) ### - ####',
|
|
7
10
|
card: '#### #### #### ####',
|
|
8
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Extracts a mask function from a stringified function
|
|
14
|
+
* @param mask - Mask string
|
|
15
|
+
* @returns Mask function
|
|
16
|
+
*/
|
|
9
17
|
function extractMaskFn(mask) {
|
|
10
18
|
try {
|
|
11
19
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
@@ -17,6 +25,11 @@ function extractMaskFn(mask) {
|
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Gets the mask for a given directive binding
|
|
30
|
+
* @param binding - Binding object from directive hook
|
|
31
|
+
* @returns Mask string
|
|
32
|
+
*/
|
|
20
33
|
function getMask(binding) {
|
|
21
34
|
let mask = binding.value;
|
|
22
35
|
if (mask) {
|
|
@@ -38,6 +51,12 @@ function getMask(binding) {
|
|
|
38
51
|
}
|
|
39
52
|
return mask;
|
|
40
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Unmasks the input string
|
|
56
|
+
* @param input - Input string
|
|
57
|
+
* @param maskToken - Mask token character
|
|
58
|
+
* @returns Unmasked input string
|
|
59
|
+
*/
|
|
41
60
|
function unmaskInput(input, maskToken) {
|
|
42
61
|
if (!maskToken) {
|
|
43
62
|
maskToken = '#';
|
|
@@ -49,6 +68,13 @@ function unmaskInput(input, maskToken) {
|
|
|
49
68
|
}
|
|
50
69
|
return unmaskedInput;
|
|
51
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Fills the mask with the input string
|
|
73
|
+
* @param input - Input string
|
|
74
|
+
* @param mask - Mask string
|
|
75
|
+
* @param maskToken - Mask token character
|
|
76
|
+
* @returns Masked input string
|
|
77
|
+
*/
|
|
52
78
|
function fillMask(input, mask, maskToken) {
|
|
53
79
|
if (!maskToken) {
|
|
54
80
|
maskToken = '#';
|
|
@@ -64,6 +90,13 @@ function fillMask(input, mask, maskToken) {
|
|
|
64
90
|
}
|
|
65
91
|
return replacement.slice(0, mask.length);
|
|
66
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Applies a mask to an input element
|
|
95
|
+
* @param el - Input element
|
|
96
|
+
* @param binding - Binding object from directive hook
|
|
97
|
+
* @returns void
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
67
100
|
export function useStringMask(el, binding) {
|
|
68
101
|
const mask = getMask(binding);
|
|
69
102
|
if (!mask)
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,6 @@ import AForm from './components/AForm.vue';
|
|
|
9
9
|
import ANumericInput from './components/form/ANumericInput.vue';
|
|
10
10
|
import ATextInput from './components/form/ATextInput.vue';
|
|
11
11
|
import Login from './components/utilities/Login.vue';
|
|
12
|
-
// import { ACurrency } from './components/form/ACurrency.vue'
|
|
13
|
-
// import { AQuantity } from './components/form/AQuantity.vue'
|
|
14
12
|
/**
|
|
15
13
|
* Install all AForm components
|
|
16
14
|
* @param app - Vue app instance
|
|
@@ -27,7 +25,5 @@ function install(app /* options */) {
|
|
|
27
25
|
app.component('AForm', AForm);
|
|
28
26
|
app.component('ANumericInput', ANumericInput);
|
|
29
27
|
app.component('ATextInput', ATextInput);
|
|
30
|
-
// app.component('ACurrency', ACurrency)
|
|
31
|
-
// app.component('AQuantity', AQuantity)
|
|
32
28
|
}
|
|
33
29
|
export { ACheckbox, AComboBox, ADate, ADropdown, ADatePicker, AFieldset, AFileAttach, AForm, ANumericInput, ATextInput, Login, install, };
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { DirectiveBinding } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a mask to an input element
|
|
4
|
+
* @param el - Input element
|
|
5
|
+
* @param binding - Binding object from directive hook
|
|
6
|
+
* @returns void
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
2
9
|
export declare function useStringMask(el: HTMLInputElement, binding: DirectiveBinding<string>): void;
|
|
3
10
|
//# sourceMappingURL=mask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../../src/directives/mask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../../src/directives/mask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AA0G3C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,QAwBpF"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { CellContext, TableConfig, TableColumn, TableRow } from '@stonecrop/atable';
|
|
2
|
-
import { App } from 'vue';
|
|
2
|
+
import type { App } from 'vue';
|
|
3
3
|
import ACheckbox from './components/form/ACheckbox.vue';
|
|
4
4
|
import AComboBox from './components/form/AComboBox.vue';
|
|
5
5
|
import ADate from './components/form/ADate.vue';
|
|
@@ -11,7 +11,7 @@ import AForm from './components/AForm.vue';
|
|
|
11
11
|
import ANumericInput from './components/form/ANumericInput.vue';
|
|
12
12
|
import ATextInput from './components/form/ATextInput.vue';
|
|
13
13
|
import Login from './components/utilities/Login.vue';
|
|
14
|
-
export type {
|
|
14
|
+
export type { BaseSchema, FieldsetSchema, FormSchema, SchemaTypes, TableSchema } from './types';
|
|
15
15
|
/**
|
|
16
16
|
* Install all AForm components
|
|
17
17
|
* @param app - Vue app instance
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACxF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACxF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,KAAK,MAAM,6BAA6B,CAAA;AAC/C,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,WAAW,MAAM,mCAAmC,CAAA;AAC3D,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,WAAW,MAAM,mCAAmC,CAAA;AAC3D,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,aAAa,MAAM,qCAAqC,CAAA;AAC/D,OAAO,UAAU,MAAM,kCAAkC,CAAA;AACzD,OAAO,KAAK,MAAM,kCAAkC,CAAA;AACpD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE/F;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAWxB;AAED,OAAO,EACN,SAAS,EACT,SAAS,EACT,KAAK,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,KAAK,EACL,aAAa,EACb,UAAU,EACV,KAAK,EACL,OAAO,GACP,CAAA"}
|
|
@@ -4,56 +4,172 @@ import type { TableColumn, TableConfig, TableRow } from '@stonecrop/atable';
|
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
6
|
export type ComponentProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The schema object to pass to the component
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
schema?: SchemaTypes;
|
|
12
|
+
/**
|
|
13
|
+
* The label to display in the component
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
7
16
|
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The masking string to apply to inputs inside the component
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
8
21
|
mask?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Indicate whether input is required for text and/or select elements inside the component
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
9
26
|
required?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Indicate whether elements inside the component are read-only
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
10
31
|
readonly?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Set a unique identifier for elements inside the component
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
11
36
|
uuid?: string;
|
|
12
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Validation options for elements inside the component
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
validation?: {
|
|
42
|
+
/**
|
|
43
|
+
* The error message to display when validation fails
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
errorMessage: string;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
};
|
|
13
49
|
};
|
|
14
50
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
51
|
+
* Basic field structure for AForm schemas
|
|
52
|
+
* @public
|
|
17
53
|
*/
|
|
18
|
-
export type
|
|
19
|
-
|
|
54
|
+
export type BaseSchema = {
|
|
55
|
+
/**
|
|
56
|
+
* The fieldname for the schema field
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
20
59
|
fieldname: string;
|
|
21
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The component to render
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* This must be a string that represents the component to render. The registration of the component
|
|
65
|
+
* should be done in the main application.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
component?: string;
|
|
70
|
+
/**
|
|
71
|
+
* A placeholder value for the field
|
|
72
|
+
* @beta
|
|
73
|
+
*/
|
|
74
|
+
value?: any;
|
|
22
75
|
};
|
|
23
76
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
77
|
+
* Schema structure for defining forms inside AForm
|
|
78
|
+
* @public
|
|
26
79
|
*/
|
|
27
|
-
export type FormSchema =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
80
|
+
export type FormSchema = BaseSchema & {
|
|
81
|
+
/**
|
|
82
|
+
* Align the field in the form
|
|
83
|
+
* @beta
|
|
84
|
+
*/
|
|
85
|
+
align?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Indicate whether the field is editable
|
|
88
|
+
* @beta
|
|
89
|
+
*/
|
|
90
|
+
edit?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The field type for the schema field
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* This must be a string that represents the field type. A mask string will be automatically
|
|
96
|
+
* applied for the following field types:
|
|
97
|
+
* - Date ('##/##/####')
|
|
98
|
+
* - Datetime ('####/##/## ##:##')
|
|
99
|
+
* - Time ('##:##')
|
|
100
|
+
* - Fulltime ('##:##:##')
|
|
101
|
+
* - Phone ('(###) ### - ####')
|
|
102
|
+
* - Card ('#### #### #### ####')
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
fieldtype?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The label to display in the form
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
label?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The unique identifier for the field
|
|
114
|
+
* @beta
|
|
115
|
+
*/
|
|
116
|
+
name?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The width of the field element.
|
|
119
|
+
* @beta
|
|
120
|
+
*/
|
|
121
|
+
width?: string;
|
|
122
|
+
/**
|
|
123
|
+
* The mask string for the field
|
|
124
|
+
* @beta
|
|
125
|
+
*/
|
|
34
126
|
mask?: string;
|
|
35
127
|
};
|
|
36
128
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
129
|
+
* Schema structure for defining tables inside AForm
|
|
130
|
+
* @public
|
|
39
131
|
*/
|
|
40
|
-
export type TableSchema =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
132
|
+
export type TableSchema = BaseSchema & {
|
|
133
|
+
/**
|
|
134
|
+
* The columns to display in the table
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
columns?: TableColumn[];
|
|
138
|
+
/**
|
|
139
|
+
* The configuration for the table
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
config?: TableConfig;
|
|
143
|
+
/**
|
|
144
|
+
* The rows to display in the table
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
rows?: TableRow[];
|
|
44
148
|
};
|
|
45
149
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
150
|
+
* Schema structure for defining fieldsets inside AForm
|
|
151
|
+
* @public
|
|
48
152
|
*/
|
|
49
|
-
export type FieldsetSchema =
|
|
50
|
-
|
|
51
|
-
|
|
153
|
+
export type FieldsetSchema = BaseSchema & {
|
|
154
|
+
/**
|
|
155
|
+
* The label to display in the fieldset
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
label?: string;
|
|
159
|
+
/**
|
|
160
|
+
* The schemas to be rendered inside the fieldset
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
schema?: (FormSchema | TableSchema)[];
|
|
164
|
+
/**
|
|
165
|
+
* Indicate whether the fieldset is collapsible
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
52
168
|
collapsible?: boolean;
|
|
53
169
|
};
|
|
54
170
|
/**
|
|
55
|
-
* Superset of schema types
|
|
56
|
-
* @
|
|
171
|
+
* Superset of all schema types for AForm
|
|
172
|
+
* @public
|
|
57
173
|
*/
|
|
58
174
|
export type SchemaTypes = FormSchema | TableSchema | FieldsetSchema;
|
|
59
175
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3E;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3E;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,UAAU,CAAC,EAAE;QACZ;;;WAGG;QACH,YAAY,EAAE,MAAM,CAAA;QAEpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAClB,CAAA;CACD,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,GAAG,CAAA;CACX,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACrC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IAEd;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;IAEvB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IACzC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,UAAU,GAAG,WAAW,CAAC,EAAE,CAAA;IAErC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/aform",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@vueuse/core": "^12.0.0",
|
|
35
35
|
"vue": "^3.5.11",
|
|
36
|
-
"@stonecrop/themes": "0.3.
|
|
37
|
-
"@stonecrop/utilities": "0.3.
|
|
36
|
+
"@stonecrop/themes": "0.3.6",
|
|
37
|
+
"@stonecrop/utilities": "0.3.6"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@microsoft/api-documenter": "^7.26.2",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"vite": "^5.4.5",
|
|
56
56
|
"vitest": "^2.1.1",
|
|
57
57
|
"vue-router": "^4.4.0",
|
|
58
|
-
"@stonecrop/atable": "0.3.
|
|
58
|
+
"@stonecrop/atable": "0.3.6",
|
|
59
59
|
"stonecrop-rig": "0.2.22"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@stonecrop/atable": "0.3.
|
|
62
|
+
"@stonecrop/atable": "0.3.6"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
@@ -19,7 +19,14 @@ import { InputHTMLAttributes } from 'vue'
|
|
|
19
19
|
|
|
20
20
|
import { ComponentProps } from '../../types'
|
|
21
21
|
|
|
22
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
schema, // don't remove to allow masking to work
|
|
24
|
+
label,
|
|
25
|
+
required,
|
|
26
|
+
readonly,
|
|
27
|
+
uuid,
|
|
28
|
+
validation = { errorMessage: ' ' },
|
|
29
|
+
} = defineProps<ComponentProps>()
|
|
23
30
|
const checkbox = defineModel<InputHTMLAttributes['checked']>()
|
|
24
31
|
</script>
|
|
25
32
|
|
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
16
|
import { ComponentProps } from '../../types'
|
|
17
17
|
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
schema, // don't remove to allow masking to work
|
|
20
|
+
label,
|
|
21
|
+
required,
|
|
22
|
+
readonly,
|
|
23
|
+
uuid,
|
|
24
|
+
validation = { errorMessage: ' ' },
|
|
25
|
+
} = defineProps<ComponentProps>()
|
|
19
26
|
const inputNumber = defineModel<number>()
|
|
20
27
|
</script>
|
|
@@ -19,7 +19,15 @@ import { /* inject, */ ref } from 'vue'
|
|
|
19
19
|
import { useStringMask as vMask } from '../../directives/mask'
|
|
20
20
|
import { ComponentProps } from '../../types'
|
|
21
21
|
|
|
22
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
schema, // don't remove to allow masking to work
|
|
24
|
+
label,
|
|
25
|
+
mask,
|
|
26
|
+
required,
|
|
27
|
+
readonly,
|
|
28
|
+
uuid,
|
|
29
|
+
validation = { errorMessage: ' ' },
|
|
30
|
+
} = defineProps<ComponentProps>()
|
|
23
31
|
|
|
24
32
|
// TODO: setup maskFilled as a computed property
|
|
25
33
|
const maskFilled = ref(true)
|
package/src/directives/mask.ts
CHANGED
|
@@ -2,6 +2,9 @@ import type { DirectiveBinding } from 'vue'
|
|
|
2
2
|
|
|
3
3
|
import type { FormSchema } from '../types'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Named masks for common input types
|
|
7
|
+
*/
|
|
5
8
|
const NAMED_MASKS = {
|
|
6
9
|
date: '##/##/####',
|
|
7
10
|
datetime: '####/##/## ##:##',
|
|
@@ -11,6 +14,11 @@ const NAMED_MASKS = {
|
|
|
11
14
|
card: '#### #### #### ####',
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Extracts a mask function from a stringified function
|
|
19
|
+
* @param mask - Mask string
|
|
20
|
+
* @returns Mask function
|
|
21
|
+
*/
|
|
14
22
|
function extractMaskFn(mask: string): ((args: any) => string) | void {
|
|
15
23
|
try {
|
|
16
24
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
@@ -22,6 +30,11 @@ function extractMaskFn(mask: string): ((args: any) => string) | void {
|
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Gets the mask for a given directive binding
|
|
35
|
+
* @param binding - Binding object from directive hook
|
|
36
|
+
* @returns Mask string
|
|
37
|
+
*/
|
|
25
38
|
function getMask(binding: DirectiveBinding<string>) {
|
|
26
39
|
let mask = binding.value
|
|
27
40
|
|
|
@@ -35,7 +48,7 @@ function getMask(binding: DirectiveBinding<string>) {
|
|
|
35
48
|
}
|
|
36
49
|
} else {
|
|
37
50
|
// TODO: (state) handle using state management
|
|
38
|
-
const schema
|
|
51
|
+
const schema = binding.instance['schema'] as FormSchema
|
|
39
52
|
const fieldType: string | undefined = schema?.fieldtype?.toLowerCase()
|
|
40
53
|
if (fieldType && NAMED_MASKS[fieldType]) {
|
|
41
54
|
mask = NAMED_MASKS[fieldType]
|
|
@@ -45,6 +58,12 @@ function getMask(binding: DirectiveBinding<string>) {
|
|
|
45
58
|
return mask
|
|
46
59
|
}
|
|
47
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Unmasks the input string
|
|
63
|
+
* @param input - Input string
|
|
64
|
+
* @param maskToken - Mask token character
|
|
65
|
+
* @returns Unmasked input string
|
|
66
|
+
*/
|
|
48
67
|
function unmaskInput(input: string, maskToken?: string) {
|
|
49
68
|
if (!maskToken) {
|
|
50
69
|
maskToken = '#'
|
|
@@ -60,6 +79,13 @@ function unmaskInput(input: string, maskToken?: string) {
|
|
|
60
79
|
return unmaskedInput
|
|
61
80
|
}
|
|
62
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Fills the mask with the input string
|
|
84
|
+
* @param input - Input string
|
|
85
|
+
* @param mask - Mask string
|
|
86
|
+
* @param maskToken - Mask token character
|
|
87
|
+
* @returns Masked input string
|
|
88
|
+
*/
|
|
63
89
|
function fillMask(input: string, mask: string, maskToken?: string) {
|
|
64
90
|
if (!maskToken) {
|
|
65
91
|
maskToken = '#'
|
|
@@ -78,6 +104,13 @@ function fillMask(input: string, mask: string, maskToken?: string) {
|
|
|
78
104
|
return replacement.slice(0, mask.length)
|
|
79
105
|
}
|
|
80
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Applies a mask to an input element
|
|
109
|
+
* @param el - Input element
|
|
110
|
+
* @param binding - Binding object from directive hook
|
|
111
|
+
* @returns void
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
81
114
|
export function useStringMask(el: HTMLInputElement, binding: DirectiveBinding<string>) {
|
|
82
115
|
const mask = getMask(binding)
|
|
83
116
|
if (!mask) return
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { CellContext, TableConfig, TableColumn, TableRow } from '@stonecrop/atable'
|
|
2
|
-
import { App } from 'vue'
|
|
2
|
+
import type { App } from 'vue'
|
|
3
3
|
|
|
4
4
|
import ACheckbox from './components/form/ACheckbox.vue'
|
|
5
5
|
import AComboBox from './components/form/AComboBox.vue'
|
|
@@ -12,9 +12,7 @@ import AForm from './components/AForm.vue'
|
|
|
12
12
|
import ANumericInput from './components/form/ANumericInput.vue'
|
|
13
13
|
import ATextInput from './components/form/ATextInput.vue'
|
|
14
14
|
import Login from './components/utilities/Login.vue'
|
|
15
|
-
export type {
|
|
16
|
-
// import { ACurrency } from './components/form/ACurrency.vue'
|
|
17
|
-
// import { AQuantity } from './components/form/AQuantity.vue'
|
|
15
|
+
export type { BaseSchema, FieldsetSchema, FormSchema, SchemaTypes, TableSchema } from './types'
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* Install all AForm components
|
|
@@ -32,8 +30,6 @@ function install(app: App /* options */) {
|
|
|
32
30
|
app.component('AForm', AForm)
|
|
33
31
|
app.component('ANumericInput', ANumericInput)
|
|
34
32
|
app.component('ATextInput', ATextInput)
|
|
35
|
-
// app.component('ACurrency', ACurrency)
|
|
36
|
-
// app.component('AQuantity', AQuantity)
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
export {
|