@octoguide/mui-ui-toolkit 0.1.0 → 0.2.0

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.mts CHANGED
@@ -412,11 +412,20 @@ declare const CardContent: _mui_material_OverridableComponent.OverridableCompone
412
412
  declare const CardHeader: _mui_material.OverridableCardHeader;
413
413
  declare const CardActions: typeof CardActions$1;
414
414
 
415
- type TextFieldProps = TextFieldProps$1;
416
- declare function TextField({ error, FormHelperTextProps, inputProps, label, ...props }: TextFieldProps): react_jsx_runtime.JSX.Element;
417
- declare namespace TextField {
418
- var displayName: string;
419
- }
415
+ type TextFieldProps = TextFieldProps$1 & {
416
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
417
+ showPasswordToggle?: boolean;
418
+ };
419
+ declare const TextField: React.ForwardRefExoticComponent<(Omit<_mui_material.OutlinedTextFieldProps & {
420
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
421
+ showPasswordToggle?: boolean;
422
+ }, "ref"> | Omit<_mui_material.FilledTextFieldProps & {
423
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
424
+ showPasswordToggle?: boolean;
425
+ }, "ref"> | Omit<_mui_material.StandardTextFieldProps & {
426
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
427
+ showPasswordToggle?: boolean;
428
+ }, "ref">) & React.RefAttributes<HTMLInputElement>>;
420
429
 
421
430
  type AlertProps = AlertProps$1;
422
431
  type AlertTitleProps = AlertTitleProps$1;
package/dist/index.d.ts CHANGED
@@ -412,11 +412,20 @@ declare const CardContent: _mui_material_OverridableComponent.OverridableCompone
412
412
  declare const CardHeader: _mui_material.OverridableCardHeader;
413
413
  declare const CardActions: typeof CardActions$1;
414
414
 
415
- type TextFieldProps = TextFieldProps$1;
416
- declare function TextField({ error, FormHelperTextProps, inputProps, label, ...props }: TextFieldProps): react_jsx_runtime.JSX.Element;
417
- declare namespace TextField {
418
- var displayName: string;
419
- }
415
+ type TextFieldProps = TextFieldProps$1 & {
416
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
417
+ showPasswordToggle?: boolean;
418
+ };
419
+ declare const TextField: React.ForwardRefExoticComponent<(Omit<_mui_material.OutlinedTextFieldProps & {
420
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
421
+ showPasswordToggle?: boolean;
422
+ }, "ref"> | Omit<_mui_material.FilledTextFieldProps & {
423
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
424
+ showPasswordToggle?: boolean;
425
+ }, "ref"> | Omit<_mui_material.StandardTextFieldProps & {
426
+ /** When true and type="password", renders a visibility toggle icon button as end adornment. */
427
+ showPasswordToggle?: boolean;
428
+ }, "ref">) & React.RefAttributes<HTMLInputElement>>;
420
429
 
421
430
  type AlertProps = AlertProps$1;
422
431
  type AlertTitleProps = AlertTitleProps$1;
package/dist/index.js CHANGED
@@ -1245,9 +1245,12 @@ var CardActions = import_material4.CardActions;
1245
1245
  Card.displayName = "ToolkitCard";
1246
1246
 
1247
1247
  // src/components/TextField/TextField.tsx
1248
+ var import_react = __toESM(require("react"));
1248
1249
  var import_material5 = require("@mui/material");
1249
1250
  var import_styles4 = require("@mui/material/styles");
1250
1251
  var import_jsx_runtime5 = require("react/jsx-runtime");
1252
+ var VisibilityIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.SvgIcon, { viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { fill: "currentColor", d: "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3" }) });
1253
+ var VisibilityOffIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.SvgIcon, { viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { fill: "currentColor", d: "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75C21.27 5.61 17 2.5 12 2.5c-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 5.13 11.35 5 12 5M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27M7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01" }) });
1251
1254
  var StyledTextField = (0, import_styles4.styled)(import_material5.TextField)(({ theme }) => ({
1252
1255
  // Transition on the entire field when focus changes
1253
1256
  "& .MuiOutlinedInput-root": {
@@ -1257,25 +1260,42 @@ var StyledTextField = (0, import_styles4.styled)(import_material5.TextField)(({
1257
1260
  }
1258
1261
  }
1259
1262
  }));
1260
- function TextField({ error, FormHelperTextProps, inputProps, label, ...props }) {
1261
- if (process.env.NODE_ENV !== "production") {
1262
- if (!label && !props["aria-label"] && !props["aria-labelledby"] && !inputProps?.["aria-label"] && !inputProps?.["aria-labelledby"]) {
1263
- console.warn("[ToolkitTextField] Missing accessible label. Provide `label`, `aria-label`, or `aria-labelledby`.");
1263
+ var TextField = import_react.default.forwardRef(
1264
+ function TextField2({ error, FormHelperTextProps, inputProps, label, showPasswordToggle, type, slotProps, ...props }, ref) {
1265
+ const [showPassword, setShowPassword] = (0, import_react.useState)(false);
1266
+ if (process.env.NODE_ENV !== "production") {
1267
+ if (!label && !props["aria-label"] && !props["aria-labelledby"] && !inputProps?.["aria-label"] && !inputProps?.["aria-labelledby"]) {
1268
+ console.warn("[ToolkitTextField] Missing accessible label. Provide `label`, `aria-label`, or `aria-labelledby`.");
1269
+ }
1264
1270
  }
1271
+ const resolvedType = showPasswordToggle && type === "password" ? showPassword ? "text" : "password" : type;
1272
+ const toggleAdornment = showPasswordToggle && type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_material5.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1273
+ import_material5.IconButton,
1274
+ {
1275
+ "aria-label": showPassword ? "Hide password" : "Show password",
1276
+ onClick: () => setShowPassword((prev) => !prev),
1277
+ edge: "end",
1278
+ children: showPassword ? VisibilityOffIcon : VisibilityIcon
1279
+ }
1280
+ ) }) : null;
1281
+ const mergedSlotProps = toggleAdornment ? { ...slotProps, input: { endAdornment: toggleAdornment, ...slotProps?.input } } : slotProps;
1282
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1283
+ StyledTextField,
1284
+ {
1285
+ fullWidth: true,
1286
+ variant: "outlined",
1287
+ label,
1288
+ error,
1289
+ type: resolvedType,
1290
+ inputRef: ref,
1291
+ inputProps,
1292
+ slotProps: mergedSlotProps,
1293
+ FormHelperTextProps: error ? { role: "alert", ...FormHelperTextProps } : FormHelperTextProps,
1294
+ ...props
1295
+ }
1296
+ );
1265
1297
  }
1266
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1267
- StyledTextField,
1268
- {
1269
- fullWidth: true,
1270
- variant: "outlined",
1271
- label,
1272
- error,
1273
- inputProps,
1274
- FormHelperTextProps: error ? { role: "alert", ...FormHelperTextProps } : FormHelperTextProps,
1275
- ...props
1276
- }
1277
- );
1278
- }
1298
+ );
1279
1299
  TextField.displayName = "ToolkitTextField";
1280
1300
 
1281
1301
  // src/components/Alert/Alert.tsx
@@ -1377,7 +1397,7 @@ function ToggleButtonGroup(props) {
1377
1397
  ToggleButtonGroup.displayName = "ToolkitToggleButtonGroup";
1378
1398
 
1379
1399
  // src/components/DatePicker/DatePicker.tsx
1380
- var import_react = require("react");
1400
+ var import_react2 = require("react");
1381
1401
  var import_AdapterDayjs = require("@mui/x-date-pickers/AdapterDayjs");
1382
1402
  var import_LocalizationProvider = require("@mui/x-date-pickers/LocalizationProvider");
1383
1403
  var import_DatePicker = require("@mui/x-date-pickers/DatePicker");
@@ -1484,8 +1504,8 @@ function DateRangePickerInput({
1484
1504
  endLabel = "End date",
1485
1505
  buttonLabel = "Click me!"
1486
1506
  }) {
1487
- const [open, setOpen] = (0, import_react.useState)(false);
1488
- const [draft, setDraft] = (0, import_react.useState)(value);
1507
+ const [open, setOpen] = (0, import_react2.useState)(false);
1508
+ const [draft, setDraft] = (0, import_react2.useState)(value);
1489
1509
  const handleOpen = () => {
1490
1510
  setDraft(value);
1491
1511
  setOpen(true);
@@ -1531,9 +1551,9 @@ function DateRangePickerCalendar({
1531
1551
  onChange,
1532
1552
  buttonLabel = "Click me!"
1533
1553
  }) {
1534
- const [open, setOpen] = (0, import_react.useState)(false);
1535
- const [draft, setDraft] = (0, import_react.useState)(value);
1536
- const [selecting, setSelecting] = (0, import_react.useState)("start");
1554
+ const [open, setOpen] = (0, import_react2.useState)(false);
1555
+ const [draft, setDraft] = (0, import_react2.useState)(value);
1556
+ const [selecting, setSelecting] = (0, import_react2.useState)("start");
1537
1557
  const handleOpen = () => {
1538
1558
  setDraft(value);
1539
1559
  setSelecting("start");