@websolutespa/bom-mixer-ui 1.9.9 → 1.9.10
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/CHANGELOG.md +6 -0
- package/dist/cjs/index.js +203 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/fields/field-checkbox.js +2 -1
- package/dist/esm/fields/field-checkbox.js.map +1 -1
- package/dist/esm/fields/field-combobox.js +34 -0
- package/dist/esm/fields/field-combobox.js.map +1 -1
- package/dist/esm/fields/field-consent.js +209 -0
- package/dist/esm/fields/field-consent.js.map +1 -0
- package/dist/esm/fields/field-implicit.js +80 -0
- package/dist/esm/fields/field-implicit.js.map +1 -0
- package/dist/esm/fields/field-password.js +86 -6
- package/dist/esm/fields/field-password.js.map +1 -1
- package/dist/esm/fields/field-select.js +5 -1
- package/dist/esm/fields/field-select.js.map +1 -1
- package/dist/esm/fields/field-text.js +22 -4
- package/dist/esm/fields/field-text.js.map +1 -1
- package/dist/esm/fields/fields.js +18 -8
- package/dist/esm/fields/fields.js.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/fields/field-checkbox.d.ts.map +1 -1
- package/dist/types/fields/field-combobox.d.ts.map +1 -1
- package/dist/types/fields/field-consent.d.ts +9 -0
- package/dist/types/fields/field-consent.d.ts.map +1 -0
- package/dist/types/fields/field-implicit.d.ts +12 -0
- package/dist/types/fields/field-implicit.d.ts.map +1 -0
- package/dist/types/fields/field-password.d.ts +2 -1
- package/dist/types/fields/field-password.d.ts.map +1 -1
- package/dist/types/fields/field-text.d.ts.map +1 -1
- package/dist/types/fields/fields.d.ts +1 -1
- package/dist/types/fields/fields.d.ts.map +1 -1
- package/dist/types/fields/index.d.ts +3 -0
- package/dist/types/fields/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/fields/field-checkbox.tsx +2 -1
- package/src/fields/field-combobox.tsx +1 -3
- package/src/fields/field-consent.tsx +112 -0
- package/src/fields/field-implicit.tsx +37 -0
- package/src/fields/field-password.tsx +29 -12
- package/src/fields/field-select.tsx +3 -3
- package/src/fields/field-text.tsx +23 -5
- package/src/fields/fields.tsx +24 -8
- package/src/fields/index.ts +4 -0
package/CHANGELOG.md
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -12526,7 +12526,7 @@ function FieldCheckbox(_a) {
|
|
|
12526
12526
|
children: [jsxRuntime.jsxs(Label, {
|
|
12527
12527
|
htmlFor: uniqueName,
|
|
12528
12528
|
margin: "0",
|
|
12529
|
-
children: [jsxRuntime.jsx(Checkbox, {
|
|
12529
|
+
children: [jsxRuntime.jsx(Ariakit.Checkbox, {
|
|
12530
12530
|
id: uniqueName,
|
|
12531
12531
|
name: uniqueName,
|
|
12532
12532
|
onChange: onChange,
|
|
@@ -12608,6 +12608,143 @@ function FieldCombobox(_ref) {
|
|
|
12608
12608
|
});
|
|
12609
12609
|
}
|
|
12610
12610
|
|
|
12611
|
+
function FieldConsent(_ref) {
|
|
12612
|
+
let {
|
|
12613
|
+
control,
|
|
12614
|
+
uid = 0
|
|
12615
|
+
} = _ref;
|
|
12616
|
+
var _a;
|
|
12617
|
+
const label = bomMixerHooks.useLabel();
|
|
12618
|
+
const uniqueName = `${control.name}-${uid}`;
|
|
12619
|
+
const uniqueNameTrue = `${uniqueName}-true`;
|
|
12620
|
+
const uniqueNameFalse = `${uniqueName}-false`;
|
|
12621
|
+
const [state, setValue, setTouched] = bomMixerForms.useControl(control);
|
|
12622
|
+
const onSelect = value => {
|
|
12623
|
+
// console.log('value', value);
|
|
12624
|
+
setValue(value);
|
|
12625
|
+
};
|
|
12626
|
+
const [focus, setFocus] = React.useState(false);
|
|
12627
|
+
const onTrueChange = event => {
|
|
12628
|
+
onSelect(true);
|
|
12629
|
+
};
|
|
12630
|
+
const onTrueBlur = _ => {
|
|
12631
|
+
setTouched();
|
|
12632
|
+
setFocus(false);
|
|
12633
|
+
};
|
|
12634
|
+
const onTrueFocus = _ => {
|
|
12635
|
+
setFocus(true);
|
|
12636
|
+
};
|
|
12637
|
+
const onFalseChange = event => {
|
|
12638
|
+
onSelect(false);
|
|
12639
|
+
};
|
|
12640
|
+
const onFalseBlur = _ => {
|
|
12641
|
+
setTouched();
|
|
12642
|
+
setFocus(false);
|
|
12643
|
+
};
|
|
12644
|
+
const onFalseFocus = _ => {
|
|
12645
|
+
setFocus(true);
|
|
12646
|
+
};
|
|
12647
|
+
const detail = (_a = control.customData) === null || _a === void 0 ? void 0 : _a.detail;
|
|
12648
|
+
const [active, setActive] = React.useState(false);
|
|
12649
|
+
return state.flags.hidden ? jsxRuntime.jsx("input", {
|
|
12650
|
+
type: "hidden",
|
|
12651
|
+
value: state.value ? 'true' : 'false'
|
|
12652
|
+
}) : jsxRuntime.jsxs(Field, {
|
|
12653
|
+
state: state,
|
|
12654
|
+
className: bomCore.getClassNames('field-consent', {
|
|
12655
|
+
required: control.validators.length > 0
|
|
12656
|
+
}),
|
|
12657
|
+
padding: "1em 0",
|
|
12658
|
+
borderBottom: "1px solid var(--color-neutral-200)",
|
|
12659
|
+
children: [jsxRuntime.jsxs("div", {
|
|
12660
|
+
className: "field-consent__description",
|
|
12661
|
+
children: [control.label && jsxRuntime.jsx("span", {
|
|
12662
|
+
dangerouslySetInnerHTML: {
|
|
12663
|
+
__html: label(control.label)
|
|
12664
|
+
}
|
|
12665
|
+
}), detail && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
12666
|
+
children: ["\u00A0", jsxRuntime.jsx(Button, {
|
|
12667
|
+
onClick: () => setActive(!active),
|
|
12668
|
+
children: "Dettagli"
|
|
12669
|
+
}), active && jsxRuntime.jsx("p", {
|
|
12670
|
+
className: "field-consent__detail",
|
|
12671
|
+
dangerouslySetInnerHTML: {
|
|
12672
|
+
__html: detail
|
|
12673
|
+
}
|
|
12674
|
+
})]
|
|
12675
|
+
})]
|
|
12676
|
+
}), jsxRuntime.jsxs("div", {
|
|
12677
|
+
className: "field-consent__group",
|
|
12678
|
+
children: [jsxRuntime.jsxs(Label, {
|
|
12679
|
+
htmlFor: uniqueNameTrue,
|
|
12680
|
+
margin: "0",
|
|
12681
|
+
children: [jsxRuntime.jsx(Checkbox, {
|
|
12682
|
+
id: uniqueNameTrue,
|
|
12683
|
+
name: uniqueNameTrue,
|
|
12684
|
+
onChange: onTrueChange,
|
|
12685
|
+
onBlur: onTrueBlur,
|
|
12686
|
+
onFocus: onTrueFocus,
|
|
12687
|
+
disabled: state.flags.disabled || state.flags.readonly,
|
|
12688
|
+
checked: state.value === true
|
|
12689
|
+
}), jsxRuntime.jsx("span", {
|
|
12690
|
+
children: label('form.consent.true')
|
|
12691
|
+
})]
|
|
12692
|
+
}), jsxRuntime.jsxs(Label, {
|
|
12693
|
+
htmlFor: uniqueNameFalse,
|
|
12694
|
+
margin: "0",
|
|
12695
|
+
children: [jsxRuntime.jsx(Checkbox, {
|
|
12696
|
+
id: uniqueNameFalse,
|
|
12697
|
+
name: uniqueNameFalse,
|
|
12698
|
+
onChange: onFalseChange,
|
|
12699
|
+
onBlur: onFalseBlur,
|
|
12700
|
+
onFocus: onFalseFocus,
|
|
12701
|
+
disabled: state.flags.disabled || state.flags.readonly,
|
|
12702
|
+
checked: state.value === false
|
|
12703
|
+
}), jsxRuntime.jsx("span", {
|
|
12704
|
+
children: label('form.consent.false')
|
|
12705
|
+
})]
|
|
12706
|
+
})]
|
|
12707
|
+
}), jsxRuntime.jsx(FieldError, {
|
|
12708
|
+
state: state
|
|
12709
|
+
})]
|
|
12710
|
+
});
|
|
12711
|
+
}
|
|
12712
|
+
|
|
12713
|
+
function FieldImplicit(_a) {
|
|
12714
|
+
var {
|
|
12715
|
+
control,
|
|
12716
|
+
uid = 0,
|
|
12717
|
+
before,
|
|
12718
|
+
after
|
|
12719
|
+
} = _a;
|
|
12720
|
+
__rest(_a, ["control", "uid", "before", "after"]);
|
|
12721
|
+
const label = bomMixerHooks.useLabel();
|
|
12722
|
+
const uniqueName = `${control.name}-${uid}`;
|
|
12723
|
+
const [state, setValue, setTouched] = bomMixerForms.useControl(control);
|
|
12724
|
+
return state.flags.hidden ? jsxRuntime.jsx("input", {
|
|
12725
|
+
type: "hidden",
|
|
12726
|
+
value: state.value || ''
|
|
12727
|
+
}) : jsxRuntime.jsxs(Field, {
|
|
12728
|
+
state: state,
|
|
12729
|
+
children: [jsxRuntime.jsxs(Label, {
|
|
12730
|
+
htmlFor: uniqueName,
|
|
12731
|
+
children: [jsxRuntime.jsx("input", {
|
|
12732
|
+
className: "checkbox",
|
|
12733
|
+
type: "hidden",
|
|
12734
|
+
id: uniqueName,
|
|
12735
|
+
name: uniqueName,
|
|
12736
|
+
value: String(state.value)
|
|
12737
|
+
}), control.label && jsxRuntime.jsx("span", {
|
|
12738
|
+
dangerouslySetInnerHTML: {
|
|
12739
|
+
__html: label(control.label)
|
|
12740
|
+
}
|
|
12741
|
+
})]
|
|
12742
|
+
}), jsxRuntime.jsx(FieldError, {
|
|
12743
|
+
state: state
|
|
12744
|
+
})]
|
|
12745
|
+
});
|
|
12746
|
+
}
|
|
12747
|
+
|
|
12611
12748
|
function getIcon(type) {
|
|
12612
12749
|
return type === 'password' ? jsxRuntime.jsx(bomMixerIcons.IconEye, {}) : jsxRuntime.jsx(bomMixerIcons.IconEyeOff, {});
|
|
12613
12750
|
}
|
|
@@ -12620,13 +12757,27 @@ function FieldPassword(_ref) {
|
|
|
12620
12757
|
const label = bomMixerHooks.useLabel();
|
|
12621
12758
|
const uniqueName = `${control.name}-${uid}`;
|
|
12622
12759
|
const [state, setValue, setTouched] = bomMixerForms.useControl(control);
|
|
12760
|
+
const [focus, setFocus] = React.useState(false);
|
|
12761
|
+
const ref = React.useRef(null);
|
|
12762
|
+
React.useEffect(() => {
|
|
12763
|
+
const onChange = value => {
|
|
12764
|
+
if (focus) {
|
|
12765
|
+
return;
|
|
12766
|
+
}
|
|
12767
|
+
if (ref.current) {
|
|
12768
|
+
ref.current.value = value;
|
|
12769
|
+
}
|
|
12770
|
+
// console.log('FieldText.onChange', ref.current, value);
|
|
12771
|
+
};
|
|
12772
|
+
// control.on('change', onChange);
|
|
12773
|
+
return () => control.off('change', onChange);
|
|
12774
|
+
}, [control, focus]);
|
|
12775
|
+
const [type, setType] = React.useState('password');
|
|
12623
12776
|
const onChange = event => {
|
|
12624
12777
|
// console.log('FieldPassword', event.target.value);
|
|
12625
12778
|
setValue(event.target.value);
|
|
12626
12779
|
// control.value = event.target.value;
|
|
12627
12780
|
};
|
|
12628
|
-
const [focus, setFocus] = React.useState(false);
|
|
12629
|
-
const [type, setType] = React.useState('password');
|
|
12630
12781
|
const onBlur = _ => {
|
|
12631
12782
|
setTouched();
|
|
12632
12783
|
setFocus(false);
|
|
@@ -12642,21 +12793,25 @@ function FieldPassword(_ref) {
|
|
|
12642
12793
|
value: state.value || ''
|
|
12643
12794
|
}) : jsxRuntime.jsxs(Field, {
|
|
12644
12795
|
state: state,
|
|
12796
|
+
className: bomCore.getClassNames({
|
|
12797
|
+
required: control.required && !control.disabled
|
|
12798
|
+
}),
|
|
12645
12799
|
children: [jsxRuntime.jsx(Label, {
|
|
12646
12800
|
htmlFor: uniqueName,
|
|
12647
12801
|
children: control.label && label(control.label)
|
|
12648
12802
|
}), jsxRuntime.jsx(Input, {
|
|
12803
|
+
width: "100%",
|
|
12804
|
+
ref: ref,
|
|
12649
12805
|
id: uniqueName,
|
|
12650
12806
|
name: uniqueName,
|
|
12651
12807
|
type: type,
|
|
12652
12808
|
placeholder: label(control.placeholder || control.label || ''),
|
|
12653
|
-
|
|
12809
|
+
defaultValue: state.value || '',
|
|
12654
12810
|
onChange: onChange,
|
|
12655
12811
|
onBlur: onBlur,
|
|
12656
12812
|
onFocus: onFocus,
|
|
12657
12813
|
disabled: state.flags.disabled,
|
|
12658
12814
|
readOnly: state.flags.readonly,
|
|
12659
|
-
width: "100%",
|
|
12660
12815
|
after: jsxRuntime.jsx(Button, {
|
|
12661
12816
|
onClick: () => onToggle(),
|
|
12662
12817
|
children: icon(type)
|
|
@@ -12754,6 +12909,9 @@ function FieldSelect(_ref) {
|
|
|
12754
12909
|
value: bomMixerForms.valueToString(state.value)
|
|
12755
12910
|
}) : jsxRuntime.jsxs(Field, {
|
|
12756
12911
|
state: state,
|
|
12912
|
+
className: bomCore.getClassNames({
|
|
12913
|
+
required: control.required && !control.disabled
|
|
12914
|
+
}),
|
|
12757
12915
|
children: [jsxRuntime.jsxs(Select, {
|
|
12758
12916
|
name: uniqueName,
|
|
12759
12917
|
value: control.value,
|
|
@@ -12765,6 +12923,7 @@ function FieldSelect(_ref) {
|
|
|
12765
12923
|
children: [control.label && jsxRuntime.jsx(Select.Label, {
|
|
12766
12924
|
children: label(control.label)
|
|
12767
12925
|
}), jsxRuntime.jsx(Select.Select, {
|
|
12926
|
+
disabled: control.disabled,
|
|
12768
12927
|
children: icon || jsxRuntime.jsx(bomMixerIcons.IconChevronDown, {})
|
|
12769
12928
|
}), jsxRuntime.jsx(Select.Popover, {
|
|
12770
12929
|
gutter: 4,
|
|
@@ -12792,12 +12951,26 @@ function FieldText(_a) {
|
|
|
12792
12951
|
const label = bomMixerHooks.useLabel();
|
|
12793
12952
|
const uniqueName = `${control.name}-${uid}`;
|
|
12794
12953
|
const [state, setValue, setTouched] = bomMixerForms.useControl(control);
|
|
12954
|
+
const [focus, setFocus] = React.useState(false);
|
|
12955
|
+
const ref = React.useRef(null);
|
|
12956
|
+
React.useEffect(() => {
|
|
12957
|
+
const onChange = value => {
|
|
12958
|
+
if (focus) {
|
|
12959
|
+
return;
|
|
12960
|
+
}
|
|
12961
|
+
if (ref.current) {
|
|
12962
|
+
ref.current.value = value;
|
|
12963
|
+
}
|
|
12964
|
+
// console.log('FieldText.onChange', ref.current, value);
|
|
12965
|
+
};
|
|
12966
|
+
// control.on('change', onChange);
|
|
12967
|
+
return () => control.off('change', onChange);
|
|
12968
|
+
}, [control, focus]);
|
|
12795
12969
|
const onChange = event => {
|
|
12796
12970
|
// console.log('FieldText', event.target.value);
|
|
12797
12971
|
setValue(event.target.value);
|
|
12798
12972
|
// control.value = event.target.value;
|
|
12799
12973
|
};
|
|
12800
|
-
const [focus, setFocus] = React.useState(false);
|
|
12801
12974
|
const onBlur = _ => {
|
|
12802
12975
|
setTouched();
|
|
12803
12976
|
setFocus(false);
|
|
@@ -12810,16 +12983,20 @@ function FieldText(_a) {
|
|
|
12810
12983
|
value: state.value || ''
|
|
12811
12984
|
}) : jsxRuntime.jsxs(Field, {
|
|
12812
12985
|
state: state,
|
|
12986
|
+
className: bomCore.getClassNames({
|
|
12987
|
+
required: control.required && !control.disabled
|
|
12988
|
+
}),
|
|
12813
12989
|
children: [jsxRuntime.jsx(Label, {
|
|
12814
12990
|
htmlFor: uniqueName,
|
|
12815
12991
|
children: control.label && label(control.label)
|
|
12816
12992
|
}), jsxRuntime.jsx(Input, Object.assign({
|
|
12817
12993
|
width: "100%"
|
|
12818
12994
|
}, props, {
|
|
12995
|
+
ref: ref,
|
|
12819
12996
|
id: uniqueName,
|
|
12820
12997
|
name: uniqueName,
|
|
12821
12998
|
placeholder: label(control.placeholder || control.label || ''),
|
|
12822
|
-
|
|
12999
|
+
defaultValue: state.value || '',
|
|
12823
13000
|
onChange: onChange,
|
|
12824
13001
|
onBlur: onBlur,
|
|
12825
13002
|
onFocus: onFocus,
|
|
@@ -12883,15 +13060,19 @@ function FieldTextArea(_ref) {
|
|
|
12883
13060
|
* Here we define the types of form fields.
|
|
12884
13061
|
*/
|
|
12885
13062
|
const FIELDS = {
|
|
12886
|
-
|
|
13063
|
+
accept: (control, uid) => jsxRuntime.jsx(FieldAccept, {
|
|
12887
13064
|
control: control,
|
|
12888
13065
|
uid: uid
|
|
12889
13066
|
}, uid),
|
|
12890
|
-
|
|
13067
|
+
autocomplete: (control, uid) => jsxRuntime.jsx(FieldAutocomplete, {
|
|
12891
13068
|
control: control,
|
|
12892
13069
|
uid: uid
|
|
12893
13070
|
}, uid),
|
|
12894
|
-
|
|
13071
|
+
card: (control, uid) => jsxRuntime.jsx(FieldCard, {
|
|
13072
|
+
control: control,
|
|
13073
|
+
uid: uid
|
|
13074
|
+
}, uid),
|
|
13075
|
+
checkbox: (control, uid) => jsxRuntime.jsx(FieldCheckbox, {
|
|
12895
13076
|
control: control,
|
|
12896
13077
|
uid: uid
|
|
12897
13078
|
}, uid),
|
|
@@ -12899,15 +13080,15 @@ const FIELDS = {
|
|
|
12899
13080
|
control: control,
|
|
12900
13081
|
uid: uid
|
|
12901
13082
|
}, uid),
|
|
12902
|
-
|
|
13083
|
+
consent: (control, uid) => jsxRuntime.jsx(FieldConsent, {
|
|
12903
13084
|
control: control,
|
|
12904
13085
|
uid: uid
|
|
12905
13086
|
}, uid),
|
|
12906
|
-
|
|
13087
|
+
implicit: (control, uid) => jsxRuntime.jsx(FieldImplicit, {
|
|
12907
13088
|
control: control,
|
|
12908
13089
|
uid: uid
|
|
12909
13090
|
}, uid),
|
|
12910
|
-
|
|
13091
|
+
password: (control, uid) => jsxRuntime.jsx(FieldPassword, {
|
|
12911
13092
|
control: control,
|
|
12912
13093
|
uid: uid
|
|
12913
13094
|
}, uid),
|
|
@@ -12915,11 +13096,15 @@ const FIELDS = {
|
|
|
12915
13096
|
control: control,
|
|
12916
13097
|
uid: uid
|
|
12917
13098
|
}, uid),
|
|
12918
|
-
|
|
13099
|
+
select: (control, uid) => jsxRuntime.jsx(FieldSelect, {
|
|
12919
13100
|
control: control,
|
|
12920
13101
|
uid: uid
|
|
12921
13102
|
}, uid),
|
|
12922
|
-
|
|
13103
|
+
text: (control, uid) => jsxRuntime.jsx(FieldText, {
|
|
13104
|
+
control: control,
|
|
13105
|
+
uid: uid
|
|
13106
|
+
}, uid),
|
|
13107
|
+
textarea: (control, uid) => jsxRuntime.jsx(FieldTextArea, {
|
|
12923
13108
|
control: control,
|
|
12924
13109
|
uid: uid
|
|
12925
13110
|
}, uid)
|
|
@@ -13744,6 +13929,7 @@ exports.Dropdown = Dropdown;
|
|
|
13744
13929
|
exports.Ellipsis = Ellipsis;
|
|
13745
13930
|
exports.ErrorHandler = ErrorHandler;
|
|
13746
13931
|
exports.Expand = Expand;
|
|
13932
|
+
exports.FIELDS = FIELDS;
|
|
13747
13933
|
exports.Field = Field;
|
|
13748
13934
|
exports.FieldAccept = FieldAccept;
|
|
13749
13935
|
exports.FieldAutocomplete = FieldAutocomplete;
|
|
@@ -13751,7 +13937,9 @@ exports.FieldCard = FieldCard;
|
|
|
13751
13937
|
exports.FieldCheckbox = FieldCheckbox;
|
|
13752
13938
|
exports.FieldCollection = FieldCollection;
|
|
13753
13939
|
exports.FieldCombobox = FieldCombobox;
|
|
13940
|
+
exports.FieldConsent = FieldConsent;
|
|
13754
13941
|
exports.FieldError = FieldError;
|
|
13942
|
+
exports.FieldImplicit = FieldImplicit;
|
|
13755
13943
|
exports.FieldPassword = FieldPassword;
|
|
13756
13944
|
exports.FieldRadio = FieldRadio;
|
|
13757
13945
|
exports.FieldSelect = FieldSelect;
|