@clickpalm/react 1.3.7 → 1.3.9

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.d.ts CHANGED
@@ -4136,6 +4136,7 @@ declare const Carousel: react__default.FC<CarouselProps> & {
4136
4136
  interface CarouselItemProps {
4137
4137
  children: ReactNode;
4138
4138
  style?: CSSProperties;
4139
+ title?: string | null | undefined;
4139
4140
  }
4140
4141
 
4141
4142
  type PasswordInputProps = Omit<TextInputProps, 'type' | 'suffix'>;
package/dist/index.js CHANGED
@@ -1341,14 +1341,32 @@ var Input2 = (0, import_react5.forwardRef)(
1341
1341
  return stringValue;
1342
1342
  };
1343
1343
  const [displayValue, setDisplayValue] = (0, import_react5.useState)(getDisplayValue(props.value));
1344
- const [charCount, setCharCount] = (0, import_react5.useState)((prefix?.length || 0) + getDisplayValue(props.value).length);
1344
+ const [charCount, setCharCount] = (0, import_react5.useState)(getDisplayValue(props.value).length);
1345
1345
  const localInputRef = (0, import_react5.useRef)(null);
1346
1346
  const inputRef = forwardedRef || localInputRef;
1347
1347
  (0, import_react5.useEffect)(() => {
1348
1348
  const newDisplayValue = getDisplayValue(props.value);
1349
- setDisplayValue(newDisplayValue);
1350
- setCharCount((prefix?.length || 0) + newDisplayValue.length);
1351
- }, [props.value, prefix]);
1349
+ if (newDisplayValue !== displayValue) {
1350
+ setDisplayValue(newDisplayValue);
1351
+ setCharCount(newDisplayValue.length);
1352
+ }
1353
+ }, [props.value, prefix, displayValue]);
1354
+ const handleChange = (e) => {
1355
+ let currentDisplayValue = getDisplayValue(e.target.value);
1356
+ if (props.type === "number") {
1357
+ currentDisplayValue = currentDisplayValue.replace(/[^0-9]/g, "");
1358
+ }
1359
+ if (props.onChange) {
1360
+ const newEvent = {
1361
+ ...e,
1362
+ target: {
1363
+ ...e.target,
1364
+ value: currentDisplayValue
1365
+ }
1366
+ };
1367
+ props.onChange(newEvent);
1368
+ }
1369
+ };
1352
1370
  const handleContainerClick = () => {
1353
1371
  inputRef?.current?.focus();
1354
1372
  };
@@ -1376,24 +1394,11 @@ var Input2 = (0, import_react5.forwardRef)(
1376
1394
  {
1377
1395
  ref: inputRef,
1378
1396
  ...props,
1397
+ type: props.type === "number" ? "text" : props.type,
1398
+ inputMode: props.type === "number" ? "numeric" : props.inputMode,
1379
1399
  value: displayValue,
1380
- maxLength: maxLength ? maxLength - (prefix?.length || 0) : void 0,
1381
- onChange: (e) => {
1382
- const currentDisplayValue = e.target.value;
1383
- setDisplayValue(currentDisplayValue);
1384
- setCharCount((prefix?.length || 0) + currentDisplayValue.length);
1385
- if (props.onChange) {
1386
- const valueWithPrefix = prefix ? prefix + currentDisplayValue : currentDisplayValue;
1387
- const newEvent = {
1388
- ...e,
1389
- target: {
1390
- ...e.target,
1391
- value: valueWithPrefix
1392
- }
1393
- };
1394
- props.onChange(newEvent);
1395
- }
1396
- }
1400
+ maxLength,
1401
+ onChange: handleChange
1397
1402
  }
1398
1403
  ),
1399
1404
  !!suffix && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Suffix, { children: suffix })
@@ -2314,7 +2319,6 @@ var TabsTrigger = styled(Tabs.Trigger, {
2314
2319
  whiteSpace: "nowrap",
2315
2320
  textOverflow: "ellipsis",
2316
2321
  overflow: "hidden",
2317
- userSelect: "none",
2318
2322
  background: "$gray100",
2319
2323
  backgroundImage: "linear-gradient(to bottom, $clickpalm_mid, $clickpalm_superDark)",
2320
2324
  WebkitBackgroundClip: "text",
@@ -3961,8 +3965,7 @@ var CarouselContainer = styled("div", {
3961
3965
  flexDirection: "column",
3962
3966
  alignItems: "center",
3963
3967
  width: "100%",
3964
- maxWidth: "720px",
3965
- userSelect: "none"
3968
+ maxWidth: "720px"
3966
3969
  });
3967
3970
  var Wrapper6 = styled("div", {
3968
3971
  display: "flex",
@@ -4056,6 +4059,13 @@ var DotButton = styled("button", {
4056
4059
  borderColor: "$ignite_dark"
4057
4060
  }
4058
4061
  });
4062
+ var Ellipsis = styled("span", {
4063
+ color: "$ignite_light",
4064
+ textDecoration: "none",
4065
+ height: "9px",
4066
+ display: "flex",
4067
+ alignItems: "center"
4068
+ });
4059
4069
  var CarouselItemContainer = styled("div", {
4060
4070
  width: "100%"
4061
4071
  });
@@ -4095,6 +4105,8 @@ var Carousel = ({ title, variant, children }) => {
4095
4105
  setTouchStartX(null);
4096
4106
  setTouchEndX(null);
4097
4107
  };
4108
+ const activeItem = items[activeIndex];
4109
+ const itemTitle = activeItem.props.title;
4098
4110
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
4099
4111
  CarouselContainer,
4100
4112
  {
@@ -4104,7 +4116,7 @@ var Carousel = ({ title, variant, children }) => {
4104
4116
  children: [
4105
4117
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Wrapper6, { variant, children: [
4106
4118
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(CarouselHeader, { children: [
4107
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Title2, { children: title }),
4119
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Title2, { children: itemTitle ?? title }),
4108
4120
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Navigation, { children: [
4109
4121
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4110
4122
  Button,
@@ -4151,23 +4163,37 @@ var Carousel = ({ title, variant, children }) => {
4151
4163
  )
4152
4164
  ] }),
4153
4165
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Spacing, { size: "md" }),
4154
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DotsContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Dots2, { role: "tablist", "aria-label": "Carousel Pagination", children: items.map((_, idx) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4155
- DotButton,
4156
- {
4157
- active: idx === activeIndex,
4158
- "aria-label": `Go to slide ${idx + 1}`,
4159
- "aria-selected": idx === activeIndex,
4160
- role: "tab",
4161
- onClick: () => setActiveIndex(idx),
4162
- type: "button"
4163
- },
4164
- idx
4165
- )) }) })
4166
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DotsContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Dots2, { role: "tablist", "aria-label": "Carousel Pagination", children: getPaginationItems(items.length, activeIndex).map(
4167
+ (page, index) => typeof page === "number" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4168
+ DotButton,
4169
+ {
4170
+ active: page === activeIndex,
4171
+ "aria-label": `Go to slide ${page + 1}`,
4172
+ "aria-selected": page === activeIndex,
4173
+ role: "tab",
4174
+ onClick: () => setActiveIndex(page),
4175
+ type: "button"
4176
+ },
4177
+ page
4178
+ ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Ellipsis, { children: "..." }, `ellipsis-${index}`)
4179
+ ) }) })
4166
4180
  ]
4167
4181
  }
4168
4182
  );
4169
4183
  };
4170
- var CarouselItem = ({ children, style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CarouselItemContainer, { ...props, style: { ...style }, children });
4184
+ var getPaginationItems = (totalItems, activeIndex) => {
4185
+ if (totalItems <= 10) {
4186
+ return Array.from({ length: totalItems }, (_, i) => i);
4187
+ }
4188
+ if (activeIndex < 7) {
4189
+ return [0, 1, 2, 3, 4, 5, 6, "...", totalItems - 1];
4190
+ }
4191
+ if (activeIndex >= totalItems - 5) {
4192
+ return [0, "...", totalItems - 5, totalItems - 4, totalItems - 3, totalItems - 2, totalItems - 1];
4193
+ }
4194
+ return [0, "...", activeIndex - 2, activeIndex - 1, activeIndex, activeIndex + 1, activeIndex + 2, "...", totalItems - 1];
4195
+ };
4196
+ var CarouselItem = ({ children, style, title, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CarouselItemContainer, { ...props, style: { ...style }, children });
4171
4197
  Carousel.Item = CarouselItem;
4172
4198
 
4173
4199
  // src/components/PasswordInput.tsx
package/dist/index.mjs CHANGED
@@ -1271,14 +1271,32 @@ var Input2 = forwardRef3(
1271
1271
  return stringValue;
1272
1272
  };
1273
1273
  const [displayValue, setDisplayValue] = useState2(getDisplayValue(props.value));
1274
- const [charCount, setCharCount] = useState2((prefix?.length || 0) + getDisplayValue(props.value).length);
1274
+ const [charCount, setCharCount] = useState2(getDisplayValue(props.value).length);
1275
1275
  const localInputRef = useRef2(null);
1276
1276
  const inputRef = forwardedRef || localInputRef;
1277
1277
  useEffect2(() => {
1278
1278
  const newDisplayValue = getDisplayValue(props.value);
1279
- setDisplayValue(newDisplayValue);
1280
- setCharCount((prefix?.length || 0) + newDisplayValue.length);
1281
- }, [props.value, prefix]);
1279
+ if (newDisplayValue !== displayValue) {
1280
+ setDisplayValue(newDisplayValue);
1281
+ setCharCount(newDisplayValue.length);
1282
+ }
1283
+ }, [props.value, prefix, displayValue]);
1284
+ const handleChange = (e) => {
1285
+ let currentDisplayValue = getDisplayValue(e.target.value);
1286
+ if (props.type === "number") {
1287
+ currentDisplayValue = currentDisplayValue.replace(/[^0-9]/g, "");
1288
+ }
1289
+ if (props.onChange) {
1290
+ const newEvent = {
1291
+ ...e,
1292
+ target: {
1293
+ ...e.target,
1294
+ value: currentDisplayValue
1295
+ }
1296
+ };
1297
+ props.onChange(newEvent);
1298
+ }
1299
+ };
1282
1300
  const handleContainerClick = () => {
1283
1301
  inputRef?.current?.focus();
1284
1302
  };
@@ -1306,24 +1324,11 @@ var Input2 = forwardRef3(
1306
1324
  {
1307
1325
  ref: inputRef,
1308
1326
  ...props,
1327
+ type: props.type === "number" ? "text" : props.type,
1328
+ inputMode: props.type === "number" ? "numeric" : props.inputMode,
1309
1329
  value: displayValue,
1310
- maxLength: maxLength ? maxLength - (prefix?.length || 0) : void 0,
1311
- onChange: (e) => {
1312
- const currentDisplayValue = e.target.value;
1313
- setDisplayValue(currentDisplayValue);
1314
- setCharCount((prefix?.length || 0) + currentDisplayValue.length);
1315
- if (props.onChange) {
1316
- const valueWithPrefix = prefix ? prefix + currentDisplayValue : currentDisplayValue;
1317
- const newEvent = {
1318
- ...e,
1319
- target: {
1320
- ...e.target,
1321
- value: valueWithPrefix
1322
- }
1323
- };
1324
- props.onChange(newEvent);
1325
- }
1326
- }
1330
+ maxLength,
1331
+ onChange: handleChange
1327
1332
  }
1328
1333
  ),
1329
1334
  !!suffix && /* @__PURE__ */ jsx19(Suffix, { children: suffix })
@@ -2244,7 +2249,6 @@ var TabsTrigger = styled(Tabs.Trigger, {
2244
2249
  whiteSpace: "nowrap",
2245
2250
  textOverflow: "ellipsis",
2246
2251
  overflow: "hidden",
2247
- userSelect: "none",
2248
2252
  background: "$gray100",
2249
2253
  backgroundImage: "linear-gradient(to bottom, $clickpalm_mid, $clickpalm_superDark)",
2250
2254
  WebkitBackgroundClip: "text",
@@ -3895,8 +3899,7 @@ var CarouselContainer = styled("div", {
3895
3899
  flexDirection: "column",
3896
3900
  alignItems: "center",
3897
3901
  width: "100%",
3898
- maxWidth: "720px",
3899
- userSelect: "none"
3902
+ maxWidth: "720px"
3900
3903
  });
3901
3904
  var Wrapper6 = styled("div", {
3902
3905
  display: "flex",
@@ -3990,6 +3993,13 @@ var DotButton = styled("button", {
3990
3993
  borderColor: "$ignite_dark"
3991
3994
  }
3992
3995
  });
3996
+ var Ellipsis = styled("span", {
3997
+ color: "$ignite_light",
3998
+ textDecoration: "none",
3999
+ height: "9px",
4000
+ display: "flex",
4001
+ alignItems: "center"
4002
+ });
3993
4003
  var CarouselItemContainer = styled("div", {
3994
4004
  width: "100%"
3995
4005
  });
@@ -4029,6 +4039,8 @@ var Carousel = ({ title, variant, children }) => {
4029
4039
  setTouchStartX(null);
4030
4040
  setTouchEndX(null);
4031
4041
  };
4042
+ const activeItem = items[activeIndex];
4043
+ const itemTitle = activeItem.props.title;
4032
4044
  return /* @__PURE__ */ jsxs20(
4033
4045
  CarouselContainer,
4034
4046
  {
@@ -4038,7 +4050,7 @@ var Carousel = ({ title, variant, children }) => {
4038
4050
  children: [
4039
4051
  /* @__PURE__ */ jsxs20(Wrapper6, { variant, children: [
4040
4052
  /* @__PURE__ */ jsxs20(CarouselHeader, { children: [
4041
- /* @__PURE__ */ jsx43(Title2, { children: title }),
4053
+ /* @__PURE__ */ jsx43(Title2, { children: itemTitle ?? title }),
4042
4054
  /* @__PURE__ */ jsxs20(Navigation, { children: [
4043
4055
  /* @__PURE__ */ jsx43(
4044
4056
  Button,
@@ -4085,23 +4097,37 @@ var Carousel = ({ title, variant, children }) => {
4085
4097
  )
4086
4098
  ] }),
4087
4099
  /* @__PURE__ */ jsx43(Spacing, { size: "md" }),
4088
- /* @__PURE__ */ jsx43(DotsContainer, { children: /* @__PURE__ */ jsx43(Dots2, { role: "tablist", "aria-label": "Carousel Pagination", children: items.map((_, idx) => /* @__PURE__ */ jsx43(
4089
- DotButton,
4090
- {
4091
- active: idx === activeIndex,
4092
- "aria-label": `Go to slide ${idx + 1}`,
4093
- "aria-selected": idx === activeIndex,
4094
- role: "tab",
4095
- onClick: () => setActiveIndex(idx),
4096
- type: "button"
4097
- },
4098
- idx
4099
- )) }) })
4100
+ /* @__PURE__ */ jsx43(DotsContainer, { children: /* @__PURE__ */ jsx43(Dots2, { role: "tablist", "aria-label": "Carousel Pagination", children: getPaginationItems(items.length, activeIndex).map(
4101
+ (page, index) => typeof page === "number" ? /* @__PURE__ */ jsx43(
4102
+ DotButton,
4103
+ {
4104
+ active: page === activeIndex,
4105
+ "aria-label": `Go to slide ${page + 1}`,
4106
+ "aria-selected": page === activeIndex,
4107
+ role: "tab",
4108
+ onClick: () => setActiveIndex(page),
4109
+ type: "button"
4110
+ },
4111
+ page
4112
+ ) : /* @__PURE__ */ jsx43(Ellipsis, { children: "..." }, `ellipsis-${index}`)
4113
+ ) }) })
4100
4114
  ]
4101
4115
  }
4102
4116
  );
4103
4117
  };
4104
- var CarouselItem = ({ children, style, ...props }) => /* @__PURE__ */ jsx43(CarouselItemContainer, { ...props, style: { ...style }, children });
4118
+ var getPaginationItems = (totalItems, activeIndex) => {
4119
+ if (totalItems <= 10) {
4120
+ return Array.from({ length: totalItems }, (_, i) => i);
4121
+ }
4122
+ if (activeIndex < 7) {
4123
+ return [0, 1, 2, 3, 4, 5, 6, "...", totalItems - 1];
4124
+ }
4125
+ if (activeIndex >= totalItems - 5) {
4126
+ return [0, "...", totalItems - 5, totalItems - 4, totalItems - 3, totalItems - 2, totalItems - 1];
4127
+ }
4128
+ return [0, "...", activeIndex - 2, activeIndex - 1, activeIndex, activeIndex + 1, activeIndex + 2, "...", totalItems - 1];
4129
+ };
4130
+ var CarouselItem = ({ children, style, title, ...props }) => /* @__PURE__ */ jsx43(CarouselItemContainer, { ...props, style: { ...style }, children });
4105
4131
  Carousel.Item = CarouselItem;
4106
4132
 
4107
4133
  // src/components/PasswordInput.tsx
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Design System da Clikpalm",
4
4
  "author": "Enisson Shilo",
5
5
  "license": "MIT",
6
- "version": "1.3.7",
6
+ "version": "1.3.9",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/clickpalm/clickpalm-designsystem-lib.git"