@ceed/ads 0.0.85 → 0.0.87

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/index.js CHANGED
@@ -1199,9 +1199,16 @@ function getCurrencySymbol(currencyCode) {
1199
1199
  }).format(0);
1200
1200
  return formatted.replace(/[\d\s.,]/g, "");
1201
1201
  }
1202
+ function formatValueString(amount, currency = "usd") {
1203
+ const formatter = new IntlMessageFormat(
1204
+ `{amount, number, ::currency/${currency} unit-width-narrow}`
1205
+ );
1206
+ return formatter.format({ amount }).toString();
1207
+ }
1202
1208
  var TextMaskAdapter = React13.forwardRef(
1203
1209
  function TextMaskAdapter2(props, ref) {
1204
1210
  const { onChange, currency, ...innerProps } = props;
1211
+ const [value, setValue] = useState3(props.value || 0);
1205
1212
  const currencySymbol = getCurrencySymbol(currency);
1206
1213
  return /* @__PURE__ */ React13.createElement(
1207
1214
  IMaskInput,
@@ -1209,15 +1216,18 @@ var TextMaskAdapter = React13.forwardRef(
1209
1216
  ...innerProps,
1210
1217
  inputRef: ref,
1211
1218
  mask: `${currencySymbol}num`,
1212
- onAccept: (value) => {
1219
+ lazy: false,
1220
+ overwrite: true,
1221
+ onAccept: (value2) => {
1222
+ setValue(Number(value2));
1213
1223
  onChange({
1214
1224
  target: {
1215
1225
  name: props.name,
1216
- value
1226
+ value: value2
1217
1227
  }
1218
1228
  });
1219
1229
  },
1220
- value: props.value?.toString(),
1230
+ value: formatValueString(value, currency),
1221
1231
  unmask: true,
1222
1232
  blocks: {
1223
1233
  num: {
@@ -1229,7 +1239,6 @@ var TextMaskAdapter = React13.forwardRef(
1229
1239
  padFractionalZeros: currency !== "krw"
1230
1240
  }
1231
1241
  },
1232
- placeholderChar: currencySymbol,
1233
1242
  placeholder: `${currencySymbol}0.00`
1234
1243
  }
1235
1244
  );
@@ -1243,28 +1252,23 @@ var CurrencyInput = React13.forwardRef(
1243
1252
  name,
1244
1253
  onChange,
1245
1254
  label,
1255
+ error,
1256
+ helperText,
1246
1257
  required,
1247
1258
  disabled,
1248
1259
  ...innerProps
1249
1260
  } = props;
1250
- const [value, setValue] = useState3(props.value);
1251
- const [error, setError] = useState3(props.error);
1252
- const [helperText, setHelperText] = useState3(props.helperText);
1261
+ const [isOverLimit, setIsOverLimit] = useState3(
1262
+ !!props.value && props.value > max
1263
+ );
1253
1264
  const handleChange = useCallback3(
1254
1265
  (event) => {
1255
1266
  const amount = Number(event.target.value);
1256
- setValue(amount);
1257
1267
  onChange?.({ ...event, target: { name, value: amount } });
1258
1268
  if (amount > max) {
1259
- setError(true);
1260
- setHelperText(
1261
- /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(InfoOutlined, null), new IntlMessageFormat(
1262
- `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
1263
- ).format({ amount: max }))
1264
- );
1269
+ setIsOverLimit(true);
1265
1270
  } else {
1266
- setError(props.error);
1267
- setHelperText(props.helperText);
1271
+ setIsOverLimit(false);
1268
1272
  }
1269
1273
  },
1270
1274
  []
@@ -1274,7 +1278,6 @@ var CurrencyInput = React13.forwardRef(
1274
1278
  {
1275
1279
  size: "sm",
1276
1280
  ref,
1277
- value: String(value),
1278
1281
  onChange: handleChange,
1279
1282
  disabled,
1280
1283
  required,
@@ -1292,17 +1295,18 @@ var CurrencyInput = React13.forwardRef(
1292
1295
  size: "sm",
1293
1296
  disabled,
1294
1297
  required,
1295
- error
1298
+ error: error || isOverLimit
1296
1299
  },
1297
1300
  /* @__PURE__ */ React13.createElement(FormLabel_default, null, label),
1298
1301
  currencyFormatter,
1299
- helperText && /* @__PURE__ */ React13.createElement(FormHelperText_default, null, helperText)
1302
+ isOverLimit ? /* @__PURE__ */ React13.createElement(FormHelperText_default, null, /* @__PURE__ */ React13.createElement(InfoOutlined, null), new IntlMessageFormat(
1303
+ `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
1304
+ ).format({ amount: max })) : helperText && /* @__PURE__ */ React13.createElement(FormHelperText_default, null, helperText)
1300
1305
  );
1301
1306
  }
1302
1307
  return currencyFormatter;
1303
1308
  }
1304
1309
  );
1305
- CurrencyInput.displayName = "CurrencyInput";
1306
1310
 
1307
1311
  // src/components/DataTable/DataTable.tsx
1308
1312
  import React15, {
@@ -1883,7 +1887,7 @@ var CalendarSheet = styled6(Sheet_default, {
1883
1887
  boxShadow: theme.shadow.md,
1884
1888
  borderRadius: theme.radius.md
1885
1889
  }));
1886
- var formatValueString = (date) => {
1890
+ var formatValueString2 = (date) => {
1887
1891
  let day = `${date.getDate()}`;
1888
1892
  let month = `${date.getMonth() + 1}`;
1889
1893
  const year = date.getFullYear();
@@ -1923,7 +1927,7 @@ var TextMaskAdapter3 = React16.forwardRef(
1923
1927
  to: 9999
1924
1928
  }
1925
1929
  },
1926
- format: formatValueString,
1930
+ format: formatValueString2,
1927
1931
  parse: (str) => {
1928
1932
  const yearMonthDay = str.split("/");
1929
1933
  return new Date(
@@ -2007,7 +2011,7 @@ var DatePicker = forwardRef4(
2007
2011
  {
2008
2012
  value: !Number.isNaN(new Date(value).getTime()) ? [new Date(value), void 0] : void 0,
2009
2013
  onChange: ([date]) => {
2010
- setValue(formatValueString(date));
2014
+ setValue(formatValueString2(date));
2011
2015
  setAnchorEl(null);
2012
2016
  },
2013
2017
  minDate: minDate ? new Date(minDate) : void 0,
@@ -2078,7 +2082,7 @@ var CalendarSheet2 = styled7(Sheet_default, {
2078
2082
  boxShadow: theme.shadow.md,
2079
2083
  borderRadius: theme.radius.md
2080
2084
  }));
2081
- var formatValueString2 = ([date1, date2]) => {
2085
+ var formatValueString3 = ([date1, date2]) => {
2082
2086
  const getStr = (date) => {
2083
2087
  let day = `${date.getDate()}`;
2084
2088
  let month = `${date.getMonth() + 1}`;
@@ -2139,7 +2143,7 @@ var TextMaskAdapter5 = React17.forwardRef(
2139
2143
  to: 9999
2140
2144
  }
2141
2145
  },
2142
- format: formatValueString2,
2146
+ format: formatValueString3,
2143
2147
  parse: parseDate,
2144
2148
  autofix: "pad",
2145
2149
  overwrite: true,
@@ -2186,7 +2190,7 @@ var DateRangePicker = forwardRef5(
2186
2190
  ([date1, date2]) => {
2187
2191
  if (!date1 || !date2)
2188
2192
  return;
2189
- setValue(formatValueString2([date1, date2]));
2193
+ setValue(formatValueString3([date1, date2]));
2190
2194
  setAnchorEl(null);
2191
2195
  },
2192
2196
  [setValue, setAnchorEl]
@@ -2403,7 +2407,7 @@ var CalendarSheet3 = styled12(Sheet_default, {
2403
2407
  boxShadow: theme.shadow.md,
2404
2408
  borderRadius: theme.radius.md
2405
2409
  }));
2406
- var formatValueString3 = ([date1, date2]) => {
2410
+ var formatValueString4 = ([date1, date2]) => {
2407
2411
  const getStr = (date) => {
2408
2412
  let month = `${date.getMonth() + 1}`;
2409
2413
  const year = date.getFullYear();
@@ -2447,7 +2451,7 @@ var TextMaskAdapter7 = React22.forwardRef(
2447
2451
  to: 9999
2448
2452
  }
2449
2453
  },
2450
- format: formatValueString3,
2454
+ format: formatValueString4,
2451
2455
  parse: parseDate2,
2452
2456
  autofix: "pad",
2453
2457
  overwrite: true,
@@ -2494,7 +2498,7 @@ var MonthRangePicker = forwardRef6(
2494
2498
  ([date1, date2]) => {
2495
2499
  if (!date1 || !date2)
2496
2500
  return;
2497
- setValue(formatValueString3([date1, date2]));
2501
+ setValue(formatValueString4([date1, date2]));
2498
2502
  setAnchorEl(null);
2499
2503
  },
2500
2504
  [setValue, setAnchorEl]
package/framer/index.js CHANGED
@@ -43595,25 +43595,34 @@ function getCurrencySymbol(currencyCode) {
43595
43595
  }).format(0);
43596
43596
  return formatted.replace(/[\d\s.,]/g, "");
43597
43597
  }
43598
+ function formatValueString(amount, currency = "usd") {
43599
+ const formatter = new IntlMessageFormat(
43600
+ `{amount, number, ::currency/${currency} unit-width-narrow}`
43601
+ );
43602
+ return formatter.format({ amount }).toString();
43603
+ }
43598
43604
  var TextMaskAdapter = React178.forwardRef(
43599
43605
  function TextMaskAdapter2(props, ref) {
43600
- var _b;
43601
43606
  const _a2 = props, { onChange, currency } = _a2, innerProps = __objRest(_a2, ["onChange", "currency"]);
43607
+ const [value, setValue] = useState26(props.value || 0);
43602
43608
  const currencySymbol = getCurrencySymbol(currency);
43603
43609
  return /* @__PURE__ */ jsx2(
43604
43610
  IMaskInput,
43605
43611
  __spreadProps(__spreadValues({}, innerProps), {
43606
43612
  inputRef: ref,
43607
43613
  mask: `${currencySymbol}num`,
43608
- onAccept: (value) => {
43614
+ lazy: false,
43615
+ overwrite: true,
43616
+ onAccept: (value2) => {
43617
+ setValue(Number(value2));
43609
43618
  onChange({
43610
43619
  target: {
43611
43620
  name: props.name,
43612
- value
43621
+ value: value2
43613
43622
  }
43614
43623
  });
43615
43624
  },
43616
- value: (_b = props.value) == null ? void 0 : _b.toString(),
43625
+ value: formatValueString(value, currency),
43617
43626
  unmask: true,
43618
43627
  blocks: {
43619
43628
  num: {
@@ -43625,7 +43634,6 @@ var TextMaskAdapter = React178.forwardRef(
43625
43634
  padFractionalZeros: currency !== "krw"
43626
43635
  }
43627
43636
  },
43628
- placeholderChar: currencySymbol,
43629
43637
  placeholder: `${currencySymbol}0.00`
43630
43638
  })
43631
43639
  );
@@ -43639,6 +43647,8 @@ var CurrencyInput = React178.forwardRef(
43639
43647
  name,
43640
43648
  onChange,
43641
43649
  label,
43650
+ error,
43651
+ helperText,
43642
43652
  required,
43643
43653
  disabled
43644
43654
  } = _a2, innerProps = __objRest(_a2, [
@@ -43647,30 +43657,22 @@ var CurrencyInput = React178.forwardRef(
43647
43657
  "name",
43648
43658
  "onChange",
43649
43659
  "label",
43660
+ "error",
43661
+ "helperText",
43650
43662
  "required",
43651
43663
  "disabled"
43652
43664
  ]);
43653
- const [value, setValue] = useState26(props.value);
43654
- const [error, setError] = useState26(props.error);
43655
- const [helperText, setHelperText] = useState26(props.helperText);
43665
+ const [isOverLimit, setIsOverLimit] = useState26(
43666
+ !!props.value && props.value > max2
43667
+ );
43656
43668
  const handleChange = useCallback27(
43657
43669
  (event) => {
43658
43670
  const amount = Number(event.target.value);
43659
- setValue(amount);
43660
43671
  onChange == null ? void 0 : onChange(__spreadProps(__spreadValues({}, event), { target: { name, value: amount } }));
43661
43672
  if (amount > max2) {
43662
- setError(true);
43663
- setHelperText(
43664
- /* @__PURE__ */ jsxs2(Fragment16, { children: [
43665
- /* @__PURE__ */ jsx2(InfoOutlined_default, {}),
43666
- new IntlMessageFormat(
43667
- `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
43668
- ).format({ amount: max2 })
43669
- ] })
43670
- );
43673
+ setIsOverLimit(true);
43671
43674
  } else {
43672
- setError(props.error);
43673
- setHelperText(props.helperText);
43675
+ setIsOverLimit(false);
43674
43676
  }
43675
43677
  },
43676
43678
  []
@@ -43680,7 +43682,6 @@ var CurrencyInput = React178.forwardRef(
43680
43682
  __spreadValues({
43681
43683
  size: "sm",
43682
43684
  ref,
43683
- value: String(value),
43684
43685
  onChange: handleChange,
43685
43686
  disabled,
43686
43687
  required,
@@ -43697,11 +43698,16 @@ var CurrencyInput = React178.forwardRef(
43697
43698
  size: "sm",
43698
43699
  disabled,
43699
43700
  required,
43700
- error,
43701
+ error: error || isOverLimit,
43701
43702
  children: [
43702
43703
  /* @__PURE__ */ jsx2(FormLabel_default2, { children: label }),
43703
43704
  currencyFormatter,
43704
- helperText && /* @__PURE__ */ jsx2(FormHelperText_default2, { children: helperText })
43705
+ isOverLimit ? /* @__PURE__ */ jsxs2(FormHelperText_default2, { children: [
43706
+ /* @__PURE__ */ jsx2(InfoOutlined_default, {}),
43707
+ new IntlMessageFormat(
43708
+ `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
43709
+ ).format({ amount: max2 })
43710
+ ] }) : helperText && /* @__PURE__ */ jsx2(FormHelperText_default2, { children: helperText })
43705
43711
  ]
43706
43712
  }
43707
43713
  );
@@ -43709,7 +43715,6 @@ var CurrencyInput = React178.forwardRef(
43709
43715
  return currencyFormatter;
43710
43716
  }
43711
43717
  );
43712
- CurrencyInput.displayName = "CurrencyInput";
43713
43718
 
43714
43719
  // src/components/DataTable/DataTable.tsx
43715
43720
  import {
@@ -44366,7 +44371,7 @@ var CalendarSheet = styled_default2(Sheet_default2, {
44366
44371
  boxShadow: theme.shadow.md,
44367
44372
  borderRadius: theme.radius.md
44368
44373
  }));
44369
- var formatValueString = (date) => {
44374
+ var formatValueString2 = (date) => {
44370
44375
  let day = `${date.getDate()}`;
44371
44376
  let month = `${date.getMonth() + 1}`;
44372
44377
  const year = date.getFullYear();
@@ -44405,7 +44410,7 @@ var TextMaskAdapter3 = React180.forwardRef(
44405
44410
  to: 9999
44406
44411
  }
44407
44412
  },
44408
- format: formatValueString,
44413
+ format: formatValueString2,
44409
44414
  parse: (str) => {
44410
44415
  const yearMonthDay = str.split("/");
44411
44416
  return new Date(
@@ -44491,7 +44496,7 @@ var DatePicker = forwardRef84(
44491
44496
  {
44492
44497
  value: !Number.isNaN(new Date(value).getTime()) ? [new Date(value), void 0] : void 0,
44493
44498
  onChange: ([date]) => {
44494
- setValue(formatValueString(date));
44499
+ setValue(formatValueString2(date));
44495
44500
  setAnchorEl(null);
44496
44501
  },
44497
44502
  minDate: minDate ? new Date(minDate) : void 0,
@@ -44564,7 +44569,7 @@ var CalendarSheet2 = styled_default2(Sheet_default2, {
44564
44569
  boxShadow: theme.shadow.md,
44565
44570
  borderRadius: theme.radius.md
44566
44571
  }));
44567
- var formatValueString2 = ([date1, date2]) => {
44572
+ var formatValueString3 = ([date1, date2]) => {
44568
44573
  const getStr = (date) => {
44569
44574
  let day = `${date.getDate()}`;
44570
44575
  let month = `${date.getMonth() + 1}`;
@@ -44624,7 +44629,7 @@ var TextMaskAdapter5 = React181.forwardRef(
44624
44629
  to: 9999
44625
44630
  }
44626
44631
  },
44627
- format: formatValueString2,
44632
+ format: formatValueString3,
44628
44633
  parse: parseDate,
44629
44634
  autofix: "pad",
44630
44635
  overwrite: true,
@@ -44671,7 +44676,7 @@ var DateRangePicker = forwardRef85(
44671
44676
  ([date1, date2]) => {
44672
44677
  if (!date1 || !date2)
44673
44678
  return;
44674
- setValue(formatValueString2([date1, date2]));
44679
+ setValue(formatValueString3([date1, date2]));
44675
44680
  setAnchorEl(null);
44676
44681
  },
44677
44682
  [setValue, setAnchorEl]
@@ -44881,7 +44886,7 @@ var CalendarSheet3 = styled_default2(Sheet_default2, {
44881
44886
  boxShadow: theme.shadow.md,
44882
44887
  borderRadius: theme.radius.md
44883
44888
  }));
44884
- var formatValueString3 = ([date1, date2]) => {
44889
+ var formatValueString4 = ([date1, date2]) => {
44885
44890
  const getStr = (date) => {
44886
44891
  let month = `${date.getMonth() + 1}`;
44887
44892
  const year = date.getFullYear();
@@ -44924,7 +44929,7 @@ var TextMaskAdapter7 = React182.forwardRef(
44924
44929
  to: 9999
44925
44930
  }
44926
44931
  },
44927
- format: formatValueString3,
44932
+ format: formatValueString4,
44928
44933
  parse: parseDate2,
44929
44934
  autofix: "pad",
44930
44935
  overwrite: true,
@@ -44971,7 +44976,7 @@ var MonthRangePicker = forwardRef86(
44971
44976
  ([date1, date2]) => {
44972
44977
  if (!date1 || !date2)
44973
44978
  return;
44974
- setValue(formatValueString3([date1, date2]));
44979
+ setValue(formatValueString4([date1, date2]));
44975
44980
  setAnchorEl(null);
44976
44981
  },
44977
44982
  [setValue, setAnchorEl]
@@ -45687,6 +45692,11 @@ var currencyInputPropertyControls = {
45687
45692
  type: ControlType10.Boolean,
45688
45693
  defaultValue: false
45689
45694
  },
45695
+ value: {
45696
+ title: "Value",
45697
+ type: ControlType10.Number,
45698
+ defaultValue: void 0
45699
+ },
45690
45700
  onChange: {
45691
45701
  type: ControlType10.EventHandler
45692
45702
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceed/ads",
3
- "version": "0.0.85",
3
+ "version": "0.0.87",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",