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