autocasting-ui-library-padimasso 1.3.4 → 1.3.6
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/components/Actions/Buttons/Button/Button.js +2 -2
- package/dist/components/Brand/Identity/Icon/Icon.js +6 -0
- package/dist/components/Forms/Fields/FormCurrencyField/FormCurrencyField.js +16 -0
- package/dist/components/Forms/Fields/FormCurrencyField/index.js +5 -0
- package/dist/components/Forms/Fields/FormInputField/FormInputField.js +8 -3
- package/dist/components/Forms/Fields/FormPasswordField/FormPasswordField.js +16 -0
- package/dist/components/Forms/Fields/FormPasswordField/index.js +5 -0
- package/dist/components/Forms/Fields/FormSelectField/FormSelectField.js +2 -0
- package/dist/components/Forms/primitive/CurrencyInput/CurrencyInput.js +55 -0
- package/dist/components/Forms/primitive/CurrencyInput/index.js +5 -0
- package/dist/components/Forms/primitive/EditableInput/EditableInput.js +8 -3
- package/dist/components/Forms/primitive/PasswordInput/PasswordInput.js +19 -0
- package/dist/components/Forms/primitive/PasswordInput/index.js +5 -0
- package/dist/components/Overlays/Dialogs/Modal/Modal.js +1 -1
- package/dist/components/Overlays/Panels/DetailsView/DetailsView.js +1 -1
- package/dist/components/Overlays/Tooltip/Tooltip.js +108 -0
- package/dist/icons/view-hide-purple.svg.js +3 -0
- package/dist/icons/view-hide.svg.js +3 -0
- package/dist/index.d.ts +43 -4
- package/dist/index.js +5 -0
- package/dist/styles.css +2 -2
- package/package.json +1 -1
- package/src/components/Actions/Buttons/Button/Button.tsx +2 -2
- package/src/components/Brand/Identity/Icon/Icon.tsx +7 -0
- package/src/components/Forms/Fields/FormCurrencyField/FormCurrencyField.stories.tsx +36 -0
- package/src/components/Forms/Fields/FormCurrencyField/FormCurrencyField.tsx +54 -0
- package/src/components/Forms/Fields/FormCurrencyField/index.ts +3 -0
- package/src/components/Forms/Fields/FormInputField/FormInputField.tsx +19 -15
- package/src/components/Forms/Fields/FormPasswordField/FormPasswordField.stories.tsx +37 -0
- package/src/components/Forms/Fields/FormPasswordField/FormPasswordField.tsx +50 -0
- package/src/components/Forms/Fields/FormPasswordField/index.ts +3 -0
- package/src/components/Forms/Fields/index.ts +2 -0
- package/src/components/Forms/primitive/CurrencyInput/CurrencyInput.stories.tsx +30 -0
- package/src/components/Forms/primitive/CurrencyInput/CurrencyInput.tsx +84 -0
- package/src/components/Forms/primitive/CurrencyInput/index.ts +3 -0
- package/src/components/Forms/primitive/EditableInput/EditableInput.tsx +36 -42
- package/src/components/Forms/primitive/PasswordInput/PasswordInput.stories.tsx +24 -0
- package/src/components/Forms/primitive/PasswordInput/PasswordInput.tsx +56 -0
- package/src/components/Forms/primitive/PasswordInput/index.ts +3 -0
- package/src/components/Forms/primitive/index.ts +2 -0
- package/src/components/Overlays/Dialogs/Modal/Modal.tsx +1 -0
- package/src/components/Overlays/Panels/DetailsView/DetailsView.tsx +1 -1
- package/src/components/Overlays/Tooltip/Tooltip.stories.tsx +121 -0
- package/src/components/Overlays/Tooltip/Tooltip.tsx +198 -0
- package/src/components/Overlays/Tooltip/index.ts +2 -0
- package/src/icons/view-hide-purple.svg +3 -0
- package/src/icons/view-hide.svg +3 -0
- package/src/index.ts +1 -0
- package/src/components/Brand/Identity/Icons/EditIcon.tsx +0 -18
- package/src/components/Brand/Identity/Icons/index.ts +0 -2
|
@@ -4,7 +4,7 @@ import { clsx } from 'clsx';
|
|
|
4
4
|
import { BUTTON_STRUCTURE } from '../../../../styles/style_constants.js';
|
|
5
5
|
|
|
6
6
|
const Button = forwardRef((props, ref) => {
|
|
7
|
-
const { className, variant = 'primary', asChild = false, children, ...rest } = props;
|
|
7
|
+
const { className, variant = 'primary', asChild = false, children, type, ...rest } = props;
|
|
8
8
|
const { disabled, ...delegated } = rest;
|
|
9
9
|
const variantClasses = {
|
|
10
10
|
primary: 'bg-(--color-primary-purple) text-(--color-primary-white) cursor-pointer hover:bg-(--hover-color-primary)',
|
|
@@ -24,7 +24,7 @@ const Button = forwardRef((props, ref) => {
|
|
|
24
24
|
};
|
|
25
25
|
return cloneElement(children, childProps);
|
|
26
26
|
}
|
|
27
|
-
return (jsx("button", { ref: ref, className: computedClass, disabled: disabled, ...delegated, children: children }));
|
|
27
|
+
return (jsx("button", { ref: ref, type: type ?? 'button', className: computedClass, disabled: disabled, ...delegated, children: children }));
|
|
28
28
|
});
|
|
29
29
|
Button.displayName = 'Button';
|
|
30
30
|
|
|
@@ -78,7 +78,9 @@ import TickIconAlertGreen from '../../../../icons/tick-2-alert-green.svg.js';
|
|
|
78
78
|
import TickIcon from '../../../../icons/tick-2.svg.js';
|
|
79
79
|
import TikTokIcon from '../../../../icons/tikTok.svg.js';
|
|
80
80
|
import ViewIconPurple from '../../../../icons/view-purple.svg.js';
|
|
81
|
+
import ViewHideIconPurple from '../../../../icons/view-hide-purple.svg.js';
|
|
81
82
|
import ViewIcon from '../../../../icons/view.svg.js';
|
|
83
|
+
import ViewHideIcon from '../../../../icons/view-hide.svg.js';
|
|
82
84
|
import VimeoIconPurple from '../../../../icons/vimeo-purple.svg.js';
|
|
83
85
|
import VimeoIcon from '../../../../icons/vimeo.svg.js';
|
|
84
86
|
import WhatsappIconPurple from '../../../../icons/whatsapp-purple.svg.js';
|
|
@@ -263,6 +265,10 @@ const ICONS = {
|
|
|
263
265
|
warning: {
|
|
264
266
|
default: WarningIconAlertYellow,
|
|
265
267
|
},
|
|
268
|
+
viewHide: {
|
|
269
|
+
default: ViewHideIcon,
|
|
270
|
+
primary: ViewHideIconPurple,
|
|
271
|
+
},
|
|
266
272
|
};
|
|
267
273
|
function Icon({ name, variant = 'default', size = 18, className, alt = '', style, ...rest }) {
|
|
268
274
|
const config = ICONS[name];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import '../../primitive/Input/Input.js';
|
|
4
|
+
import CurrencyInput from '../../primitive/CurrencyInput/CurrencyInput.js';
|
|
5
|
+
import '../../primitive/PasswordInput/PasswordInput.js';
|
|
6
|
+
import '../../primitive/Select/Select.js';
|
|
7
|
+
import Label from '../../primitive/Label/Label.js';
|
|
8
|
+
|
|
9
|
+
const FormCurrencyField = (allProps) => {
|
|
10
|
+
const hasValueProp = Object.prototype.hasOwnProperty.call(allProps, 'value');
|
|
11
|
+
const { id, label, error, labelClassName, className, value, required, onValueChange, ...props } = allProps;
|
|
12
|
+
const inputValueProps = hasValueProp ? { value: (value ?? '') } : {};
|
|
13
|
+
return (jsxs("div", { className: "w-full flex flex-col", children: [label && (jsxs(Label, { htmlFor: id, className: clsx('mb-2', labelClassName), children: [label, required ? (jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })) : null] })), jsx(CurrencyInput, { id: id, "aria-invalid": !!error, "aria-describedby": error ? `${id}-error` : undefined, className: className, onValueChange: onValueChange, ...inputValueProps, ...props }), jsx("div", { className: "min-h-[25px]", children: error && (jsx(Label, { id: `${id}-error`, variant: "error", className: "mt-0.4 pl-0.7", children: error })) })] }));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { FormCurrencyField as default };
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Input from '../../primitive/Input/Input.js';
|
|
3
|
+
import '../../primitive/CurrencyInput/CurrencyInput.js';
|
|
4
|
+
import '../../primitive/PasswordInput/PasswordInput.js';
|
|
3
5
|
import '../../primitive/Select/Select.js';
|
|
4
6
|
import Label from '../../primitive/Label/Label.js';
|
|
5
7
|
import { clsx } from 'clsx';
|
|
6
8
|
import EditableInput from '../../primitive/EditableInput/EditableInput.js';
|
|
7
9
|
|
|
8
|
-
const FormInputField = (
|
|
9
|
-
|
|
10
|
+
const FormInputField = (allProps) => {
|
|
11
|
+
const hasValueProp = Object.prototype.hasOwnProperty.call(allProps, 'value');
|
|
12
|
+
const { id, label, error, editable = false, onEdit, labelClassName, type = 'text', className, value, required, ...props } = allProps;
|
|
13
|
+
const inputValueProps = hasValueProp ? { value: (value ?? '') } : {};
|
|
14
|
+
return (jsxs("div", { className: "w-full flex flex-col", children: [label && (jsxs(Label, { htmlFor: id, className: clsx('mb-2', labelClassName), children: [label, required ? (jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })) : null] })), editable ? (jsx(EditableInput, { id: id, "aria-invalid": !!error, "aria-describedby": error ? `${id}-error` : undefined, className: className, type: type, onEdit: onEdit, ...inputValueProps, ...props })) : (
|
|
10
15
|
/* ----- Normal variant (la que ya tenías) ----- */
|
|
11
|
-
jsx(Input, { id: id, "aria-invalid": !!error, "aria-describedby": error ? `${id}-error` : undefined, className: className, type: type,
|
|
16
|
+
jsx(Input, { id: id, "aria-invalid": !!error, "aria-describedby": error ? `${id}-error` : undefined, className: className, type: type, ...inputValueProps, ...props })), jsx("div", { className: "min-h-[25px]", children: error && (jsx(Label, { id: `${id}-error`, variant: "error", className: "mt-0.4 pl-0.7", children: error })) })] }));
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
export { FormInputField as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import '../../primitive/Input/Input.js';
|
|
4
|
+
import '../../primitive/CurrencyInput/CurrencyInput.js';
|
|
5
|
+
import PasswordInput from '../../primitive/PasswordInput/PasswordInput.js';
|
|
6
|
+
import '../../primitive/Select/Select.js';
|
|
7
|
+
import Label from '../../primitive/Label/Label.js';
|
|
8
|
+
|
|
9
|
+
const FormPasswordField = (allProps) => {
|
|
10
|
+
const hasValueProp = Object.prototype.hasOwnProperty.call(allProps, 'value');
|
|
11
|
+
const { id, label, error, labelClassName, className, value, required, ...props } = allProps;
|
|
12
|
+
const inputValueProps = hasValueProp ? { value: (value ?? '') } : {};
|
|
13
|
+
return (jsxs("div", { className: "w-full flex flex-col", children: [label && (jsxs(Label, { htmlFor: id, className: clsx('mb-2', labelClassName), children: [label, required ? (jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })) : null] })), jsx(PasswordInput, { id: id, "aria-invalid": !!error, "aria-describedby": error ? `${id}-error` : undefined, className: className, ...inputValueProps, ...props }), jsx("div", { className: "min-h-[25px]", children: error && (jsx(Label, { id: `${id}-error`, variant: "error", className: "mt-0.4 pl-0.7", children: error })) })] }));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { FormPasswordField as default };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Select from '../../primitive/Select/Select.js';
|
|
3
3
|
import '../../primitive/Input/Input.js';
|
|
4
|
+
import '../../primitive/CurrencyInput/CurrencyInput.js';
|
|
5
|
+
import '../../primitive/PasswordInput/PasswordInput.js';
|
|
4
6
|
import Label from '../../primitive/Label/Label.js';
|
|
5
7
|
|
|
6
8
|
const FormSelectField = ({ id, label, labelClassName, error, placeholder, options, className, required, ...props }) => {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useMemo, useState, useEffect } from 'react';
|
|
3
|
+
import Input from '../Input/Input.js';
|
|
4
|
+
|
|
5
|
+
function extractDigits(value) {
|
|
6
|
+
return (value ?? '').replace(/\D/g, '');
|
|
7
|
+
}
|
|
8
|
+
function addThousandsSeparator(intPart) {
|
|
9
|
+
return intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
10
|
+
}
|
|
11
|
+
function formatDigitsAsCurrency(digits) {
|
|
12
|
+
if (!digits)
|
|
13
|
+
return '';
|
|
14
|
+
const normalized = digits.replace(/^0+(?=\d)/, '');
|
|
15
|
+
const padded = normalized.padStart(3, '0');
|
|
16
|
+
const integerPart = addThousandsSeparator(padded.slice(0, -2));
|
|
17
|
+
const decimalPart = padded.slice(-2);
|
|
18
|
+
return `${integerPart},${decimalPart}`;
|
|
19
|
+
}
|
|
20
|
+
function normalizeCurrencyText(value) {
|
|
21
|
+
return formatDigitsAsCurrency(extractDigits(value));
|
|
22
|
+
}
|
|
23
|
+
const CurrencyInput = forwardRef((allProps, ref) => {
|
|
24
|
+
const hasValueProp = Object.prototype.hasOwnProperty.call(allProps, 'value');
|
|
25
|
+
const { value, defaultValue, onChange, onValueChange, ...props } = allProps;
|
|
26
|
+
const controlledValue = useMemo(() => normalizeCurrencyText(value), [value]);
|
|
27
|
+
const initialValue = useMemo(() => normalizeCurrencyText(defaultValue), [defaultValue]);
|
|
28
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(initialValue);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!hasValueProp) {
|
|
31
|
+
setUncontrolledValue(initialValue);
|
|
32
|
+
}
|
|
33
|
+
}, [hasValueProp, initialValue]);
|
|
34
|
+
const displayValue = hasValueProp ? controlledValue : uncontrolledValue;
|
|
35
|
+
const handleChange = (event) => {
|
|
36
|
+
const formattedValue = formatDigitsAsCurrency(extractDigits(event.target.value));
|
|
37
|
+
const nextDigits = extractDigits(formattedValue);
|
|
38
|
+
if (!hasValueProp) {
|
|
39
|
+
setUncontrolledValue(formattedValue);
|
|
40
|
+
}
|
|
41
|
+
onValueChange?.(formattedValue, nextDigits);
|
|
42
|
+
if (onChange) {
|
|
43
|
+
const nextEvent = {
|
|
44
|
+
...event,
|
|
45
|
+
target: { ...event.target, value: formattedValue },
|
|
46
|
+
currentTarget: { ...event.currentTarget, value: formattedValue },
|
|
47
|
+
};
|
|
48
|
+
onChange(nextEvent);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return (jsx(Input, { ref: ref, type: "text", inputMode: "numeric", autoComplete: "off", value: displayValue, onChange: handleChange, ...props }));
|
|
52
|
+
});
|
|
53
|
+
CurrencyInput.displayName = 'CurrencyInput';
|
|
54
|
+
|
|
55
|
+
export { CurrencyInput as default };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
|
-
import
|
|
4
|
+
import { Icon } from '../../../Brand/Identity/Icon/Icon.js';
|
|
5
|
+
import Input from '../Input/Input.js';
|
|
5
6
|
|
|
6
|
-
const EditableInput = forwardRef((
|
|
7
|
-
|
|
7
|
+
const EditableInput = forwardRef((allProps, ref) => {
|
|
8
|
+
const hasValueProp = Object.prototype.hasOwnProperty.call(allProps, 'value');
|
|
9
|
+
const { className, value, onEdit, disabled, ...props } = allProps;
|
|
10
|
+
const canEdit = !disabled && !!onEdit;
|
|
11
|
+
const inputValueProps = hasValueProp ? { value: (value ?? '') } : {};
|
|
12
|
+
return (jsxs("div", { className: clsx('w-full h-12 flex items-stretch rounded-xl border border-(--color-secondary-outline) overflow-hidden', disabled && 'bg-(--color-secondary-offwhite) cursor-not-allowed'), children: [jsx(Input, { ref: ref, disabled: disabled, className: clsx('h-full rounded-none border-0 focus:border-0 focus:ring-0', disabled && 'bg-transparent', className), ...inputValueProps, ...props }), jsx("div", { className: clsx('flex items-center justify-center border-l border-(--color-secondary-outline)', 'px-4'), children: jsx("button", { type: "button", onClick: onEdit, disabled: !canEdit, "aria-label": "Edit field", className: "inline-flex items-center justify-center disabled:cursor-not-allowed", children: jsx(Icon, { name: "edit", variant: canEdit ? 'default' : 'disabled' }) }) })] }));
|
|
8
13
|
});
|
|
9
14
|
EditableInput.displayName = 'EditableInput';
|
|
10
15
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useState } from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { Icon } from '../../../Brand/Identity/Icon/Icon.js';
|
|
5
|
+
import Input from '../Input/Input.js';
|
|
6
|
+
|
|
7
|
+
const PasswordInput = forwardRef((props, ref) => {
|
|
8
|
+
const { className, disabled, ...rest } = props;
|
|
9
|
+
const [revealed, setRevealed] = useState(false);
|
|
10
|
+
const toggleReveal = () => {
|
|
11
|
+
if (disabled)
|
|
12
|
+
return;
|
|
13
|
+
setRevealed((prev) => !prev);
|
|
14
|
+
};
|
|
15
|
+
return (jsxs("div", { className: clsx('w-full h-12 flex items-stretch rounded-xl border border-(--color-secondary-outline) overflow-hidden', disabled && 'bg-(--color-secondary-offwhite) cursor-not-allowed'), children: [jsx(Input, { ref: ref, type: revealed ? 'text' : 'password', disabled: disabled, className: clsx('h-full rounded-none border-0 focus:border-0 focus:ring-0', disabled && 'bg-transparent', className), ...rest }), jsx("div", { className: "flex items-center justify-center border-l border-(--color-secondary-outline) px-4", children: jsx("button", { type: "button", onClick: toggleReveal, disabled: disabled, "aria-label": revealed ? 'Hide password' : 'Show password', className: "inline-flex items-center justify-center disabled:cursor-not-allowed disabled:opacity-60", children: jsx(Icon, { name: revealed ? 'viewHide' : 'view', variant: "default" }) }) })] }));
|
|
16
|
+
});
|
|
17
|
+
PasswordInput.displayName = 'PasswordInput';
|
|
18
|
+
|
|
19
|
+
export { PasswordInput as default };
|
|
@@ -36,7 +36,7 @@ function Modal({ isOpen, onClose, title, children, size = 'md' }) {
|
|
|
36
36
|
sticky top-0 z-10 bg-(--color-primary-white)/95 backdrop-blur
|
|
37
37
|
transition-shadow
|
|
38
38
|
${scrolled ? 'shadow-md' : 'shadow-none'}
|
|
39
|
-
`, children: [jsx("button", { onClick: onClose, className: "cursor-pointer absolute right-5 top-4 text-xl leading-none", "aria-label": "Close", children: "\u2715" }), title && jsx("h2", { className: "text-2xl font-bold px-6 pt-5 pb-3 pr-12", children: title })] })), jsx("div", { className: `p-6 pt-4 ${title ? 'mt-0' : 'mt-10'}`, children: children })] }) }) }));
|
|
39
|
+
`, children: [jsx("button", { type: "button", onClick: onClose, className: "cursor-pointer absolute right-5 top-4 text-xl leading-none", "aria-label": "Close", children: "\u2715" }), title && jsx("h2", { className: "text-2xl font-bold px-6 pt-5 pb-3 pr-12", children: title })] })), jsx("div", { className: `p-6 pt-4 ${title ? 'mt-0' : 'mt-10'}`, children: children })] }) }) }));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export { Modal as default };
|
|
@@ -31,7 +31,7 @@ function DetailsView({ open, onClose, headerLeft: navigation, headerRight, child
|
|
|
31
31
|
}, [open]);
|
|
32
32
|
if (!open)
|
|
33
33
|
return null;
|
|
34
|
-
return (jsxs("div", { className: "fixed inset-0 z-[
|
|
34
|
+
return (jsxs("div", { className: "fixed inset-0 z-[140] flex justify-end items-stretch", children: [jsx("button", { type: "button", "aria-label": "Cerrar", onClick: onClose, className: "absolute inset-0 bg-black/60" }), jsxs("aside", { className: clsx('relative ml-auto h-full w-full max-w-[550px] bg-(--color-secondary-white) shadow-xl flex flex-col', className), children: [jsxs("header", { className: "flex items-center justify-between p-5 border-b border-(--color-secondary-outline) bg-(--color-primary-white)", children: [navigation, jsxs("div", { className: "flex items-center gap-4", children: [headerRight, jsx(Icon, { name: "burgerClose", onClick: onClose })] })] }), jsx("div", { ref: bodyRef, className: "flex-1 min-h-0 overflow-auto px-8 py-10", children: children })] })] }));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export { DetailsView as default };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useId, useRef, useState, useCallback, useLayoutEffect, isValidElement, Fragment as Fragment$1, cloneElement } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
|
|
6
|
+
const TOOLTIP_GAP = 16;
|
|
7
|
+
const POSITION_STYLES = {
|
|
8
|
+
topLeft: {
|
|
9
|
+
tailClassName: 'left-3 top-full',
|
|
10
|
+
tailStyle: {
|
|
11
|
+
clipPath: 'polygon(0 0, 100% 0, 50% 100%)',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
topRight: {
|
|
15
|
+
tailClassName: 'right-3 top-full',
|
|
16
|
+
tailStyle: {
|
|
17
|
+
clipPath: 'polygon(0 0, 100% 0, 50% 100%)',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
bottomLeft: {
|
|
21
|
+
tailClassName: 'left-3 bottom-full',
|
|
22
|
+
tailStyle: {
|
|
23
|
+
clipPath: 'polygon(50% 0, 0 100%, 100% 100%)',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
bottomRight: {
|
|
27
|
+
tailClassName: 'right-3 bottom-full',
|
|
28
|
+
tailStyle: {
|
|
29
|
+
clipPath: 'polygon(50% 0, 0 100%, 100% 100%)',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
function getTooltipCoordinates(triggerRect, tooltipRect, position, nudgeX = 0, nudgeY = 0) {
|
|
34
|
+
if (position === 'topLeft') {
|
|
35
|
+
return {
|
|
36
|
+
left: triggerRect.left + nudgeX,
|
|
37
|
+
top: triggerRect.top - tooltipRect.height - TOOLTIP_GAP + nudgeY,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (position === 'topRight') {
|
|
41
|
+
return {
|
|
42
|
+
left: triggerRect.right - tooltipRect.width + nudgeX,
|
|
43
|
+
top: triggerRect.top - tooltipRect.height - TOOLTIP_GAP + nudgeY,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (position === 'bottomLeft') {
|
|
47
|
+
return {
|
|
48
|
+
left: triggerRect.left + nudgeX,
|
|
49
|
+
top: triggerRect.bottom + TOOLTIP_GAP + nudgeY,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
left: triggerRect.right - tooltipRect.width + nudgeX,
|
|
54
|
+
top: triggerRect.bottom + TOOLTIP_GAP + nudgeY,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function Tooltip({ children, title, position = 'topLeft', nudgeX = 0, nudgeY = 0 }) {
|
|
58
|
+
const tooltipId = useId();
|
|
59
|
+
const triggerRef = useRef(null);
|
|
60
|
+
const tooltipRef = useRef(null);
|
|
61
|
+
const [open, setOpen] = useState(false);
|
|
62
|
+
const [isPositioned, setIsPositioned] = useState(false);
|
|
63
|
+
const [coordinates, setCoordinates] = useState({ left: 0, top: 0 });
|
|
64
|
+
const positionStyle = POSITION_STYLES[position];
|
|
65
|
+
const updatePosition = useCallback(() => {
|
|
66
|
+
const triggerElement = triggerRef.current;
|
|
67
|
+
const tooltipElement = tooltipRef.current;
|
|
68
|
+
if (!triggerElement || !tooltipElement)
|
|
69
|
+
return;
|
|
70
|
+
const nextCoordinates = getTooltipCoordinates(triggerElement.getBoundingClientRect(), tooltipElement.getBoundingClientRect(), position, nudgeX, nudgeY);
|
|
71
|
+
setCoordinates((currentCoordinates) => {
|
|
72
|
+
if (currentCoordinates.left === nextCoordinates.left && currentCoordinates.top === nextCoordinates.top) {
|
|
73
|
+
return currentCoordinates;
|
|
74
|
+
}
|
|
75
|
+
return nextCoordinates;
|
|
76
|
+
});
|
|
77
|
+
setIsPositioned(true);
|
|
78
|
+
}, [nudgeX, nudgeY, position]);
|
|
79
|
+
useLayoutEffect(() => {
|
|
80
|
+
if (!open)
|
|
81
|
+
return;
|
|
82
|
+
setIsPositioned(false);
|
|
83
|
+
updatePosition();
|
|
84
|
+
const handleViewportChange = () => updatePosition();
|
|
85
|
+
window.addEventListener('resize', handleViewportChange);
|
|
86
|
+
window.addEventListener('scroll', handleViewportChange, true);
|
|
87
|
+
return () => {
|
|
88
|
+
window.removeEventListener('resize', handleViewportChange);
|
|
89
|
+
window.removeEventListener('scroll', handleViewportChange, true);
|
|
90
|
+
};
|
|
91
|
+
}, [open, updatePosition]);
|
|
92
|
+
if (!title) {
|
|
93
|
+
return jsx(Fragment, { children: children });
|
|
94
|
+
}
|
|
95
|
+
const trigger = isValidElement(children) && children.type !== Fragment$1
|
|
96
|
+
? cloneElement(children, {
|
|
97
|
+
'aria-describedby': open ? tooltipId : undefined,
|
|
98
|
+
})
|
|
99
|
+
: children;
|
|
100
|
+
return (jsxs(Fragment, { children: [jsx("span", { ref: triggerRef, className: "inline-flex max-w-full", onMouseEnter: () => setOpen(true), onMouseLeave: () => setOpen(false), onFocus: () => setOpen(true), onBlur: () => setOpen(false), "aria-describedby": !isValidElement(children) && open ? tooltipId : undefined, children: trigger }), open
|
|
101
|
+
? createPortal(jsx("span", { ref: tooltipRef, id: tooltipId, role: "tooltip", "aria-hidden": "true", className: clsx('pointer-events-none fixed z-[1200] ', isPositioned ? 'opacity-100' : 'opacity-0'), style: {
|
|
102
|
+
left: coordinates.left,
|
|
103
|
+
top: coordinates.top,
|
|
104
|
+
}, children: jsxs("span", { className: clsx('relative block rounded-[10px] bg-(--color-primary-purple)', 'px-2.5 py-1.5 text-xs font-normal text-(--color-primary-white)', 'shadow-xl'), children: [jsx("span", { className: clsx('absolute h-2 w-4 bg-inherit', positionStyle.tailClassName), style: positionStyle.tailStyle, "aria-hidden": "true" }), title] }) }), document.body)
|
|
105
|
+
: null] }));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { Tooltip as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var ViewHideIconPurple = "data:image/svg+xml,%3Csvg width=%2220%22 height=%2216%22 viewBox=%220 0 20 16%22 fill=%22none%22 xmlns=%22http://www.w3.org/2000/svg%22%3E%3Cpath d=%22M16.3801 8.06313C17.2416 7.20164 17.925 6.17891 18.3912 5.05332C18.6058 4.53525 18.7725 4.00006 18.8899 3.45447M16.3801 8.06313C15.5187 8.92462 14.4959 9.60798 13.3703 10.0742C12.9958 10.2294 12.6123 10.3595 12.2223 10.464M16.3801 8.06313L17.9537 9.63666M3.25991 8.06313C4.1214 8.92462 5.14413 9.60798 6.26972 10.0742C6.64428 10.2294 7.02779 10.3595 7.41772 10.464M3.25991 8.06313C2.39842 7.20164 1.71506 6.17891 1.24882 5.05332C1.03423 4.53525 0.867572 4.00006 0.750183 3.45447M3.25991 8.06313L1.68637 9.63666M7.41772 10.464C8.19953 10.6736 9.00712 10.7804 9.82003 10.7804C10.6329 10.7804 11.4405 10.6736 12.2223 10.464M7.41772 10.464L6.85997 12.5455M12.2223 10.464L12.7801 12.5455%22 stroke=%22%236F2DF3%22 stroke-width=%221.5%22 stroke-linecap=%22round%22/%3E%3C/svg%3E";
|
|
2
|
+
|
|
3
|
+
export { ViewHideIconPurple as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var ViewHideIcon = "data:image/svg+xml,%3Csvg width=%2220%22 height=%2216%22 viewBox=%220 0 20 16%22 fill=%22none%22 xmlns=%22http://www.w3.org/2000/svg%22%3E%3Cpath d=%22M16.3801 8.06313C17.2416 7.20164 17.925 6.17891 18.3912 5.05332C18.6058 4.53525 18.7725 4.00006 18.8899 3.45447M16.3801 8.06313C15.5187 8.92462 14.4959 9.60798 13.3703 10.0742C12.9958 10.2294 12.6123 10.3595 12.2223 10.464M16.3801 8.06313L17.9537 9.63666M3.25991 8.06313C4.1214 8.92462 5.14413 9.60798 6.26972 10.0742C6.64428 10.2294 7.02779 10.3595 7.41772 10.464M3.25991 8.06313C2.39842 7.20164 1.71506 6.17891 1.24882 5.05332C1.03423 4.53525 0.867572 4.00006 0.750183 3.45447M3.25991 8.06313L1.68637 9.63666M7.41772 10.464C8.19953 10.6736 9.00712 10.7804 9.82003 10.7804C10.6329 10.7804 11.4405 10.6736 12.2223 10.464M7.41772 10.464L6.85997 12.5455M12.2223 10.464L12.7801 12.5455%22 stroke=%22%23070707%22 stroke-width=%221.5%22 stroke-linecap=%22round%22/%3E%3C/svg%3E";
|
|
2
|
+
|
|
3
|
+
export { ViewHideIcon as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare function ButtonRow({ items, className, innerClassName }: ButtonRowProps)
|
|
|
34
34
|
type GoogleButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
35
35
|
declare const GoogleButton: ({ className, children, ...props }: GoogleButtonProps) => react_jsx_runtime.JSX.Element;
|
|
36
36
|
|
|
37
|
-
type IconName = 'ogIcon' | 'switcher' | 'tick' | 'view' | 'open' | 'burger' | 'burgerClose' | 'arrowLongLeft' | 'catalog' | 'copyLink' | 'clapper' | 'clapperManage' | 'clock' | 'file' | 'filter' | 'profile' | 'settings' | 'cross' | 'edit' | 'mail' | 'location' | 'calendar' | 'behance' | 'imdb' | 'plus' | 'whatsapp' | 'vimeo' | 'instagram' | 'x' | 'tikTok' | 'linkedin' | 'delete' | 'save' | 'publish' | 'overflowmenu' | 'applicants' | 'search' | 'info' | 'play' | 'web' | 'warning' | 'logout';
|
|
37
|
+
type IconName = 'ogIcon' | 'switcher' | 'tick' | 'view' | 'viewHide' | 'open' | 'burger' | 'burgerClose' | 'arrowLongLeft' | 'catalog' | 'copyLink' | 'clapper' | 'clapperManage' | 'clock' | 'file' | 'filter' | 'profile' | 'settings' | 'cross' | 'edit' | 'mail' | 'location' | 'calendar' | 'behance' | 'imdb' | 'plus' | 'whatsapp' | 'vimeo' | 'instagram' | 'x' | 'tikTok' | 'linkedin' | 'delete' | 'save' | 'publish' | 'overflowmenu' | 'applicants' | 'search' | 'info' | 'play' | 'web' | 'warning' | 'logout';
|
|
38
38
|
type IconVariant = 'default' | 'primary' | 'white' | 'success' | 'danger' | 'disabled';
|
|
39
39
|
type IconProps = Omit<ImgHTMLAttributes<HTMLImageElement>, 'src'> & {
|
|
40
40
|
name: IconName;
|
|
@@ -189,6 +189,16 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, '
|
|
|
189
189
|
}
|
|
190
190
|
declare const Input: React$1.ForwardRefExoticComponent<InputProps & React$1.RefAttributes<HTMLInputElement>>;
|
|
191
191
|
|
|
192
|
+
declare const CurrencyInput: React$1.ForwardRefExoticComponent<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "type"> & {
|
|
193
|
+
value?: string;
|
|
194
|
+
defaultValue?: string;
|
|
195
|
+
onValueChange?: (formattedValue: string, rawDigits: string) => void;
|
|
196
|
+
} & React$1.RefAttributes<HTMLInputElement>>;
|
|
197
|
+
|
|
198
|
+
declare const PasswordInput: React$1.ForwardRefExoticComponent<Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "type"> & {
|
|
199
|
+
type?: "password";
|
|
200
|
+
} & React$1.RefAttributes<HTMLInputElement>>;
|
|
201
|
+
|
|
192
202
|
type SelectOption = {
|
|
193
203
|
value: string;
|
|
194
204
|
label: string;
|
|
@@ -213,7 +223,26 @@ type FormInputFieldProps = React$1.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
213
223
|
editable?: boolean;
|
|
214
224
|
onEdit?: () => void;
|
|
215
225
|
};
|
|
216
|
-
declare const FormInputField: (
|
|
226
|
+
declare const FormInputField: (allProps: FormInputFieldProps) => react_jsx_runtime.JSX.Element;
|
|
227
|
+
|
|
228
|
+
type FormCurrencyFieldProps = Omit<React$1.InputHTMLAttributes<HTMLInputElement>, 'type'> & {
|
|
229
|
+
id: string;
|
|
230
|
+
label?: string;
|
|
231
|
+
error?: string;
|
|
232
|
+
labelClassName?: string;
|
|
233
|
+
value?: string;
|
|
234
|
+
defaultValue?: string;
|
|
235
|
+
onValueChange?: (formattedValue: string, rawDigits: string) => void;
|
|
236
|
+
};
|
|
237
|
+
declare const FormCurrencyField: (allProps: FormCurrencyFieldProps) => react_jsx_runtime.JSX.Element;
|
|
238
|
+
|
|
239
|
+
type FormPasswordFieldProps = Omit<React$1.InputHTMLAttributes<HTMLInputElement>, 'type'> & {
|
|
240
|
+
id: string;
|
|
241
|
+
label?: string;
|
|
242
|
+
error?: string;
|
|
243
|
+
labelClassName?: string;
|
|
244
|
+
};
|
|
245
|
+
declare const FormPasswordField: (allProps: FormPasswordFieldProps) => react_jsx_runtime.JSX.Element;
|
|
217
246
|
|
|
218
247
|
type Props$4 = React__default.SelectHTMLAttributes<HTMLSelectElement> & {
|
|
219
248
|
id: string;
|
|
@@ -361,6 +390,16 @@ type ModalProps = {
|
|
|
361
390
|
};
|
|
362
391
|
declare function Modal({ isOpen, onClose, title, children, size }: ModalProps): react_jsx_runtime.JSX.Element | null;
|
|
363
392
|
|
|
393
|
+
type TooltipPosition = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
394
|
+
type TooltipProps = {
|
|
395
|
+
children: React.ReactNode;
|
|
396
|
+
title: string;
|
|
397
|
+
position?: TooltipPosition;
|
|
398
|
+
nudgeX?: number;
|
|
399
|
+
nudgeY?: number;
|
|
400
|
+
};
|
|
401
|
+
declare function Tooltip({ children, title, position, nudgeX, nudgeY }: TooltipProps): react_jsx_runtime.JSX.Element;
|
|
402
|
+
|
|
364
403
|
type DetailsViewProps = {
|
|
365
404
|
open: boolean;
|
|
366
405
|
onClose: () => void;
|
|
@@ -388,5 +427,5 @@ type WizardProps = {
|
|
|
388
427
|
};
|
|
389
428
|
declare function Wizard({ children }: WizardProps): ReactElement<WizardStepProps, string | React$1.JSXElementConstructor<any>>;
|
|
390
429
|
|
|
391
|
-
export { Button, ButtonRow, ChevronLeft, ChevronRight, ChevronUpDown, Chip, DetailsView, FormInputField, FormSelectField, FullscreenCenter, GoogleButton, HilighterSvg, Icon, ImageCarousel, Input, Label, Logo, Modal, OverflowMenu, PhotoZoomOverlay, Pills, SearchInput, SearchWithSuggestions, Select, Separator, Spinner, StatusChip, TextDropdownTrigger, Toast, ToastProvider, UniversalVideoPlayer, UploadTile, VideoPreviewCard, Wizard, WizardStep, clearToasts, dismissToast, showToast, useDebouncedValue, useToast, useViewportVhVar };
|
|
392
|
-
export type { IconName, IconVariant, OverflowMenuAlign, OverflowMenuItem, OverflowMenuSide, PillItem, ShowToastOptions, ToastContent, ToastContextValue, ToastPosition, ToastProps, ToastRecord, ToastType, UniversalVideoPlayerProps, VideoProvider, WizardStepProps };
|
|
430
|
+
export { Button, ButtonRow, ChevronLeft, ChevronRight, ChevronUpDown, Chip, CurrencyInput, DetailsView, FormCurrencyField, FormInputField, FormPasswordField, FormSelectField, FullscreenCenter, GoogleButton, HilighterSvg, Icon, ImageCarousel, Input, Label, Logo, Modal, OverflowMenu, PasswordInput, PhotoZoomOverlay, Pills, SearchInput, SearchWithSuggestions, Select, Separator, Spinner, StatusChip, TextDropdownTrigger, Toast, ToastProvider, Tooltip, UniversalVideoPlayer, UploadTile, VideoPreviewCard, Wizard, WizardStep, clearToasts, dismissToast, showToast, useDebouncedValue, useToast, useViewportVhVar };
|
|
431
|
+
export type { IconName, IconVariant, OverflowMenuAlign, OverflowMenuItem, OverflowMenuSide, PillItem, ShowToastOptions, ToastContent, ToastContextValue, ToastPosition, ToastProps, ToastRecord, ToastType, TooltipPosition, TooltipProps, UniversalVideoPlayerProps, VideoProvider, WizardStepProps };
|
package/dist/index.js
CHANGED
|
@@ -16,9 +16,13 @@ export { default as StatusChip } from './components/Feedback/Status/Chip/StatusC
|
|
|
16
16
|
export { default as Toast } from './components/Feedback/Toast/Toast.js';
|
|
17
17
|
export { ToastProvider, clearToasts, dismissToast, showToast, useToast } from './components/Feedback/Toast/ToastProvider.js';
|
|
18
18
|
export { default as Input } from './components/Forms/primitive/Input/Input.js';
|
|
19
|
+
export { default as CurrencyInput } from './components/Forms/primitive/CurrencyInput/CurrencyInput.js';
|
|
20
|
+
export { default as PasswordInput } from './components/Forms/primitive/PasswordInput/PasswordInput.js';
|
|
19
21
|
export { default as Select } from './components/Forms/primitive/Select/Select.js';
|
|
20
22
|
export { default as Label } from './components/Forms/primitive/Label/Label.js';
|
|
21
23
|
export { default as FormInputField } from './components/Forms/Fields/FormInputField/FormInputField.js';
|
|
24
|
+
export { default as FormCurrencyField } from './components/Forms/Fields/FormCurrencyField/FormCurrencyField.js';
|
|
25
|
+
export { default as FormPasswordField } from './components/Forms/Fields/FormPasswordField/FormPasswordField.js';
|
|
22
26
|
export { default as FormSelectField } from './components/Forms/Fields/FormSelectField/FormSelectField.js';
|
|
23
27
|
export { default as SearchInput } from './components/Forms/Search/SearchInput.js';
|
|
24
28
|
export { default as SearchWithSuggestions } from './components/Forms/Search/SearchWithSuggestions.js';
|
|
@@ -32,6 +36,7 @@ export { default as ChevronRight } from './components/Navigation/Indicators/Chev
|
|
|
32
36
|
export { default as ChevronUpDown } from './components/Navigation/Indicators/Chevron/ChevronUpDown.js';
|
|
33
37
|
export { default as Pills } from './components/Navigation/Selection/Pills/Pills.js';
|
|
34
38
|
export { default as Modal } from './components/Overlays/Dialogs/Modal/Modal.js';
|
|
39
|
+
export { default as Tooltip } from './components/Overlays/Tooltip/Tooltip.js';
|
|
35
40
|
export { default as DetailsView } from './components/Overlays/Panels/DetailsView/DetailsView.js';
|
|
36
41
|
export { default as Wizard } from './components/Flows/Wizard/Wizard.js';
|
|
37
42
|
export { default as WizardStep } from './components/Flows/Wizard/WizardStep.js';
|