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.
package/dist/cjs/index.js CHANGED
@@ -11096,6 +11096,10 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11096
11096
  _useState6 = _slicedToArray(_useState5, 2),
11097
11097
  selectedItems = _useState6[0],
11098
11098
  setSelectedItems = _useState6[1];
11099
+ var _useState7 = React.useState(''),
11100
+ _useState8 = _slicedToArray(_useState7, 2),
11101
+ customRadioValue = _useState8[0],
11102
+ setCustomRadioValue = _useState8[1];
11099
11103
  var config = getInputFieldsConfig();
11100
11104
  var custom = field.custom || {};
11101
11105
  var inputType = custom.inputType || 'text';
@@ -11105,7 +11109,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11105
11109
  var options = custom.options || [];
11106
11110
  var minSelections = custom.minSelections || 0;
11107
11111
  var maxSelections = custom.maxSelections || options.length;
11108
- var isSubmitDisabled = inputType === 'list' ? selectedItems.length < minSelections : isRequired && !value;
11112
+ var isSubmitDisabled = inputType === 'list' ? selectedItems.length < minSelections : isRequired && (!value || value === '__custom__' && !customRadioValue.trim());
11109
11113
  var logoUrl = config.logoUrl || null;
11110
11114
  var headerText = config.headerText || null;
11111
11115
  var accentColor = config.accentColor || '#0d83cd';
@@ -11114,6 +11118,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11114
11118
  setValue('');
11115
11119
  setImagePreview(null);
11116
11120
  setSelectedItems([]);
11121
+ setCustomRadioValue('');
11117
11122
  }, [field.id]);
11118
11123
  var handleImageSelect = function handleImageSelect(e) {
11119
11124
  var _e$target$files;
@@ -11135,6 +11140,8 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11135
11140
  onSubmit(field.id, formatted);
11136
11141
  } else if (inputType === 'list') {
11137
11142
  onSubmit(field.id, selectedItems.join(', '));
11143
+ } else if (inputType === 'radio' && value === '__custom__') {
11144
+ onSubmit(field.id, customRadioValue.trim());
11138
11145
  } else {
11139
11146
  onSubmit(field.id, value);
11140
11147
  }
@@ -11281,38 +11288,71 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11281
11288
  })]
11282
11289
  });
11283
11290
  case 'radio':
11284
- return /*#__PURE__*/jsxRuntime.jsx(material.Box, {
11285
- sx: {
11286
- mt: 1,
11287
- flex: 1,
11288
- minHeight: 0,
11289
- overflowY: 'auto',
11290
- pr: 0.5,
11291
- '&::-webkit-scrollbar': {
11292
- width: 6
11293
- },
11294
- '&::-webkit-scrollbar-track': {
11295
- background: 'transparent'
11296
- },
11297
- '&::-webkit-scrollbar-thumb': {
11298
- background: '#d0d5dd',
11299
- borderRadius: 3
11300
- },
11301
- '&::-webkit-scrollbar-thumb:hover': {
11302
- background: '#aaa'
11303
- }
11304
- },
11305
- children: /*#__PURE__*/jsxRuntime.jsx(material.RadioGroup, {
11306
- value: value,
11307
- onChange: function onChange(e) {
11308
- return setValue(e.target.value);
11309
- },
11291
+ {
11292
+ var otherSelected = value === '__custom__';
11293
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
11310
11294
  sx: {
11311
- gap: 1
11295
+ mt: 1,
11296
+ flex: 1,
11297
+ minHeight: 0,
11298
+ overflowY: 'auto',
11299
+ pr: 0.5,
11300
+ '&::-webkit-scrollbar': {
11301
+ width: 6
11302
+ },
11303
+ '&::-webkit-scrollbar-track': {
11304
+ background: 'transparent'
11305
+ },
11306
+ '&::-webkit-scrollbar-thumb': {
11307
+ background: '#d0d5dd',
11308
+ borderRadius: 3
11309
+ },
11310
+ '&::-webkit-scrollbar-thumb:hover': {
11311
+ background: '#aaa'
11312
+ }
11312
11313
  },
11313
- children: options.map(function (opt) {
11314
- return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
11315
- value: opt,
11314
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.RadioGroup, {
11315
+ value: value,
11316
+ onChange: function onChange(e) {
11317
+ return setValue(e.target.value);
11318
+ },
11319
+ sx: {
11320
+ gap: 1
11321
+ },
11322
+ children: [options.map(function (opt) {
11323
+ return /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
11324
+ value: opt,
11325
+ control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
11326
+ sx: {
11327
+ color: '#d0d5dd',
11328
+ '&.Mui-checked': {
11329
+ color: accentColor
11330
+ }
11331
+ }
11332
+ }),
11333
+ label: /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
11334
+ sx: {
11335
+ fontSize: 18
11336
+ },
11337
+ children: opt
11338
+ }),
11339
+ sx: {
11340
+ m: 0,
11341
+ border: '1px solid',
11342
+ borderColor: value === opt ? accentColor : '#d0d5dd',
11343
+ borderRadius: '8px',
11344
+ px: 2,
11345
+ py: 0.75,
11346
+ transition: 'all 0.15s ease',
11347
+ backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
11348
+ '&:hover': {
11349
+ borderColor: accentColor,
11350
+ backgroundColor: 'rgba(13,131,205,0.03)'
11351
+ }
11352
+ }
11353
+ }, opt);
11354
+ }), /*#__PURE__*/jsxRuntime.jsx(material.FormControlLabel, {
11355
+ value: "__custom__",
11316
11356
  control: /*#__PURE__*/jsxRuntime.jsx(material.Radio, {
11317
11357
  sx: {
11318
11358
  color: '#d0d5dd',
@@ -11325,26 +11365,56 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
11325
11365
  sx: {
11326
11366
  fontSize: 18
11327
11367
  },
11328
- children: opt
11368
+ children: t('inputFieldsDialog.other', 'Other')
11329
11369
  }),
11330
11370
  sx: {
11331
11371
  m: 0,
11332
11372
  border: '1px solid',
11333
- borderColor: value === opt ? accentColor : '#d0d5dd',
11334
- borderRadius: '8px',
11373
+ borderColor: otherSelected ? accentColor : '#d0d5dd',
11374
+ borderRadius: otherSelected ? '8px 8px 0 0' : '8px',
11375
+ borderBottom: otherSelected ? 'none' : undefined,
11335
11376
  px: 2,
11336
11377
  py: 0.75,
11337
- transition: 'all 0.15s ease',
11338
- backgroundColor: value === opt ? 'rgba(13,131,205,0.04)' : 'transparent',
11378
+ transition: 'border-color 0.15s ease, border-radius 0.15s ease',
11379
+ backgroundColor: otherSelected ? 'rgba(13,131,205,0.04)' : 'transparent',
11339
11380
  '&:hover': {
11340
11381
  borderColor: accentColor,
11341
11382
  backgroundColor: 'rgba(13,131,205,0.03)'
11342
11383
  }
11343
11384
  }
11344
- }, opt);
11345
- })
11346
- })
11347
- });
11385
+ })]
11386
+ }), otherSelected && /*#__PURE__*/jsxRuntime.jsx(material.TextField, {
11387
+ autoFocus: true,
11388
+ fullWidth: true,
11389
+ value: customRadioValue,
11390
+ onChange: function onChange(e) {
11391
+ return setCustomRadioValue(e.target.value);
11392
+ },
11393
+ onKeyDown: function onKeyDown(e) {
11394
+ if (e.key === 'Enter' && customRadioValue.trim()) handleSubmit();
11395
+ },
11396
+ placeholder: t('inputFieldsDialog.otherPlaceholder', 'Type your answer…'),
11397
+ sx: {
11398
+ '& .MuiOutlinedInput-root': {
11399
+ borderRadius: '0 0 8px 8px',
11400
+ fontSize: 18,
11401
+ '& fieldset': {
11402
+ borderColor: accentColor,
11403
+ borderTopColor: 'transparent'
11404
+ },
11405
+ '&:hover fieldset': {
11406
+ borderColor: accentColor,
11407
+ borderTopColor: 'transparent'
11408
+ },
11409
+ '&.Mui-focused fieldset': {
11410
+ borderColor: accentColor,
11411
+ borderTopColor: 'transparent'
11412
+ }
11413
+ }
11414
+ }
11415
+ })]
11416
+ });
11417
+ }
11348
11418
  case 'list':
11349
11419
  {
11350
11420
  var isAtMax = maxSelections > 0 && selectedItems.length >= maxSelections;
@@ -11636,10 +11706,10 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
11636
11706
  backTrigger = _ref2$backTrigger === void 0 ? 0 : _ref2$backTrigger;
11637
11707
  // displayIndex counts how many fields have been answered (for step indicator only).
11638
11708
  // Navigation always uses fields[0] — the first remaining pending field.
11639
- var _useState7 = React.useState(0),
11640
- _useState8 = _slicedToArray(_useState7, 2),
11641
- displayIndex = _useState8[0],
11642
- setDisplayIndex = _useState8[1];
11709
+ var _useState9 = React.useState(0),
11710
+ _useState0 = _slicedToArray(_useState9, 2),
11711
+ displayIndex = _useState0[0],
11712
+ setDisplayIndex = _useState0[1];
11643
11713
  var initialTotalRef = React.useRef(0);
11644
11714
  var completedHistoryRef = React.useRef([]);
11645
11715
  var removedDueToSkipRef = React.useRef([]);