labellife-design-tool 2.3.3 → 2.3.4

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.
@@ -1703,6 +1703,10 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1703
1703
  _useState6 = _slicedToArray(_useState5, 2),
1704
1704
  selectedItems = _useState6[0],
1705
1705
  setSelectedItems = _useState6[1];
1706
+ var _useState7 = react.useState(''),
1707
+ _useState8 = _slicedToArray(_useState7, 2),
1708
+ customRadioValue = _useState8[0],
1709
+ setCustomRadioValue = _useState8[1];
1706
1710
  var config = getInputFieldsConfig();
1707
1711
  var custom = field.custom || {};
1708
1712
  var inputType = custom.inputType || 'text';
@@ -1712,7 +1716,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1712
1716
  var options = custom.options || [];
1713
1717
  var minSelections = custom.minSelections || 0;
1714
1718
  var maxSelections = custom.maxSelections || options.length;
1715
- var isSubmitDisabled = inputType === 'list' ? selectedItems.length < minSelections : isRequired && !value;
1719
+ var isSubmitDisabled = inputType === 'list' ? selectedItems.length < minSelections : isRequired && (!value || value === '__custom__' && !customRadioValue.trim());
1716
1720
  var logoUrl = config.logoUrl || null;
1717
1721
  var headerText = config.headerText || null;
1718
1722
  var accentColor = config.accentColor || '#0d83cd';
@@ -1721,6 +1725,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1721
1725
  setValue('');
1722
1726
  setImagePreview(null);
1723
1727
  setSelectedItems([]);
1728
+ setCustomRadioValue('');
1724
1729
  }, [field.id]);
1725
1730
  var handleImageSelect = function handleImageSelect(e) {
1726
1731
  var _e$target$files;
@@ -1742,6 +1747,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1742
1747
  onSubmit(field.id, formatted);
1743
1748
  } else if (inputType === 'list') {
1744
1749
  onSubmit(field.id, selectedItems.join(', '));
1750
+ } else if (inputType === 'radio' && value === '__custom__') {
1751
+ onSubmit(field.id, customRadioValue.trim());
1745
1752
  } else {
1746
1753
  onSubmit(field.id, value);
1747
1754
  }
@@ -1888,38 +1895,72 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1888
1895
  })]
1889
1896
  });
1890
1897
  case 'radio':
1891
- return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1892
- sx: {
1893
- mt: 1,
1894
- flex: 1,
1895
- minHeight: 0,
1896
- overflowY: 'auto',
1897
- pr: 0.5,
1898
- '&::-webkit-scrollbar': {
1899
- width: 6
1900
- },
1901
- '&::-webkit-scrollbar-track': {
1902
- background: 'transparent'
1903
- },
1904
- '&::-webkit-scrollbar-thumb': {
1905
- background: '#d0d5dd',
1906
- borderRadius: 3
1907
- },
1908
- '&::-webkit-scrollbar-thumb:hover': {
1909
- background: '#aaa'
1910
- }
1911
- },
1912
- children: /*#__PURE__*/jsxRuntime.jsx(material.RadioGroup, {
1913
- value: value,
1914
- onChange: function onChange(e) {
1915
- return setValue(e.target.value);
1916
- },
1898
+ {
1899
+ var allowCustomValue = custom.allowCustomValue || false;
1900
+ var otherSelected = value === '__custom__';
1901
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1917
1902
  sx: {
1918
- gap: 1
1903
+ mt: 1,
1904
+ flex: 1,
1905
+ minHeight: 0,
1906
+ overflowY: 'auto',
1907
+ pr: 0.5,
1908
+ '&::-webkit-scrollbar': {
1909
+ width: 6
1910
+ },
1911
+ '&::-webkit-scrollbar-track': {
1912
+ background: 'transparent'
1913
+ },
1914
+ '&::-webkit-scrollbar-thumb': {
1915
+ background: '#d0d5dd',
1916
+ borderRadius: 3
1917
+ },
1918
+ '&::-webkit-scrollbar-thumb:hover': {
1919
+ background: '#aaa'
1920
+ }
1919
1921
  },
1920
- children: options.map(function (opt) {
1921
- return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
1922
- value: opt,
1922
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.RadioGroup, {
1923
+ value: value,
1924
+ onChange: function onChange(e) {
1925
+ return setValue(e.target.value);
1926
+ },
1927
+ sx: {
1928
+ gap: 1
1929
+ },
1930
+ children: [options.map(function (opt) {
1931
+ return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
1932
+ value: opt,
1933
+ control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
1934
+ sx: {
1935
+ color: '#d0d5dd',
1936
+ '&.Mui-checked': {
1937
+ color: accentColor
1938
+ }
1939
+ }
1940
+ }),
1941
+ label: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1942
+ sx: {
1943
+ fontSize: 18
1944
+ },
1945
+ children: opt
1946
+ }),
1947
+ sx: {
1948
+ m: 0,
1949
+ border: '1px solid',
1950
+ borderColor: value === opt ? accentColor : '#d0d5dd',
1951
+ borderRadius: '8px',
1952
+ px: 2,
1953
+ py: 0.75,
1954
+ transition: 'all 0.15s ease',
1955
+ backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
1956
+ '&:hover': {
1957
+ borderColor: accentColor,
1958
+ backgroundColor: 'rgba(13,131,205,0.03)'
1959
+ }
1960
+ }
1961
+ }, opt);
1962
+ }), allowCustomValue && /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
1963
+ value: "__custom__",
1923
1964
  control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
1924
1965
  sx: {
1925
1966
  color: '#d0d5dd',
@@ -1932,26 +1973,56 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1932
1973
  sx: {
1933
1974
  fontSize: 18
1934
1975
  },
1935
- children: opt
1976
+ children: t('inputFieldsDialog.other', 'Other')
1936
1977
  }),
1937
1978
  sx: {
1938
1979
  m: 0,
1939
1980
  border: '1px solid',
1940
- borderColor: value === opt ? accentColor : '#d0d5dd',
1941
- borderRadius: '8px',
1981
+ borderColor: otherSelected ? accentColor : '#d0d5dd',
1982
+ borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
1983
+ borderBottom: otherSelected ? 'none' : undefined,
1942
1984
  px: 2,
1943
1985
  py: 0.75,
1944
- transition: 'all 0.15s ease',
1945
- backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
1986
+ transition: 'border-color 0.15s ease, border-radius 0.15s ease',
1987
+ backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
1946
1988
  '&:hover': {
1947
1989
  borderColor: accentColor,
1948
1990
  backgroundColor: 'rgba(13,131,205,0.03)'
1949
1991
  }
1950
1992
  }
1951
- }, opt);
1952
- })
1953
- })
1954
- });
1993
+ })]
1994
+ }), allowCustomValue && otherSelected && /*#__PURE__*/jsxRuntime.jsx(material.TextField, {
1995
+ autoFocus: true,
1996
+ fullWidth: true,
1997
+ value: customRadioValue,
1998
+ onChange: function onChange(e) {
1999
+ return setCustomRadioValue(e.target.value);
2000
+ },
2001
+ onKeyDown: function onKeyDown(e) {
2002
+ if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
2003
+ },
2004
+ placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
2005
+ sx: {
2006
+ '& .MuiOutlinedInput-root': {
2007
+ borderRadius: '0 0 8px 8px',
2008
+ fontSize: 18,
2009
+ '& fieldset': {
2010
+ borderColor: accentColor,
2011
+ borderTopColor: 'transparent'
2012
+ },
2013
+ '&:hover fieldset': {
2014
+ borderColor: accentColor,
2015
+ borderTopColor: 'transparent'
2016
+ },
2017
+ '&.Mui-focused fieldset': {
2018
+ borderColor: accentColor,
2019
+ borderTopColor: 'transparent'
2020
+ }
2021
+ }
2022
+ }
2023
+ })]
2024
+ });
2025
+ }
1955
2026
  case 'list':
1956
2027
  {
1957
2028
  var isAtMax = maxSelections > 0 && selectedItems.length >= maxSelections;
@@ -2243,10 +2314,10 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2243
2314
  backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
2244
2315
  // displayIndex counts how many fields have been answered (for step indicator only).
2245
2316
  // Navigation always uses fields[0] — the first remaining pending field.
2246
- var _useState7 = react.useState(0),
2247
- _useState8 = _slicedToArray(_useState7, 2),
2248
- displayIndex = _useState8[0],
2249
- setDisplayIndex = _useState8[1];
2317
+ var _useState9 = react.useState(0),
2318
+ _useState0 = _slicedToArray(_useState9, 2),
2319
+ displayIndex = _useState0[0],
2320
+ setDisplayIndex = _useState0[1];
2250
2321
  var initialTotalRef = react.useRef(0);
2251
2322
  var completedHistoryRef = react.useRef([]);
2252
2323
  var removedDueToSkipRef = react.useRef([]);