labellife-design-tool 2.2.6 → 2.2.8

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.
@@ -1,7 +1,7 @@
1
1
  import { useRef, useState, useEffect, Fragment, useCallback } from 'react';
2
2
  import { Image, Group, Rect, Text, Arrow, Path, RegularPolygon, Star, Circle, Line, Shape, Transformer, Stage, Layer } from 'react-konva';
3
3
  import { observer } from 'mobx-react-lite';
4
- import { Box, Typography, IconButton, Button, TextField } from '@mui/material';
4
+ import { Box, Typography, IconButton, Button, TextField, FormGroup, FormControlLabel, Checkbox, RadioGroup, Radio } from '@mui/material';
5
5
  import CloseIcon from '@mui/icons-material/Close';
6
6
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
7
7
  import Konva from 'konva';
@@ -1684,12 +1684,20 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1684
1684
  imagePreview = _useState4[0],
1685
1685
  setImagePreview = _useState4[1];
1686
1686
  var fileInputRef = useRef(null);
1687
+ var _useState5 = useState([]),
1688
+ _useState6 = _slicedToArray(_useState5, 2),
1689
+ selectedItems = _useState6[0],
1690
+ setSelectedItems = _useState6[1];
1687
1691
  var config = getInputFieldsConfig();
1688
1692
  var custom = field.custom || {};
1689
1693
  var inputType = custom.inputType || 'text';
1690
1694
  var promptText = custom.promptText || custom.placeholder || 'Please provide input';
1691
1695
  var dateFormat = custom.dateFormat || 'MM-DD-YYYY';
1692
1696
  var isRequired = custom.required === true;
1697
+ var options = custom.options || [];
1698
+ var minSelections = custom.minSelections || 0;
1699
+ var maxSelections = custom.maxSelections || options.length;
1700
+ var isSubmitDisabled = inputType === 'list' ? selectedItems.length < minSelections : isRequired && !value;
1693
1701
  var logoUrl = config.logoUrl || null;
1694
1702
  var headerText = config.headerText || null;
1695
1703
  var accentColor = config.accentColor || '#0d83cd';
@@ -1697,6 +1705,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1697
1705
  useEffect(function () {
1698
1706
  setValue('');
1699
1707
  setImagePreview(null);
1708
+ setSelectedItems([]);
1700
1709
  }, [field.id]);
1701
1710
  var handleImageSelect = function handleImageSelect(e) {
1702
1711
  var _e$target$files;
@@ -1716,12 +1725,14 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1716
1725
  var dateObj = parseDateFromFormat(value);
1717
1726
  var formatted = formatDate(dateObj, dateFormat);
1718
1727
  onSubmit(field.id, formatted);
1728
+ } else if (inputType === 'list') {
1729
+ onSubmit(field.id, selectedItems.join(', '));
1719
1730
  } else {
1720
1731
  onSubmit(field.id, value);
1721
1732
  }
1722
1733
  };
1723
1734
  var handleKeyDown = function handleKeyDown(e) {
1724
- if (e.key === 'Enter' && inputType !== 'image') handleSubmit();
1735
+ if (e.key === 'Enter' && inputType !== 'image' && inputType !== 'list' && inputType !== 'radio') handleSubmit();
1725
1736
  };
1726
1737
  var renderInput = function renderInput() {
1727
1738
  var sharedSx = _objectSpread2({
@@ -1861,6 +1872,119 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1861
1872
  })]
1862
1873
  })]
1863
1874
  });
1875
+ case 'radio':
1876
+ return /*#__PURE__*/jsx(RadioGroup, {
1877
+ value: value,
1878
+ onChange: function onChange(e) {
1879
+ return setValue(e.target.value);
1880
+ },
1881
+ sx: {
1882
+ mt: 1,
1883
+ gap: 1
1884
+ },
1885
+ children: options.map(function (opt) {
1886
+ return /*#__PURE__*/jsx(FormControlLabel, {
1887
+ value: opt,
1888
+ control: /*#__PURE__*/jsx(Radio, {
1889
+ sx: {
1890
+ color: '#d0d5dd',
1891
+ '&.Mui-checked': {
1892
+ color: accentColor
1893
+ }
1894
+ }
1895
+ }),
1896
+ label: /*#__PURE__*/jsx(Typography, {
1897
+ sx: {
1898
+ fontSize: 18
1899
+ },
1900
+ children: opt
1901
+ }),
1902
+ sx: {
1903
+ m: 0,
1904
+ border: '1px solid',
1905
+ borderColor: value === opt ? accentColor : '#d0d5dd',
1906
+ borderRadius: '8px',
1907
+ px: 2,
1908
+ py: 0.75,
1909
+ transition: 'all 0.15s ease',
1910
+ backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
1911
+ '&:hover': {
1912
+ borderColor: accentColor,
1913
+ backgroundColor: 'rgba(13,131,205,0.03)'
1914
+ }
1915
+ }
1916
+ }, opt);
1917
+ })
1918
+ });
1919
+ case 'list':
1920
+ {
1921
+ var isAtMax = maxSelections > 0 && selectedItems.length >= maxSelections;
1922
+ return /*#__PURE__*/jsxs(Box, {
1923
+ sx: {
1924
+ mt: 1
1925
+ },
1926
+ children: [/*#__PURE__*/jsx(FormGroup, {
1927
+ sx: {
1928
+ gap: 1
1929
+ },
1930
+ children: options.map(function (opt) {
1931
+ var checked = selectedItems.includes(opt);
1932
+ var disabled = !checked && isAtMax;
1933
+ return /*#__PURE__*/jsx(FormControlLabel, {
1934
+ control: /*#__PURE__*/jsx(Checkbox, {
1935
+ checked: checked,
1936
+ disabled: disabled,
1937
+ onChange: function onChange(e) {
1938
+ if (e.target.checked) {
1939
+ setSelectedItems(function (prev) {
1940
+ return [].concat(_toConsumableArray(prev), [opt]);
1941
+ });
1942
+ } else {
1943
+ setSelectedItems(function (prev) {
1944
+ return prev.filter(function (i) {
1945
+ return i !== opt;
1946
+ });
1947
+ });
1948
+ }
1949
+ },
1950
+ sx: {
1951
+ color: '#d0d5dd',
1952
+ '&.Mui-checked': {
1953
+ color: accentColor
1954
+ }
1955
+ }
1956
+ }),
1957
+ label: /*#__PURE__*/jsx(Typography, {
1958
+ sx: {
1959
+ fontSize: 18,
1960
+ opacity: disabled ? 0.45 : 1
1961
+ },
1962
+ children: opt
1963
+ }),
1964
+ sx: {
1965
+ m: 0,
1966
+ border: '1px solid',
1967
+ borderColor: checked ? accentColor : '#d0d5dd',
1968
+ borderRadius: '8px',
1969
+ px: 2,
1970
+ py: 0.75,
1971
+ opacity: disabled ? 0.6 : 1,
1972
+ transition: 'all 0.15s ease',
1973
+ backgroundColor: checked ? 'rgba(13,131,205,0.04)' : 'transparent'
1974
+ }
1975
+ }, opt);
1976
+ })
1977
+ }), /*#__PURE__*/jsxs(Typography, {
1978
+ variant: "caption",
1979
+ sx: {
1980
+ color: '#999',
1981
+ display: 'block',
1982
+ mt: 1.5
1983
+ },
1984
+ children: [selectedItems.length, maxSelections > 0 ? "/".concat(maxSelections) : '', " selected", minSelections > 0 && " \xB7 min ".concat(minSelections, " required")]
1985
+ })]
1986
+ });
1987
+ }
1864
1988
  case 'text':
1865
1989
  default:
1866
1990
  return /*#__PURE__*/jsx(TextField, {
@@ -2003,7 +2127,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
2003
2127
  }), /*#__PURE__*/jsx(Button, {
2004
2128
  variant: "contained",
2005
2129
  onClick: handleSubmit,
2006
- disabled: isRequired && !value,
2130
+ disabled: isSubmitDisabled,
2007
2131
  sx: _objectSpread2({
2008
2132
  textTransform: 'none',
2009
2133
  fontWeight: 600,
@@ -2019,7 +2143,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
2019
2143
  }
2020
2144
  }, config.submitButtonStyle),
2021
2145
  children: config.submitButtonText || t('inputFieldsDialog.submit', 'Continue')
2022
- }), !isRequired && /*#__PURE__*/jsx(Button, {
2146
+ }), (inputType === 'list' ? minSelections === 0 : !isRequired) && /*#__PURE__*/jsx(Button, {
2023
2147
  variant: "outlined",
2024
2148
  onClick: function onClick() {
2025
2149
  return onSkip(field.id);
@@ -2056,10 +2180,10 @@ var InputFieldsDialog = observer(function (_ref2) {
2056
2180
  backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
2057
2181
  // displayIndex counts how many fields have been answered (for step indicator only).
2058
2182
  // Navigation always uses fields[0] — the first remaining pending field.
2059
- var _useState5 = useState(0),
2060
- _useState6 = _slicedToArray(_useState5, 2),
2061
- displayIndex = _useState6[0],
2062
- setDisplayIndex = _useState6[1];
2183
+ var _useState7 = useState(0),
2184
+ _useState8 = _slicedToArray(_useState7, 2),
2185
+ displayIndex = _useState8[0],
2186
+ setDisplayIndex = _useState8[1];
2063
2187
  var initialTotalRef = useRef(0);
2064
2188
  var completedHistoryRef = useRef([]);
2065
2189
  var isGoingBackRef = useRef(false);
@@ -2204,7 +2328,9 @@ var InputFieldsDialog = observer(function (_ref2) {
2204
2328
  text: config.CustomTextDialog,
2205
2329
  date: config.CustomDateDialog,
2206
2330
  integer: config.CustomIntegerDialog,
2207
- image: config.CustomImageDialog
2331
+ image: config.CustomImageDialog,
2332
+ radio: config.CustomRadioDialog,
2333
+ list: config.CustomListDialog
2208
2334
  };
2209
2335
  var fieldType = currentField.custom && currentField.custom.inputType || 'text';
2210
2336
  var PerTypeDialog = TYPE_DIALOG_MAP[fieldType];