@websolutespa/bom-mixer-ui 1.9.8 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.js +209 -17
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/esm/components/text/text.js +6 -2
  5. package/dist/esm/components/text/text.js.map +1 -1
  6. package/dist/esm/fields/field-checkbox.js +2 -1
  7. package/dist/esm/fields/field-checkbox.js.map +1 -1
  8. package/dist/esm/fields/field-combobox.js +34 -0
  9. package/dist/esm/fields/field-combobox.js.map +1 -1
  10. package/dist/esm/fields/field-consent.js +209 -0
  11. package/dist/esm/fields/field-consent.js.map +1 -0
  12. package/dist/esm/fields/field-implicit.js +80 -0
  13. package/dist/esm/fields/field-implicit.js.map +1 -0
  14. package/dist/esm/fields/field-password.js +86 -6
  15. package/dist/esm/fields/field-password.js.map +1 -1
  16. package/dist/esm/fields/field-select.js +5 -1
  17. package/dist/esm/fields/field-select.js.map +1 -1
  18. package/dist/esm/fields/field-text.js +22 -4
  19. package/dist/esm/fields/field-text.js.map +1 -1
  20. package/dist/esm/fields/fields.js +18 -8
  21. package/dist/esm/fields/fields.js.map +1 -1
  22. package/dist/esm/index.js +3 -0
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/types/components/text/text.d.ts.map +1 -1
  25. package/dist/types/fields/field-checkbox.d.ts.map +1 -1
  26. package/dist/types/fields/field-combobox.d.ts.map +1 -1
  27. package/dist/types/fields/field-consent.d.ts +9 -0
  28. package/dist/types/fields/field-consent.d.ts.map +1 -0
  29. package/dist/types/fields/field-implicit.d.ts +12 -0
  30. package/dist/types/fields/field-implicit.d.ts.map +1 -0
  31. package/dist/types/fields/field-password.d.ts +2 -1
  32. package/dist/types/fields/field-password.d.ts.map +1 -1
  33. package/dist/types/fields/field-text.d.ts.map +1 -1
  34. package/dist/types/fields/fields.d.ts +1 -1
  35. package/dist/types/fields/fields.d.ts.map +1 -1
  36. package/dist/types/fields/index.d.ts +3 -0
  37. package/dist/types/fields/index.d.ts.map +1 -1
  38. package/dist/types/theme/types.d.ts +5 -6
  39. package/dist/types/theme/types.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/components/text/text.tsx +6 -2
  42. package/src/fields/field-checkbox.tsx +2 -1
  43. package/src/fields/field-combobox.tsx +1 -3
  44. package/src/fields/field-consent.tsx +112 -0
  45. package/src/fields/field-implicit.tsx +37 -0
  46. package/src/fields/field-password.tsx +29 -12
  47. package/src/fields/field-select.tsx +3 -3
  48. package/src/fields/field-text.tsx +23 -5
  49. package/src/fields/fields.tsx +24 -8
  50. package/src/fields/index.ts +4 -0
  51. package/src/theme/types.ts +5 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @websolutespa/bom-mixer-ui
2
2
 
3
+ ## 1.9.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: FieldConsent, FieldImplicit
8
+
9
+ ## 1.9.9
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: IThemeFont, Text
14
+
3
15
  ## 1.9.8
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -4083,12 +4083,16 @@ function hasBackground(props) {
4083
4083
 
4084
4084
  const StyledText$1 = styled__default.default.div`
4085
4085
  ${props => getFontVariantResponsive(props, (variant, font) => styled.css`
4086
- ${font.family ? styled.css`font-family: var(--font-${variant}-family, var(--base-font-family));` : ''}
4087
- ${font.size ? styled.css`font-size: var(--font-${variant}-size, 1rem);` : ''}
4086
+ ${font.fontFamily ? styled.css`font-family: var(--font-${variant}-font-family, var(--base-font-family));` : ''}
4087
+ ${font.fontSize ? styled.css`font-size: var(--font-${variant}-font-size, 1rem);` : ''}
4088
4088
  ${font.lineHeight ? styled.css`line-height: var(--font-${variant}-line-height, 1);` : ''}
4089
4089
  ${font.fontWeight ? styled.css`font-weight: var(--font-${variant}-font-weight, inherit);` : ''}
4090
+ ${font.fontStyle ? styled.css`font-style: var(--font-${variant}-font-style, inherit);` : ''}
4090
4091
  ${font.letterSpacing ? styled.css`letter-spacing: var(--font-${variant}-letter-spacing, inherit);` : ''}
4091
4092
  ${font.textTransform ? styled.css`text-transform: var(--font-${variant}-text-transform, inherit);` : ''}
4093
+ //
4094
+ ${font.family ? styled.css`font-family: var(--font-${variant}-family, var(--base-font-family));` : ''}
4095
+ ${font.size ? styled.css`font-size: var(--font-${variant}-size, 1rem);` : ''}
4092
4096
  `)};
4093
4097
  ${props => props.gradient ? styled.css`
4094
4098
  display: -webkit-inline-box;
@@ -12522,7 +12526,7 @@ function FieldCheckbox(_a) {
12522
12526
  children: [jsxRuntime.jsxs(Label, {
12523
12527
  htmlFor: uniqueName,
12524
12528
  margin: "0",
12525
- children: [jsxRuntime.jsx(Checkbox, {
12529
+ children: [jsxRuntime.jsx(Ariakit.Checkbox, {
12526
12530
  id: uniqueName,
12527
12531
  name: uniqueName,
12528
12532
  onChange: onChange,
@@ -12604,6 +12608,143 @@ function FieldCombobox(_ref) {
12604
12608
  });
12605
12609
  }
12606
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
+
12607
12748
  function getIcon(type) {
12608
12749
  return type === 'password' ? jsxRuntime.jsx(bomMixerIcons.IconEye, {}) : jsxRuntime.jsx(bomMixerIcons.IconEyeOff, {});
12609
12750
  }
@@ -12616,13 +12757,27 @@ function FieldPassword(_ref) {
12616
12757
  const label = bomMixerHooks.useLabel();
12617
12758
  const uniqueName = `${control.name}-${uid}`;
12618
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');
12619
12776
  const onChange = event => {
12620
12777
  // console.log('FieldPassword', event.target.value);
12621
12778
  setValue(event.target.value);
12622
12779
  // control.value = event.target.value;
12623
12780
  };
12624
- const [focus, setFocus] = React.useState(false);
12625
- const [type, setType] = React.useState('password');
12626
12781
  const onBlur = _ => {
12627
12782
  setTouched();
12628
12783
  setFocus(false);
@@ -12638,21 +12793,25 @@ function FieldPassword(_ref) {
12638
12793
  value: state.value || ''
12639
12794
  }) : jsxRuntime.jsxs(Field, {
12640
12795
  state: state,
12796
+ className: bomCore.getClassNames({
12797
+ required: control.required && !control.disabled
12798
+ }),
12641
12799
  children: [jsxRuntime.jsx(Label, {
12642
12800
  htmlFor: uniqueName,
12643
12801
  children: control.label && label(control.label)
12644
12802
  }), jsxRuntime.jsx(Input, {
12803
+ width: "100%",
12804
+ ref: ref,
12645
12805
  id: uniqueName,
12646
12806
  name: uniqueName,
12647
12807
  type: type,
12648
12808
  placeholder: label(control.placeholder || control.label || ''),
12649
- value: state.value || '',
12809
+ defaultValue: state.value || '',
12650
12810
  onChange: onChange,
12651
12811
  onBlur: onBlur,
12652
12812
  onFocus: onFocus,
12653
12813
  disabled: state.flags.disabled,
12654
12814
  readOnly: state.flags.readonly,
12655
- width: "100%",
12656
12815
  after: jsxRuntime.jsx(Button, {
12657
12816
  onClick: () => onToggle(),
12658
12817
  children: icon(type)
@@ -12750,6 +12909,9 @@ function FieldSelect(_ref) {
12750
12909
  value: bomMixerForms.valueToString(state.value)
12751
12910
  }) : jsxRuntime.jsxs(Field, {
12752
12911
  state: state,
12912
+ className: bomCore.getClassNames({
12913
+ required: control.required && !control.disabled
12914
+ }),
12753
12915
  children: [jsxRuntime.jsxs(Select, {
12754
12916
  name: uniqueName,
12755
12917
  value: control.value,
@@ -12761,6 +12923,7 @@ function FieldSelect(_ref) {
12761
12923
  children: [control.label && jsxRuntime.jsx(Select.Label, {
12762
12924
  children: label(control.label)
12763
12925
  }), jsxRuntime.jsx(Select.Select, {
12926
+ disabled: control.disabled,
12764
12927
  children: icon || jsxRuntime.jsx(bomMixerIcons.IconChevronDown, {})
12765
12928
  }), jsxRuntime.jsx(Select.Popover, {
12766
12929
  gutter: 4,
@@ -12788,12 +12951,26 @@ function FieldText(_a) {
12788
12951
  const label = bomMixerHooks.useLabel();
12789
12952
  const uniqueName = `${control.name}-${uid}`;
12790
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]);
12791
12969
  const onChange = event => {
12792
12970
  // console.log('FieldText', event.target.value);
12793
12971
  setValue(event.target.value);
12794
12972
  // control.value = event.target.value;
12795
12973
  };
12796
- const [focus, setFocus] = React.useState(false);
12797
12974
  const onBlur = _ => {
12798
12975
  setTouched();
12799
12976
  setFocus(false);
@@ -12806,16 +12983,20 @@ function FieldText(_a) {
12806
12983
  value: state.value || ''
12807
12984
  }) : jsxRuntime.jsxs(Field, {
12808
12985
  state: state,
12986
+ className: bomCore.getClassNames({
12987
+ required: control.required && !control.disabled
12988
+ }),
12809
12989
  children: [jsxRuntime.jsx(Label, {
12810
12990
  htmlFor: uniqueName,
12811
12991
  children: control.label && label(control.label)
12812
12992
  }), jsxRuntime.jsx(Input, Object.assign({
12813
12993
  width: "100%"
12814
12994
  }, props, {
12995
+ ref: ref,
12815
12996
  id: uniqueName,
12816
12997
  name: uniqueName,
12817
12998
  placeholder: label(control.placeholder || control.label || ''),
12818
- value: state.value || '',
12999
+ defaultValue: state.value || '',
12819
13000
  onChange: onChange,
12820
13001
  onBlur: onBlur,
12821
13002
  onFocus: onFocus,
@@ -12879,15 +13060,19 @@ function FieldTextArea(_ref) {
12879
13060
  * Here we define the types of form fields.
12880
13061
  */
12881
13062
  const FIELDS = {
12882
- text: (control, uid) => jsxRuntime.jsx(FieldText, {
13063
+ accept: (control, uid) => jsxRuntime.jsx(FieldAccept, {
12883
13064
  control: control,
12884
13065
  uid: uid
12885
13066
  }, uid),
12886
- textarea: (control, uid) => jsxRuntime.jsx(FieldTextArea, {
13067
+ autocomplete: (control, uid) => jsxRuntime.jsx(FieldAutocomplete, {
12887
13068
  control: control,
12888
13069
  uid: uid
12889
13070
  }, uid),
12890
- password: (control, uid) => jsxRuntime.jsx(FieldPassword, {
13071
+ card: (control, uid) => jsxRuntime.jsx(FieldCard, {
13072
+ control: control,
13073
+ uid: uid
13074
+ }, uid),
13075
+ checkbox: (control, uid) => jsxRuntime.jsx(FieldCheckbox, {
12891
13076
  control: control,
12892
13077
  uid: uid
12893
13078
  }, uid),
@@ -12895,15 +13080,15 @@ const FIELDS = {
12895
13080
  control: control,
12896
13081
  uid: uid
12897
13082
  }, uid),
12898
- select: (control, uid) => jsxRuntime.jsx(FieldSelect, {
13083
+ consent: (control, uid) => jsxRuntime.jsx(FieldConsent, {
12899
13084
  control: control,
12900
13085
  uid: uid
12901
13086
  }, uid),
12902
- autocomplete: (control, uid) => jsxRuntime.jsx(FieldAutocomplete, {
13087
+ implicit: (control, uid) => jsxRuntime.jsx(FieldImplicit, {
12903
13088
  control: control,
12904
13089
  uid: uid
12905
13090
  }, uid),
12906
- checkbox: (control, uid) => jsxRuntime.jsx(FieldCheckbox, {
13091
+ password: (control, uid) => jsxRuntime.jsx(FieldPassword, {
12907
13092
  control: control,
12908
13093
  uid: uid
12909
13094
  }, uid),
@@ -12911,11 +13096,15 @@ const FIELDS = {
12911
13096
  control: control,
12912
13097
  uid: uid
12913
13098
  }, uid),
12914
- accept: (control, uid) => jsxRuntime.jsx(FieldAccept, {
13099
+ select: (control, uid) => jsxRuntime.jsx(FieldSelect, {
12915
13100
  control: control,
12916
13101
  uid: uid
12917
13102
  }, uid),
12918
- card: (control, uid) => jsxRuntime.jsx(FieldCard, {
13103
+ text: (control, uid) => jsxRuntime.jsx(FieldText, {
13104
+ control: control,
13105
+ uid: uid
13106
+ }, uid),
13107
+ textarea: (control, uid) => jsxRuntime.jsx(FieldTextArea, {
12919
13108
  control: control,
12920
13109
  uid: uid
12921
13110
  }, uid)
@@ -13740,6 +13929,7 @@ exports.Dropdown = Dropdown;
13740
13929
  exports.Ellipsis = Ellipsis;
13741
13930
  exports.ErrorHandler = ErrorHandler;
13742
13931
  exports.Expand = Expand;
13932
+ exports.FIELDS = FIELDS;
13743
13933
  exports.Field = Field;
13744
13934
  exports.FieldAccept = FieldAccept;
13745
13935
  exports.FieldAutocomplete = FieldAutocomplete;
@@ -13747,7 +13937,9 @@ exports.FieldCard = FieldCard;
13747
13937
  exports.FieldCheckbox = FieldCheckbox;
13748
13938
  exports.FieldCollection = FieldCollection;
13749
13939
  exports.FieldCombobox = FieldCombobox;
13940
+ exports.FieldConsent = FieldConsent;
13750
13941
  exports.FieldError = FieldError;
13942
+ exports.FieldImplicit = FieldImplicit;
13751
13943
  exports.FieldPassword = FieldPassword;
13752
13944
  exports.FieldRadio = FieldRadio;
13753
13945
  exports.FieldSelect = FieldSelect;