@ceed/ads 0.0.92 → 0.0.93

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
@@ -1182,7 +1182,7 @@ Container.displayName = "Container";
1182
1182
  // src/components/CurrencyInput/CurrencyInput.tsx
1183
1183
  import React14, { useCallback as useCallback3, useState as useState3 } from "react";
1184
1184
  import { IntlMessageFormat } from "intl-messageformat";
1185
- import { IMaskInput } from "react-imask";
1185
+ import { IMask, IMaskInput } from "react-imask";
1186
1186
  import InfoOutlined from "@mui/icons-material/esm/InfoOutlined.js";
1187
1187
 
1188
1188
  // src/components/Input/Input.tsx
@@ -1234,115 +1234,119 @@ Input.displayName = "Input";
1234
1234
  var Input_default = Input;
1235
1235
 
1236
1236
  // src/components/CurrencyInput/CurrencyInput.tsx
1237
- function getCurrencySymbol(currencyCode) {
1238
- const formatted = new Intl.NumberFormat("en-us", {
1239
- style: "currency",
1240
- currency: currencyCode
1241
- }).format(0);
1242
- return formatted.replace(/[\d\s.,]/g, "");
1237
+ function formatCurrency(value, currencyCode = "usd") {
1238
+ const formatter = new IntlMessageFormat(
1239
+ `{amount, number, ::currency/${currencyCode} unit-width-narrow}`
1240
+ );
1241
+ const amount = value || 0;
1242
+ const formatted = formatter.format({ amount }).toString();
1243
+ const symbol = formatted.replace(/[0-9.,]/g, "").trim();
1244
+ const formattedAmount = formatted.replace(symbol, "").trim();
1245
+ return {
1246
+ symbol,
1247
+ amount,
1248
+ formattedAmount
1249
+ };
1243
1250
  }
1244
1251
  var TextMaskAdapter = React14.forwardRef(
1245
1252
  function TextMaskAdapter2(props, ref) {
1246
1253
  const { onChange, currency, ...innerProps } = props;
1247
- const [value, setValue] = useState3(props.value || 0);
1248
- const currencySymbol = getCurrencySymbol(currency);
1254
+ const [formatted, setFormatted] = useState3(formatCurrency(props.value, currency));
1249
1255
  return /* @__PURE__ */ React14.createElement(
1250
1256
  IMaskInput,
1251
1257
  {
1252
1258
  ...innerProps,
1253
1259
  inputRef: ref,
1254
- mask: `${currencySymbol}num`,
1255
- lazy: false,
1256
- overwrite: true,
1257
- onAccept: (value2) => {
1258
- setValue(Number(value2));
1260
+ onAccept: (value) => {
1261
+ const unmaskedValue = value.replace(/[^\d\.]/g, "");
1262
+ setFormatted(formatCurrency(Number(unmaskedValue), currency));
1259
1263
  onChange({
1260
1264
  target: {
1261
1265
  name: props.name,
1262
- value: value2
1266
+ value: unmaskedValue
1263
1267
  }
1264
1268
  });
1265
1269
  },
1266
- value: value.toString(),
1267
- unmask: true,
1270
+ mask: `${formatted.symbol} integer\`.float`,
1268
1271
  blocks: {
1269
- num: {
1272
+ integer: {
1270
1273
  mask: Number,
1271
- thousandsSeparator: ",",
1272
- radix: ".",
1273
- expose: true,
1274
- scale: 2,
1275
- padFractionalZeros: currency !== "krw"
1274
+ thousandsSeparator: ","
1275
+ },
1276
+ float: {
1277
+ mask: IMask.MaskedRange,
1278
+ from: 0,
1279
+ to: 99,
1280
+ maxLength: 2
1276
1281
  }
1277
1282
  },
1278
- placeholder: `${currencySymbol}0.00`
1283
+ value: formatted.formattedAmount,
1284
+ overwrite: "shift"
1279
1285
  }
1280
1286
  );
1281
1287
  }
1282
1288
  );
1283
- var CurrencyInput = React14.forwardRef(
1284
- function CurrencyInput2(props, ref) {
1285
- const {
1286
- currency = "usd",
1287
- max = 1e5,
1288
- name,
1289
- onChange,
1290
- label,
1291
- error,
1292
- helperText,
1293
- required,
1289
+ var CurrencyInput = React14.forwardRef(function CurrencyInput2(props, ref) {
1290
+ const {
1291
+ currency = "usd",
1292
+ max = 1e5,
1293
+ name,
1294
+ onChange,
1295
+ label,
1296
+ error,
1297
+ helperText,
1298
+ required,
1299
+ disabled,
1300
+ ...innerProps
1301
+ } = props;
1302
+ const [isOverLimit, setIsOverLimit] = useState3(
1303
+ !!props.value && props.value > Number(max)
1304
+ );
1305
+ const handleChange = useCallback3(
1306
+ (event) => {
1307
+ const amount = Number(event.target.value);
1308
+ onChange?.({ ...event, target: { name, value: amount } });
1309
+ if (amount > Number(max)) {
1310
+ setIsOverLimit(true);
1311
+ } else {
1312
+ setIsOverLimit(false);
1313
+ }
1314
+ },
1315
+ []
1316
+ );
1317
+ const currencyFormatter = /* @__PURE__ */ React14.createElement(
1318
+ Input_default,
1319
+ {
1320
+ size: "sm",
1321
+ ref,
1322
+ onChange: handleChange,
1294
1323
  disabled,
1295
- ...innerProps
1296
- } = props;
1297
- const [isOverLimit, setIsOverLimit] = useState3(
1298
- !!props.value && props.value > Number(max)
1299
- );
1300
- const handleChange = useCallback3(
1301
- (event) => {
1302
- const amount = Number(event.target.value);
1303
- onChange?.({ ...event, target: { name, value: amount } });
1304
- if (amount > Number(max)) {
1305
- setIsOverLimit(true);
1306
- } else {
1307
- setIsOverLimit(false);
1308
- }
1324
+ required,
1325
+ slotProps: { input: { component: TextMaskAdapter, currency } },
1326
+ sx: {
1327
+ fontFamily: "monospace"
1309
1328
  },
1310
- []
1311
- );
1312
- const currencyFormatter = /* @__PURE__ */ React14.createElement(
1313
- Input_default,
1329
+ ...innerProps
1330
+ }
1331
+ );
1332
+ if (label) {
1333
+ return /* @__PURE__ */ React14.createElement(
1334
+ FormControl_default,
1314
1335
  {
1315
1336
  size: "sm",
1316
- ref,
1317
- onChange: handleChange,
1318
1337
  disabled,
1319
1338
  required,
1320
- slotProps: { input: { component: TextMaskAdapter, currency, max } },
1321
- sx: {
1322
- fontFamily: "monospace"
1323
- },
1324
- ...innerProps
1325
- }
1339
+ error: error || isOverLimit
1340
+ },
1341
+ /* @__PURE__ */ React14.createElement(FormLabel_default, null, label),
1342
+ currencyFormatter,
1343
+ isOverLimit ? /* @__PURE__ */ React14.createElement(FormHelperText_default, null, /* @__PURE__ */ React14.createElement(InfoOutlined, null), new IntlMessageFormat(
1344
+ `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
1345
+ ).format({ amount: max })) : helperText && /* @__PURE__ */ React14.createElement(FormHelperText_default, null, helperText)
1326
1346
  );
1327
- if (label) {
1328
- return /* @__PURE__ */ React14.createElement(
1329
- FormControl_default,
1330
- {
1331
- size: "sm",
1332
- disabled,
1333
- required,
1334
- error: error || isOverLimit
1335
- },
1336
- /* @__PURE__ */ React14.createElement(FormLabel_default, null, label),
1337
- currencyFormatter,
1338
- isOverLimit ? /* @__PURE__ */ React14.createElement(FormHelperText_default, null, /* @__PURE__ */ React14.createElement(InfoOutlined, null), new IntlMessageFormat(
1339
- `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
1340
- ).format({ amount: max })) : helperText && /* @__PURE__ */ React14.createElement(FormHelperText_default, null, helperText)
1341
- );
1342
- }
1343
- return currencyFormatter;
1344
1347
  }
1345
- );
1348
+ return currencyFormatter;
1349
+ });
1346
1350
 
1347
1351
  // src/components/DataTable/DataTable.tsx
1348
1352
  import React16, {
@@ -1876,7 +1880,7 @@ DataTable.displayName = "DataTable";
1876
1880
 
1877
1881
  // src/components/DatePicker/DatePicker.tsx
1878
1882
  import React17, { forwardRef as forwardRef4, useCallback as useCallback5, useState as useState5 } from "react";
1879
- import { IMaskInput as IMaskInput2, IMask } from "react-imask";
1883
+ import { IMaskInput as IMaskInput2, IMask as IMask2 } from "react-imask";
1880
1884
  import CalendarTodayIcon from "@mui/icons-material/esm/CalendarToday.js";
1881
1885
  import { styled as styled6 } from "@mui/joy";
1882
1886
  import { FocusTrap, ClickAwayListener, Popper } from "@mui/base";
@@ -1936,19 +1940,19 @@ var TextMaskAdapter3 = React17.forwardRef(
1936
1940
  pattern: "Y/`m/`d",
1937
1941
  blocks: {
1938
1942
  d: {
1939
- mask: IMask.MaskedRange,
1943
+ mask: IMask2.MaskedRange,
1940
1944
  from: 1,
1941
1945
  to: 31,
1942
1946
  maxLength: 2
1943
1947
  },
1944
1948
  m: {
1945
- mask: IMask.MaskedRange,
1949
+ mask: IMask2.MaskedRange,
1946
1950
  from: 1,
1947
1951
  to: 12,
1948
1952
  maxLength: 2
1949
1953
  },
1950
1954
  Y: {
1951
- mask: IMask.MaskedRange,
1955
+ mask: IMask2.MaskedRange,
1952
1956
  from: 1900,
1953
1957
  to: 9999
1954
1958
  }
@@ -2088,7 +2092,7 @@ DatePicker.displayName = "DatePicker";
2088
2092
 
2089
2093
  // src/components/DateRangePicker/DateRangePicker.tsx
2090
2094
  import React18, { forwardRef as forwardRef5, useCallback as useCallback6, useMemo as useMemo4, useState as useState6 } from "react";
2091
- import { IMaskInput as IMaskInput3, IMask as IMask2 } from "react-imask";
2095
+ import { IMaskInput as IMaskInput3, IMask as IMask3 } from "react-imask";
2092
2096
  import CalendarTodayIcon2 from "@mui/icons-material/esm/CalendarToday.js";
2093
2097
  import { styled as styled7 } from "@mui/joy";
2094
2098
  import { FocusTrap as FocusTrap2, ClickAwayListener as ClickAwayListener2, Popper as Popper2 } from "@mui/base";
@@ -2152,19 +2156,19 @@ var TextMaskAdapter5 = React18.forwardRef(
2152
2156
  pattern: "Y/`m/`d - Y/`m/`d",
2153
2157
  blocks: {
2154
2158
  d: {
2155
- mask: IMask2.MaskedRange,
2159
+ mask: IMask3.MaskedRange,
2156
2160
  from: 1,
2157
2161
  to: 31,
2158
2162
  maxLength: 2
2159
2163
  },
2160
2164
  m: {
2161
- mask: IMask2.MaskedRange,
2165
+ mask: IMask3.MaskedRange,
2162
2166
  from: 1,
2163
2167
  to: 12,
2164
2168
  maxLength: 2
2165
2169
  },
2166
2170
  Y: {
2167
- mask: IMask2.MaskedRange,
2171
+ mask: IMask3.MaskedRange,
2168
2172
  from: 1900,
2169
2173
  to: 9999
2170
2174
  }
@@ -2413,7 +2417,7 @@ Grid.displayName = "Grid";
2413
2417
 
2414
2418
  // src/components/MonthRangePicker/MonthRangePicker.tsx
2415
2419
  import React23, { forwardRef as forwardRef6, useCallback as useCallback7, useMemo as useMemo5, useState as useState7 } from "react";
2416
- import { IMaskInput as IMaskInput4, IMask as IMask3 } from "react-imask";
2420
+ import { IMaskInput as IMaskInput4, IMask as IMask4 } from "react-imask";
2417
2421
  import CalendarTodayIcon3 from "@mui/icons-material/esm/CalendarToday.js";
2418
2422
  import { styled as styled12 } from "@mui/joy";
2419
2423
  import { FocusTrap as FocusTrap3, ClickAwayListener as ClickAwayListener3, Popper as Popper3 } from "@mui/base";
@@ -2466,13 +2470,13 @@ var TextMaskAdapter7 = React23.forwardRef(
2466
2470
  pattern: "Y/`m - Y/`m",
2467
2471
  blocks: {
2468
2472
  m: {
2469
- mask: IMask3.MaskedRange,
2473
+ mask: IMask4.MaskedRange,
2470
2474
  from: 1,
2471
2475
  to: 12,
2472
2476
  maxLength: 2
2473
2477
  },
2474
2478
  Y: {
2475
- mask: IMask3.MaskedRange,
2479
+ mask: IMask4.MaskedRange,
2476
2480
  from: 1900,
2477
2481
  to: 9999
2478
2482
  }
package/framer/index.js CHANGED
@@ -43871,127 +43871,131 @@ Input3.displayName = "Input";
43871
43871
  var Input_default2 = Input3;
43872
43872
 
43873
43873
  // src/components/CurrencyInput/CurrencyInput.tsx
43874
- function getCurrencySymbol(currencyCode) {
43875
- const formatted = new Intl.NumberFormat("en-us", {
43876
- style: "currency",
43877
- currency: currencyCode
43878
- }).format(0);
43879
- return formatted.replace(/[\d\s.,]/g, "");
43874
+ function formatCurrency(value, currencyCode = "usd") {
43875
+ const formatter = new IntlMessageFormat(
43876
+ `{amount, number, ::currency/${currencyCode} unit-width-narrow}`
43877
+ );
43878
+ const amount = value || 0;
43879
+ const formatted = formatter.format({ amount }).toString();
43880
+ const symbol = formatted.replace(/[0-9.,]/g, "").trim();
43881
+ const formattedAmount = formatted.replace(symbol, "").trim();
43882
+ return {
43883
+ symbol,
43884
+ amount,
43885
+ formattedAmount
43886
+ };
43880
43887
  }
43881
43888
  var TextMaskAdapter = React179.forwardRef(
43882
43889
  function TextMaskAdapter2(props, ref) {
43883
43890
  const _a2 = props, { onChange, currency } = _a2, innerProps = __objRest(_a2, ["onChange", "currency"]);
43884
- const [value, setValue] = useState26(props.value || 0);
43885
- const currencySymbol = getCurrencySymbol(currency);
43891
+ const [formatted, setFormatted] = useState26(formatCurrency(props.value, currency));
43886
43892
  return /* @__PURE__ */ jsx2(
43887
43893
  IMaskInput,
43888
43894
  __spreadProps(__spreadValues({}, innerProps), {
43889
43895
  inputRef: ref,
43890
- mask: `${currencySymbol}num`,
43891
- lazy: false,
43892
- overwrite: true,
43893
- onAccept: (value2) => {
43894
- setValue(Number(value2));
43896
+ onAccept: (value) => {
43897
+ const unmaskedValue = value.replace(/[^\d\.]/g, "");
43898
+ setFormatted(formatCurrency(Number(unmaskedValue), currency));
43895
43899
  onChange({
43896
43900
  target: {
43897
43901
  name: props.name,
43898
- value: value2
43902
+ value: unmaskedValue
43899
43903
  }
43900
43904
  });
43901
43905
  },
43902
- value: value.toString(),
43903
- unmask: true,
43906
+ mask: `${formatted.symbol} integer\`.float`,
43904
43907
  blocks: {
43905
- num: {
43908
+ integer: {
43906
43909
  mask: Number,
43907
- thousandsSeparator: ",",
43908
- radix: ".",
43909
- expose: true,
43910
- scale: 2,
43911
- padFractionalZeros: currency !== "krw"
43910
+ thousandsSeparator: ","
43911
+ },
43912
+ float: {
43913
+ mask: IMask.MaskedRange,
43914
+ from: 0,
43915
+ to: 99,
43916
+ maxLength: 2
43912
43917
  }
43913
43918
  },
43914
- placeholder: `${currencySymbol}0.00`
43919
+ value: formatted.formattedAmount,
43920
+ overwrite: "shift"
43915
43921
  })
43916
43922
  );
43917
43923
  }
43918
43924
  );
43919
- var CurrencyInput = React179.forwardRef(
43920
- function CurrencyInput2(props, ref) {
43921
- const _a2 = props, {
43922
- currency = "usd",
43923
- max: max2 = 1e5,
43924
- name,
43925
- onChange,
43926
- label,
43927
- error,
43928
- helperText,
43925
+ var CurrencyInput = React179.forwardRef(function CurrencyInput2(props, ref) {
43926
+ const _a2 = props, {
43927
+ currency = "usd",
43928
+ max: max2 = 1e5,
43929
+ name,
43930
+ onChange,
43931
+ label,
43932
+ error,
43933
+ helperText,
43934
+ required,
43935
+ disabled
43936
+ } = _a2, innerProps = __objRest(_a2, [
43937
+ "currency",
43938
+ "max",
43939
+ "name",
43940
+ "onChange",
43941
+ "label",
43942
+ "error",
43943
+ "helperText",
43944
+ "required",
43945
+ "disabled"
43946
+ ]);
43947
+ const [isOverLimit, setIsOverLimit] = useState26(
43948
+ !!props.value && props.value > Number(max2)
43949
+ );
43950
+ const handleChange = useCallback27(
43951
+ (event) => {
43952
+ const amount = Number(event.target.value);
43953
+ onChange == null ? void 0 : onChange(__spreadProps(__spreadValues({}, event), { target: { name, value: amount } }));
43954
+ if (amount > Number(max2)) {
43955
+ setIsOverLimit(true);
43956
+ } else {
43957
+ setIsOverLimit(false);
43958
+ }
43959
+ },
43960
+ []
43961
+ );
43962
+ const currencyFormatter = /* @__PURE__ */ jsx2(
43963
+ Input_default2,
43964
+ __spreadValues({
43965
+ size: "sm",
43966
+ ref,
43967
+ onChange: handleChange,
43968
+ disabled,
43929
43969
  required,
43930
- disabled
43931
- } = _a2, innerProps = __objRest(_a2, [
43932
- "currency",
43933
- "max",
43934
- "name",
43935
- "onChange",
43936
- "label",
43937
- "error",
43938
- "helperText",
43939
- "required",
43940
- "disabled"
43941
- ]);
43942
- const [isOverLimit, setIsOverLimit] = useState26(
43943
- !!props.value && props.value > Number(max2)
43944
- );
43945
- const handleChange = useCallback27(
43946
- (event) => {
43947
- const amount = Number(event.target.value);
43948
- onChange == null ? void 0 : onChange(__spreadProps(__spreadValues({}, event), { target: { name, value: amount } }));
43949
- if (amount > Number(max2)) {
43950
- setIsOverLimit(true);
43951
- } else {
43952
- setIsOverLimit(false);
43953
- }
43954
- },
43955
- []
43956
- );
43957
- const currencyFormatter = /* @__PURE__ */ jsx2(
43958
- Input_default2,
43959
- __spreadValues({
43970
+ slotProps: { input: { component: TextMaskAdapter, currency } },
43971
+ sx: {
43972
+ fontFamily: "monospace"
43973
+ }
43974
+ }, innerProps)
43975
+ );
43976
+ if (label) {
43977
+ return /* @__PURE__ */ jsxs2(
43978
+ FormControl_default2,
43979
+ {
43960
43980
  size: "sm",
43961
- ref,
43962
- onChange: handleChange,
43963
43981
  disabled,
43964
43982
  required,
43965
- slotProps: { input: { component: TextMaskAdapter, currency, max: max2 } },
43966
- sx: {
43967
- fontFamily: "monospace"
43968
- }
43969
- }, innerProps)
43983
+ error: error || isOverLimit,
43984
+ children: [
43985
+ /* @__PURE__ */ jsx2(FormLabel_default2, { children: label }),
43986
+ currencyFormatter,
43987
+ isOverLimit ? /* @__PURE__ */ jsxs2(FormHelperText_default2, { children: [
43988
+ /* @__PURE__ */ jsx2(InfoOutlined_default, {}),
43989
+ new IntlMessageFormat(
43990
+ `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
43991
+ ).format({ amount: max2 })
43992
+ ] }) : helperText && /* @__PURE__ */ jsx2(FormHelperText_default2, { children: helperText })
43993
+ ]
43994
+ }
43970
43995
  );
43971
- if (label) {
43972
- return /* @__PURE__ */ jsxs2(
43973
- FormControl_default2,
43974
- {
43975
- size: "sm",
43976
- disabled,
43977
- required,
43978
- error: error || isOverLimit,
43979
- children: [
43980
- /* @__PURE__ */ jsx2(FormLabel_default2, { children: label }),
43981
- currencyFormatter,
43982
- isOverLimit ? /* @__PURE__ */ jsxs2(FormHelperText_default2, { children: [
43983
- /* @__PURE__ */ jsx2(InfoOutlined_default, {}),
43984
- new IntlMessageFormat(
43985
- `limit: {amount, number, ::currency/${currency} unit-width-narrow}`
43986
- ).format({ amount: max2 })
43987
- ] }) : helperText && /* @__PURE__ */ jsx2(FormHelperText_default2, { children: helperText })
43988
- ]
43989
- }
43990
- );
43991
- }
43992
- return currencyFormatter;
43993
43996
  }
43994
- );
43997
+ return currencyFormatter;
43998
+ });
43995
43999
 
43996
44000
  // src/components/DataTable/DataTable.tsx
43997
44001
  import {
@@ -46020,8 +46024,7 @@ var currencyInputPropertyControls = {
46020
46024
  },
46021
46025
  max: {
46022
46026
  title: "Max",
46023
- type: ControlType11.Number,
46024
- defaultValue: void 0
46027
+ type: ControlType11.String
46025
46028
  }
46026
46029
  };
46027
46030
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceed/ads",
3
- "version": "0.0.92",
3
+ "version": "0.0.93",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",