@ttoss/ui 1.36.1 → 1.36.3

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/esm/index.js CHANGED
@@ -571,4 +571,53 @@ Stack.displayName = "Stack";
571
571
 
572
572
  // src/components/Paragraph.tsx
573
573
  import { Paragraph } from "theme-ui";
574
- export { Badge, BaseStyles, Box, Button, Card, Checkbox, CloseButton, Container, Divider, Flex, Global2 as Global, Grid, Heading, HelpText, Icon, IconButton, Image, InfiniteLinearProgress, Input, InputNumber, Label, Progress as LinearProgress, Link, Paragraph, Radio, Select, Slider, Spinner, Stack, Text, Textarea, ThemeProvider, keyframes, useBreakpointIndex, useResponsiveValue, useTheme };
574
+
575
+ // src/components/InputPassword/InputPassword.tsx
576
+ import * as React14 from "react";
577
+
578
+ // src/components/InputPassword/useHidePassInput.ts
579
+ import * as React13 from "react";
580
+ var useHidePassInput = (defaultValue = true) => {
581
+ const [hidePass, setHidePass] = React13.useState(Boolean(defaultValue));
582
+ const {
583
+ icon,
584
+ inputType
585
+ } = React13.useMemo(() => {
586
+ return {
587
+ icon: hidePass ? "view-off" : "view-on",
588
+ inputType: hidePass ? "password" : "text"
589
+ };
590
+ }, [hidePass]);
591
+ const handleClick = () => {
592
+ setHidePass(prev => {
593
+ return !prev;
594
+ });
595
+ };
596
+ return {
597
+ handleClick,
598
+ icon,
599
+ inputType
600
+ };
601
+ };
602
+
603
+ // src/components/InputPassword/InputPassword.tsx
604
+ import { jsx as jsx16 } from "react/jsx-runtime";
605
+ var InputPassword = /*#__PURE__*/React14.forwardRef(({
606
+ showPasswordByDefault,
607
+ ...inputPasswordProps
608
+ }, ref) => {
609
+ const {
610
+ handleClick,
611
+ icon,
612
+ inputType
613
+ } = useHidePassInput(!showPasswordByDefault);
614
+ return /* @__PURE__ */jsx16(Input, {
615
+ ref,
616
+ ...inputPasswordProps,
617
+ trailingIcon: icon,
618
+ onTrailingIconClick: handleClick,
619
+ type: inputType
620
+ });
621
+ });
622
+ InputPassword.displayName = "InputPassword";
623
+ export { Badge, BaseStyles, Box, Button, Card, Checkbox, CloseButton, Container, Divider, Flex, Global2 as Global, Grid, Heading, HelpText, Icon, IconButton, Image, InfiniteLinearProgress, Input, InputNumber, InputPassword, Label, Progress as LinearProgress, Link, Paragraph, Radio, Select, Slider, Spinner, Stack, Text, Textarea, ThemeProvider, keyframes, useBreakpointIndex, useResponsiveValue, useTheme };
package/dist/index.d.ts CHANGED
@@ -91,4 +91,9 @@ type StackProps = FlexProps;
91
91
  */
92
92
  declare const Stack: React.ForwardRefExoticComponent<theme_ui.BoxProps & React.RefAttributes<HTMLElement>>;
93
93
 
94
- export { Badge, BadgeProps, Button, ButtonProps, CloseButton, CloseButtonProps, HelpText, HelpTextProps, Icon, IconButton, IconProps, IconType, InfiniteLinearProgress, Input, InputNumber, InputNumberProps, InputProps, Label, LabelProps, Link, LinkProps, Select, Stack, StackProps, Textarea, TextareaProps, ThemeProvider, ThemeProviderProps, useTheme };
94
+ type InputPasswordProps = Omit<InputProps, 'trailingIcon' | 'onTrailingIconClick' | 'type'> & {
95
+ showPasswordByDefault?: boolean;
96
+ };
97
+ declare const InputPassword: React.ForwardRefExoticComponent<Omit<InputPasswordProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
98
+
99
+ export { Badge, BadgeProps, Button, ButtonProps, CloseButton, CloseButtonProps, HelpText, HelpTextProps, Icon, IconButton, IconProps, IconType, InfiniteLinearProgress, Input, InputNumber, InputNumberProps, InputPassword, InputPasswordProps, InputProps, Label, LabelProps, Link, LinkProps, Select, Stack, StackProps, Textarea, TextareaProps, ThemeProvider, ThemeProviderProps, useTheme };
package/dist/index.js CHANGED
@@ -58,6 +58,7 @@ __export(src_exports, {
58
58
  InfiniteLinearProgress: () => InfiniteLinearProgress,
59
59
  Input: () => Input,
60
60
  InputNumber: () => InputNumber,
61
+ InputPassword: () => InputPassword,
61
62
  Label: () => Label,
62
63
  LinearProgress: () => import_theme_ui15.Progress,
63
64
  Link: () => Link,
@@ -646,6 +647,55 @@ Stack.displayName = "Stack";
646
647
 
647
648
  // src/components/Paragraph.tsx
648
649
  var import_theme_ui27 = require("theme-ui");
650
+
651
+ // src/components/InputPassword/InputPassword.tsx
652
+ var React14 = __toESM(require("react"));
653
+
654
+ // src/components/InputPassword/useHidePassInput.ts
655
+ var React13 = __toESM(require("react"));
656
+ var useHidePassInput = (defaultValue = true) => {
657
+ const [hidePass, setHidePass] = React13.useState(Boolean(defaultValue));
658
+ const {
659
+ icon,
660
+ inputType
661
+ } = React13.useMemo(() => {
662
+ return {
663
+ icon: hidePass ? "view-off" : "view-on",
664
+ inputType: hidePass ? "password" : "text"
665
+ };
666
+ }, [hidePass]);
667
+ const handleClick = () => {
668
+ setHidePass(prev => {
669
+ return !prev;
670
+ });
671
+ };
672
+ return {
673
+ handleClick,
674
+ icon,
675
+ inputType
676
+ };
677
+ };
678
+
679
+ // src/components/InputPassword/InputPassword.tsx
680
+ var import_jsx_runtime16 = require("react/jsx-runtime");
681
+ var InputPassword = React14.forwardRef(({
682
+ showPasswordByDefault,
683
+ ...inputPasswordProps
684
+ }, ref) => {
685
+ const {
686
+ handleClick,
687
+ icon,
688
+ inputType
689
+ } = useHidePassInput(!showPasswordByDefault);
690
+ return /* @__PURE__ */(0, import_jsx_runtime16.jsx)(Input, {
691
+ ref,
692
+ ...inputPasswordProps,
693
+ trailingIcon: icon,
694
+ onTrailingIconClick: handleClick,
695
+ type: inputType
696
+ });
697
+ });
698
+ InputPassword.displayName = "InputPassword";
649
699
  // Annotate the CommonJS export names for ESM import in node:
650
700
  0 && (module.exports = {
651
701
  Badge,
@@ -668,6 +718,7 @@ var import_theme_ui27 = require("theme-ui");
668
718
  InfiniteLinearProgress,
669
719
  Input,
670
720
  InputNumber,
721
+ InputPassword,
671
722
  Label,
672
723
  LinearProgress,
673
724
  Link,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "1.36.1",
3
+ "version": "1.36.3",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -20,7 +20,7 @@
20
20
  "@iconify-icon/react": "^1.0.7",
21
21
  "@theme-ui/match-media": "^0.15.7",
22
22
  "theme-ui": "^0.15.7",
23
- "@ttoss/theme": "^1.4.31"
23
+ "@ttoss/theme": "^1.4.32"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": ">=16.8.0"
@@ -33,8 +33,8 @@
33
33
  "jest": "^29.5.0",
34
34
  "react": "^18.2.0",
35
35
  "tsup": "^6.7.0",
36
- "@ttoss/test-utils": "^1.23.0",
37
- "@ttoss/config": "^1.30.0"
36
+ "@ttoss/config": "^1.30.0",
37
+ "@ttoss/test-utils": "^1.23.0"
38
38
  },
39
39
  "keywords": [
40
40
  "React",
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ import { Input } from '../Input';
3
+ import { type InputProps } from '../Input';
4
+ import { useHidePassInput } from './useHidePassInput';
5
+
6
+ export type InputPasswordProps = Omit<
7
+ InputProps,
8
+ 'trailingIcon' | 'onTrailingIconClick' | 'type'
9
+ > & {
10
+ showPasswordByDefault?: boolean;
11
+ };
12
+
13
+ export const InputPassword = React.forwardRef<
14
+ HTMLInputElement,
15
+ InputPasswordProps
16
+ >(({ showPasswordByDefault, ...inputPasswordProps }, ref) => {
17
+ const { handleClick, icon, inputType } = useHidePassInput(
18
+ !showPasswordByDefault
19
+ );
20
+
21
+ return (
22
+ <Input
23
+ ref={ref}
24
+ {...inputPasswordProps}
25
+ trailingIcon={icon}
26
+ onTrailingIconClick={handleClick}
27
+ type={inputType}
28
+ />
29
+ );
30
+ });
31
+
32
+ InputPassword.displayName = 'InputPassword';
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+
3
+ export const useHidePassInput = (defaultValue = true) => {
4
+ const [hidePass, setHidePass] = React.useState<boolean>(
5
+ Boolean(defaultValue)
6
+ );
7
+
8
+ const { icon, inputType } = React.useMemo(() => {
9
+ return {
10
+ icon: hidePass ? 'view-off' : 'view-on',
11
+ inputType: hidePass ? 'password' : 'text',
12
+ };
13
+ }, [hidePass]);
14
+
15
+ const handleClick = () => {
16
+ setHidePass((prev) => {
17
+ return !prev;
18
+ });
19
+ };
20
+
21
+ return {
22
+ handleClick,
23
+ icon,
24
+ inputType,
25
+ };
26
+ };
package/src/index.ts CHANGED
@@ -38,3 +38,7 @@ export { CloseButton, type CloseButtonProps } from './components/CloseButton';
38
38
  export { InputNumber, type InputNumberProps } from './components/InputNumber';
39
39
  export { Stack, type StackProps } from './components/Stack';
40
40
  export { Paragraph, type ParagraphProps } from './components/Paragraph';
41
+ export {
42
+ InputPassword,
43
+ type InputPasswordProps,
44
+ } from './components/InputPassword/InputPassword';