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.
@@ -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,72 @@ 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 allowCustomValue = custom.allowCustomValue || false;
1896
+ var otherSelected = value === '__custom__';
1897
+ return /*#__PURE__*/jsxs(Box, {
1913
1898
  sx: {
1914
- gap: 1
1899
+ mt: 1,
1900
+ flex: 1,
1901
+ minHeight: 0,
1902
+ overflowY: 'auto',
1903
+ pr: 0.5,
1904
+ '&::-webkit-scrollbar': {
1905
+ width: 6
1906
+ },
1907
+ '&::-webkit-scrollbar-track': {
1908
+ background: 'transparent'
1909
+ },
1910
+ '&::-webkit-scrollbar-thumb': {
1911
+ background: '#d0d5dd',
1912
+ borderRadius: 3
1913
+ },
1914
+ '&::-webkit-scrollbar-thumb:hover': {
1915
+ background: '#aaa'
1916
+ }
1915
1917
  },
1916
- children: options.map(function (opt) {
1917
- return /*#__PURE__*/jsx(FormControlLabel, {
1918
- value: opt,
1918
+ children: [/*#__PURE__*/jsxs(RadioGroup, {
1919
+ value: value,
1920
+ onChange: function onChange(e) {
1921
+ return setValue(e.target.value);
1922
+ },
1923
+ sx: {
1924
+ gap: 1
1925
+ },
1926
+ children: [options.map(function (opt) {
1927
+ return /*#__PURE__*/jsx(FormControlLabel, {
1928
+ value: opt,
1929
+ control: /*#__PURE__*/jsx(Radio, {
1930
+ sx: {
1931
+ color: '#d0d5dd',
1932
+ '&.Mui-checked': {
1933
+ color: accentColor
1934
+ }
1935
+ }
1936
+ }),
1937
+ label: /*#__PURE__*/jsx(Typography, {
1938
+ sx: {
1939
+ fontSize: 18
1940
+ },
1941
+ children: opt
1942
+ }),
1943
+ sx: {
1944
+ m: 0,
1945
+ border: '1px solid',
1946
+ borderColor: value === opt ? accentColor : '#d0d5dd',
1947
+ borderRadius: '8px',
1948
+ px: 2,
1949
+ py: 0.75,
1950
+ transition: 'all 0.15s ease',
1951
+ backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
1952
+ '&:hover': {
1953
+ borderColor: accentColor,
1954
+ backgroundColor: 'rgba(13,131,205,0.03)'
1955
+ }
1956
+ }
1957
+ }, opt);
1958
+ }), allowCustomValue && /*#__PURE__*/jsx(FormControlLabel, {
1959
+ value: "__custom__",
1919
1960
  control: /*#__PURE__*/jsx(Radio, {
1920
1961
  sx: {
1921
1962
  color: '#d0d5dd',
@@ -1928,26 +1969,56 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1928
1969
  sx: {
1929
1970
  fontSize: 18
1930
1971
  },
1931
- children: opt
1972
+ children: t('inputFieldsDialog.other', 'Other')
1932
1973
  }),
1933
1974
  sx: {
1934
1975
  m: 0,
1935
1976
  border: '1px solid',
1936
- borderColor: value === opt ? accentColor : '#d0d5dd',
1937
- borderRadius: '8px',
1977
+ borderColor: otherSelected ? accentColor : '#d0d5dd',
1978
+ borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
1979
+ borderBottom: otherSelected ? 'none' : undefined,
1938
1980
  px: 2,
1939
1981
  py: 0.75,
1940
- transition: 'all 0.15s ease',
1941
- backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
1982
+ transition: 'border-color 0.15s ease, border-radius 0.15s ease',
1983
+ backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
1942
1984
  '&:hover': {
1943
1985
  borderColor: accentColor,
1944
1986
  backgroundColor: 'rgba(13,131,205,0.03)'
1945
1987
  }
1946
1988
  }
1947
- }, opt);
1948
- })
1949
- })
1950
- });
1989
+ })]
1990
+ }), allowCustomValue && otherSelected && /*#__PURE__*/jsx(TextField, {
1991
+ autoFocus: true,
1992
+ fullWidth: true,
1993
+ value: customRadioValue,
1994
+ onChange: function onChange(e) {
1995
+ return setCustomRadioValue(e.target.value);
1996
+ },
1997
+ onKeyDown: function onKeyDown(e) {
1998
+ if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
1999
+ },
2000
+ placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
2001
+ sx: {
2002
+ '& .MuiOutlinedInput-root': {
2003
+ borderRadius: '0 0 8px 8px',
2004
+ fontSize: 18,
2005
+ '& fieldset': {
2006
+ borderColor: accentColor,
2007
+ borderTopColor: 'transparent'
2008
+ },
2009
+ '&:hover fieldset': {
2010
+ borderColor: accentColor,
2011
+ borderTopColor: 'transparent'
2012
+ },
2013
+ '&.Mui-focused fieldset': {
2014
+ borderColor: accentColor,
2015
+ borderTopColor: 'transparent'
2016
+ }
2017
+ }
2018
+ }
2019
+ })]
2020
+ });
2021
+ }
1951
2022
  case 'list':
1952
2023
  {
1953
2024
  var isAtMax = maxSelections > 0 && selectedItems.length >= maxSelections;
@@ -2239,10 +2310,10 @@ var InputFieldsDialog = observer(function (_ref2) {
2239
2310
  backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
2240
2311
  // displayIndex counts how many fields have been answered (for step indicator only).
2241
2312
  // 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];
2313
+ var _useState9 = useState(0),
2314
+ _useState0 = _slicedToArray(_useState9, 2),
2315
+ displayIndex = _useState0[0],
2316
+ setDisplayIndex = _useState0[1];
2246
2317
  var initialTotalRef = useRef(0);
2247
2318
  var completedHistoryRef = useRef([]);
2248
2319
  var removedDueToSkipRef = useRef([]);