labellife-design-tool 2.3.3 → 2.3.5

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