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