labellife-design-tool 2.2.7 → 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.
- package/dist/cjs/canvas/workspace.js +134 -8
- package/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +521 -43
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/side-panel/index.js +387 -35
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/esm/canvas/workspace.js +135 -9
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +522 -44
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/side-panel/index.js +387 -35
- package/dist/esm/side-panel/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1688,12 +1688,20 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1688
1688
|
imagePreview = _useState4[0],
|
|
1689
1689
|
setImagePreview = _useState4[1];
|
|
1690
1690
|
var fileInputRef = react.useRef(null);
|
|
1691
|
+
var _useState5 = react.useState([]),
|
|
1692
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1693
|
+
selectedItems = _useState6[0],
|
|
1694
|
+
setSelectedItems = _useState6[1];
|
|
1691
1695
|
var config = getInputFieldsConfig();
|
|
1692
1696
|
var custom = field.custom || {};
|
|
1693
1697
|
var inputType = custom.inputType || 'text';
|
|
1694
1698
|
var promptText = custom.promptText || custom.placeholder || 'Please provide input';
|
|
1695
1699
|
var dateFormat = custom.dateFormat || 'MM-DD-YYYY';
|
|
1696
1700
|
var isRequired = custom.required === true;
|
|
1701
|
+
var options = custom.options || [];
|
|
1702
|
+
var minSelections = custom.minSelections || 0;
|
|
1703
|
+
var maxSelections = custom.maxSelections || options.length;
|
|
1704
|
+
var isSubmitDisabled = inputType === 'list' ? selectedItems.length < minSelections : isRequired && !value;
|
|
1697
1705
|
var logoUrl = config.logoUrl || null;
|
|
1698
1706
|
var headerText = config.headerText || null;
|
|
1699
1707
|
var accentColor = config.accentColor || '#0d83cd';
|
|
@@ -1701,6 +1709,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1701
1709
|
react.useEffect(function () {
|
|
1702
1710
|
setValue('');
|
|
1703
1711
|
setImagePreview(null);
|
|
1712
|
+
setSelectedItems([]);
|
|
1704
1713
|
}, [field.id]);
|
|
1705
1714
|
var handleImageSelect = function handleImageSelect(e) {
|
|
1706
1715
|
var _e$target$files;
|
|
@@ -1720,12 +1729,14 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1720
1729
|
var dateObj = parseDateFromFormat(value);
|
|
1721
1730
|
var formatted = formatDate(dateObj, dateFormat);
|
|
1722
1731
|
onSubmit(field.id, formatted);
|
|
1732
|
+
} else if (inputType === 'list') {
|
|
1733
|
+
onSubmit(field.id, selectedItems.join(', '));
|
|
1723
1734
|
} else {
|
|
1724
1735
|
onSubmit(field.id, value);
|
|
1725
1736
|
}
|
|
1726
1737
|
};
|
|
1727
1738
|
var handleKeyDown = function handleKeyDown(e) {
|
|
1728
|
-
if (e.key === 'Enter' && inputType !== 'image') handleSubmit();
|
|
1739
|
+
if (e.key === 'Enter' && inputType !== 'image' && inputType !== 'list' && inputType !== 'radio') handleSubmit();
|
|
1729
1740
|
};
|
|
1730
1741
|
var renderInput = function renderInput() {
|
|
1731
1742
|
var sharedSx = _objectSpread2({
|
|
@@ -1865,6 +1876,119 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
1865
1876
|
})]
|
|
1866
1877
|
})]
|
|
1867
1878
|
});
|
|
1879
|
+
case 'radio':
|
|
1880
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.RadioGroup, {
|
|
1881
|
+
value: value,
|
|
1882
|
+
onChange: function onChange(e) {
|
|
1883
|
+
return setValue(e.target.value);
|
|
1884
|
+
},
|
|
1885
|
+
sx: {
|
|
1886
|
+
mt: 1,
|
|
1887
|
+
gap: 1
|
|
1888
|
+
},
|
|
1889
|
+
children: options.map(function (opt) {
|
|
1890
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
|
|
1891
|
+
value: opt,
|
|
1892
|
+
control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
|
|
1893
|
+
sx: {
|
|
1894
|
+
color: '#d0d5dd',
|
|
1895
|
+
'&.Mui-checked': {
|
|
1896
|
+
color: accentColor
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}),
|
|
1900
|
+
label: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
1901
|
+
sx: {
|
|
1902
|
+
fontSize: 18
|
|
1903
|
+
},
|
|
1904
|
+
children: opt
|
|
1905
|
+
}),
|
|
1906
|
+
sx: {
|
|
1907
|
+
m: 0,
|
|
1908
|
+
border: '1px solid',
|
|
1909
|
+
borderColor: value === opt ? accentColor : '#d0d5dd',
|
|
1910
|
+
borderRadius: '8px',
|
|
1911
|
+
px: 2,
|
|
1912
|
+
py: 0.75,
|
|
1913
|
+
transition: 'all 0.15s ease',
|
|
1914
|
+
backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
|
|
1915
|
+
'&:hover': {
|
|
1916
|
+
borderColor: accentColor,
|
|
1917
|
+
backgroundColor: 'rgba(13,131,205,0.03)'
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}, opt);
|
|
1921
|
+
})
|
|
1922
|
+
});
|
|
1923
|
+
case 'list':
|
|
1924
|
+
{
|
|
1925
|
+
var isAtMax = maxSelections > 0 && selectedItems.length >= maxSelections;
|
|
1926
|
+
return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
1927
|
+
sx: {
|
|
1928
|
+
mt: 1
|
|
1929
|
+
},
|
|
1930
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.FormGroup, {
|
|
1931
|
+
sx: {
|
|
1932
|
+
gap: 1
|
|
1933
|
+
},
|
|
1934
|
+
children: options.map(function (opt) {
|
|
1935
|
+
var checked = selectedItems.includes(opt);
|
|
1936
|
+
var disabled = !checked && isAtMax;
|
|
1937
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
|
|
1938
|
+
control: /*#__PURE__*/jsxRuntime.jsx(material.Checkbox, {
|
|
1939
|
+
checked: checked,
|
|
1940
|
+
disabled: disabled,
|
|
1941
|
+
onChange: function onChange(e) {
|
|
1942
|
+
if (e.target.checked) {
|
|
1943
|
+
setSelectedItems(function (prev) {
|
|
1944
|
+
return [].concat(_toConsumableArray(prev), [opt]);
|
|
1945
|
+
});
|
|
1946
|
+
} else {
|
|
1947
|
+
setSelectedItems(function (prev) {
|
|
1948
|
+
return prev.filter(function (i) {
|
|
1949
|
+
return i !== opt;
|
|
1950
|
+
});
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
},
|
|
1954
|
+
sx: {
|
|
1955
|
+
color: '#d0d5dd',
|
|
1956
|
+
'&.Mui-checked': {
|
|
1957
|
+
color: accentColor
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}),
|
|
1961
|
+
label: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
1962
|
+
sx: {
|
|
1963
|
+
fontSize: 18,
|
|
1964
|
+
opacity: disabled ? 0.45 : 1
|
|
1965
|
+
},
|
|
1966
|
+
children: opt
|
|
1967
|
+
}),
|
|
1968
|
+
sx: {
|
|
1969
|
+
m: 0,
|
|
1970
|
+
border: '1px solid',
|
|
1971
|
+
borderColor: checked ? accentColor : '#d0d5dd',
|
|
1972
|
+
borderRadius: '8px',
|
|
1973
|
+
px: 2,
|
|
1974
|
+
py: 0.75,
|
|
1975
|
+
opacity: disabled ? 0.6 : 1,
|
|
1976
|
+
transition: 'all 0.15s ease',
|
|
1977
|
+
backgroundColor: checked ? 'rgba(13,131,205,0.04)' : 'transparent'
|
|
1978
|
+
}
|
|
1979
|
+
}, opt);
|
|
1980
|
+
})
|
|
1981
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
|
|
1982
|
+
variant: "caption",
|
|
1983
|
+
sx: {
|
|
1984
|
+
color: '#999',
|
|
1985
|
+
display: 'block',
|
|
1986
|
+
mt: 1.5
|
|
1987
|
+
},
|
|
1988
|
+
children: [selectedItems.length, maxSelections > 0 ? "/".concat(maxSelections) : '', " selected", minSelections > 0 && " \xB7 min ".concat(minSelections, " required")]
|
|
1989
|
+
})]
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1868
1992
|
case 'text':
|
|
1869
1993
|
default:
|
|
1870
1994
|
return /*#__PURE__*/jsxRuntime.jsx(material.TextField, {
|
|
@@ -2007,7 +2131,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
2007
2131
|
}), /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
2008
2132
|
variant: "contained",
|
|
2009
2133
|
onClick: handleSubmit,
|
|
2010
|
-
disabled:
|
|
2134
|
+
disabled: isSubmitDisabled,
|
|
2011
2135
|
sx: _objectSpread2({
|
|
2012
2136
|
textTransform: 'none',
|
|
2013
2137
|
fontWeight: 600,
|
|
@@ -2023,7 +2147,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
|
|
|
2023
2147
|
}
|
|
2024
2148
|
}, config.submitButtonStyle),
|
|
2025
2149
|
children: config.submitButtonText || t('inputFieldsDialog.submit', 'Continue')
|
|
2026
|
-
}), !isRequired && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
2150
|
+
}), (inputType === 'list' ? minSelections === 0 : !isRequired) && /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
2027
2151
|
variant: "outlined",
|
|
2028
2152
|
onClick: function onClick() {
|
|
2029
2153
|
return onSkip(field.id);
|
|
@@ -2060,10 +2184,10 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2060
2184
|
backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
|
|
2061
2185
|
// displayIndex counts how many fields have been answered (for step indicator only).
|
|
2062
2186
|
// Navigation always uses fields[0] — the first remaining pending field.
|
|
2063
|
-
var
|
|
2064
|
-
|
|
2065
|
-
displayIndex =
|
|
2066
|
-
setDisplayIndex =
|
|
2187
|
+
var _useState7 = react.useState(0),
|
|
2188
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2189
|
+
displayIndex = _useState8[0],
|
|
2190
|
+
setDisplayIndex = _useState8[1];
|
|
2067
2191
|
var initialTotalRef = react.useRef(0);
|
|
2068
2192
|
var completedHistoryRef = react.useRef([]);
|
|
2069
2193
|
var isGoingBackRef = react.useRef(false);
|
|
@@ -2208,7 +2332,9 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
|
|
|
2208
2332
|
text: config.CustomTextDialog,
|
|
2209
2333
|
date: config.CustomDateDialog,
|
|
2210
2334
|
integer: config.CustomIntegerDialog,
|
|
2211
|
-
image: config.CustomImageDialog
|
|
2335
|
+
image: config.CustomImageDialog,
|
|
2336
|
+
radio: config.CustomRadioDialog,
|
|
2337
|
+
list: config.CustomListDialog
|
|
2212
2338
|
};
|
|
2213
2339
|
var fieldType = currentField.custom && currentField.custom.inputType || 'text';
|
|
2214
2340
|
var PerTypeDialog = TYPE_DIALOG_MAP[fieldType];
|