labellife-design-tool 2.3.1 → 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,59 +1891,165 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1884
1891
  })]
1885
1892
  });
1886
1893
  case 'radio':
1887
- return /*#__PURE__*/jsx(RadioGroup, {
1888
- value: value,
1889
- onChange: function onChange(e) {
1890
- return setValue(e.target.value);
1891
- },
1892
- sx: {
1893
- mt: 1,
1894
- gap: 1
1895
- },
1896
- children: options.map(function (opt) {
1897
- return /*#__PURE__*/jsx(FormControlLabel, {
1898
- value: opt,
1899
- control: /*#__PURE__*/jsx(Radio, {
1894
+ {
1895
+ var allowCustomValue = custom.allowCustomValue || false;
1896
+ var otherSelected = value === '__custom__';
1897
+ return /*#__PURE__*/jsxs(Box, {
1898
+ sx: {
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
+ }
1917
+ },
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__",
1960
+ control: /*#__PURE__*/jsx(Radio, {
1961
+ sx: {
1962
+ color: '#d0d5dd',
1963
+ '&.Mui-checked': {
1964
+ color: accentColor
1965
+ }
1966
+ }
1967
+ }),
1968
+ label: /*#__PURE__*/jsx(Typography, {
1969
+ sx: {
1970
+ fontSize: 18
1971
+ },
1972
+ children: t('inputFieldsDialog.other', 'Other')
1973
+ }),
1900
1974
  sx: {
1901
- color: '#d0d5dd',
1902
- '&.Mui-checked': {
1903
- color: accentColor
1975
+ m: 0,
1976
+ border: '1px solid',
1977
+ borderColor: otherSelected ? accentColor : '#d0d5dd',
1978
+ borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
1979
+ borderBottom: otherSelected ? 'none' : undefined,
1980
+ px: 2,
1981
+ py: 0.75,
1982
+ transition: 'border-color 0.15s ease, border-radius 0.15s ease',
1983
+ backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
1984
+ '&:hover': {
1985
+ borderColor: accentColor,
1986
+ backgroundColor: 'rgba(13,131,205,0.03)'
1904
1987
  }
1905
1988
  }
1906
- }),
1907
- label: /*#__PURE__*/jsx(Typography, {
1908
- sx: {
1909
- fontSize: 18
1910
- },
1911
- children: opt
1912
- }),
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…'),
1913
2001
  sx: {
1914
- m: 0,
1915
- border: '1px solid',
1916
- borderColor: value === opt ? accentColor : '#d0d5dd',
1917
- borderRadius: '8px',
1918
- px: 2,
1919
- py: 0.75,
1920
- transition: 'all 0.15s ease',
1921
- backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
1922
- '&:hover': {
1923
- borderColor: accentColor,
1924
- backgroundColor: 'rgba(13,131,205,0.03)'
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
+ }
1925
2017
  }
1926
2018
  }
1927
- }, opt);
1928
- })
1929
- });
2019
+ })]
2020
+ });
2021
+ }
1930
2022
  case 'list':
1931
2023
  {
1932
2024
  var isAtMax = maxSelections > 0 && selectedItems.length >= maxSelections;
1933
2025
  return /*#__PURE__*/jsxs(Box, {
1934
2026
  sx: {
1935
- mt: 1
2027
+ mt: 1,
2028
+ flex: 1,
2029
+ minHeight: 0,
2030
+ display: 'flex',
2031
+ flexDirection: 'column'
1936
2032
  },
1937
2033
  children: [/*#__PURE__*/jsx(FormGroup, {
1938
2034
  sx: {
1939
- gap: 1
2035
+ gap: 1,
2036
+ flex: 1,
2037
+ minHeight: 0,
2038
+ overflowY: 'auto',
2039
+ pr: 0.5,
2040
+ '&::-webkit-scrollbar': {
2041
+ width: 6
2042
+ },
2043
+ '&::-webkit-scrollbar-track': {
2044
+ background: 'transparent'
2045
+ },
2046
+ '&::-webkit-scrollbar-thumb': {
2047
+ background: '#d0d5dd',
2048
+ borderRadius: 3
2049
+ },
2050
+ '&::-webkit-scrollbar-thumb:hover': {
2051
+ background: '#aaa'
2052
+ }
1940
2053
  },
1941
2054
  children: options.map(function (opt) {
1942
2055
  var checked = selectedItems.includes(opt);
@@ -2074,18 +2187,23 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
2074
2187
  sx: {
2075
2188
  flex: 1,
2076
2189
  display: 'flex',
2077
- alignItems: 'center',
2078
- justifyContent: 'center',
2190
+ flexDirection: 'column',
2191
+ overflow: 'hidden',
2079
2192
  p: {
2080
2193
  xs: 3,
2081
2194
  sm: 5
2082
- },
2083
- overflowY: 'auto'
2195
+ }
2084
2196
  },
2085
2197
  children: /*#__PURE__*/jsxs(Box, {
2086
2198
  sx: {
2087
2199
  width: '100%',
2088
- maxWidth: 750
2200
+ maxWidth: 750,
2201
+ mx: 'auto',
2202
+ display: 'flex',
2203
+ flexDirection: 'column',
2204
+ flex: 1,
2205
+ minHeight: 0,
2206
+ justifyContent: 'center'
2089
2207
  },
2090
2208
  children: [/*#__PURE__*/jsx(Typography, {
2091
2209
  sx: {
@@ -2114,7 +2232,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
2114
2232
  display: 'flex',
2115
2233
  alignItems: 'center',
2116
2234
  gap: 2,
2117
- mt: 4.5
2235
+ mt: 4.5,
2236
+ flexShrink: 0
2118
2237
  },
2119
2238
  children: [canGoBack && /*#__PURE__*/jsx(Button, {
2120
2239
  variant: "outlined",
@@ -2191,10 +2310,10 @@ var InputFieldsDialog = observer(function (_ref2) {
2191
2310
  backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
2192
2311
  // displayIndex counts how many fields have been answered (for step indicator only).
2193
2312
  // Navigation always uses fields[0] — the first remaining pending field.
2194
- var _useState7 = useState(0),
2195
- _useState8 = _slicedToArray(_useState7, 2),
2196
- displayIndex = _useState8[0],
2197
- setDisplayIndex = _useState8[1];
2313
+ var _useState9 = useState(0),
2314
+ _useState0 = _slicedToArray(_useState9, 2),
2315
+ displayIndex = _useState0[0],
2316
+ setDisplayIndex = _useState0[1];
2198
2317
  var initialTotalRef = useRef(0);
2199
2318
  var completedHistoryRef = useRef([]);
2200
2319
  var removedDueToSkipRef = useRef([]);