@yr3/ui 1.0.4 → 1.0.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/Input/input.css +0 -37
- package/dist/components/Input/input.css.map +1 -1
- package/dist/components/Phone/phone.css +20 -0
- package/dist/components/Phone/phone.css.map +1 -0
- package/dist/components/Places/places.css +19 -0
- package/dist/components/Places/places.css.map +1 -0
- package/dist/components/Select/select.css +0 -23
- package/dist/components/Select/select.css.map +1 -1
- package/dist/components/Selector/selector.css +47 -0
- package/dist/components/Selector/selector.css.map +1 -0
- package/dist/components/Switch/switch.css +8 -6
- package/dist/components/Switch/switch.css.map +1 -1
- package/dist/index.cjs +346 -163
- package/dist/index.d.cts +88 -60
- package/dist/index.d.ts +88 -60
- package/dist/index.js +346 -170
- package/dist/styles/index.css +68 -43
- package/dist/styles/index.css.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -63,6 +64,7 @@ __export(index_exports, {
|
|
|
63
64
|
NotistackProvider: () => NotistackProvider,
|
|
64
65
|
Pending: () => Pending,
|
|
65
66
|
Phone: () => Phone,
|
|
67
|
+
PlacesAutocomplete: () => PlacesAutocomplete,
|
|
66
68
|
Radio: () => Radio,
|
|
67
69
|
Select: () => Select,
|
|
68
70
|
Slide: () => Slide,
|
|
@@ -82,9 +84,13 @@ __export(index_exports, {
|
|
|
82
84
|
createVariants: () => createVariants,
|
|
83
85
|
cx: () => cx,
|
|
84
86
|
getContrast: () => getContrast,
|
|
87
|
+
getCountryCodePhone: () => getCountryCodePhone,
|
|
88
|
+
getDialPhone: () => getDialPhone,
|
|
85
89
|
getMonthCalendar: () => getMonthCalendar,
|
|
90
|
+
getNumberPhone: () => getNumberPhone,
|
|
86
91
|
initTheme: () => initTheme,
|
|
87
92
|
isEmpty: () => isEmpty,
|
|
93
|
+
normalizePhone: () => normalizePhone,
|
|
88
94
|
text: () => text,
|
|
89
95
|
times: () => times,
|
|
90
96
|
uiStyle: () => uiStyle,
|
|
@@ -350,6 +356,49 @@ var createVariants = (config) => {
|
|
|
350
356
|
};
|
|
351
357
|
};
|
|
352
358
|
|
|
359
|
+
// src/utils/phone.ts
|
|
360
|
+
var normalizePhone = (phone, dial) => {
|
|
361
|
+
if (!phone) return null;
|
|
362
|
+
let clean = phone.replace(/[^\d+]/g, "");
|
|
363
|
+
let number = clean;
|
|
364
|
+
if (clean.startsWith(dial)) {
|
|
365
|
+
number = clean.slice(dial.length);
|
|
366
|
+
} else if (clean.startsWith("+")) {
|
|
367
|
+
const match = clean.match(/^\+\d{1,3}(.*)$/);
|
|
368
|
+
if (match) {
|
|
369
|
+
number = match[1];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
number = number.replace(/^0+/, "");
|
|
373
|
+
return {
|
|
374
|
+
number,
|
|
375
|
+
full: `${dial}${number}`
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
var getDialPhone = (phone, countries) => {
|
|
379
|
+
for (const country of countries) {
|
|
380
|
+
console.log("checking", phone, "against", country.dial);
|
|
381
|
+
if (phone.startsWith(country.dial)) {
|
|
382
|
+
return country.dial;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
};
|
|
387
|
+
var getCountryCodePhone = (phone, countries) => {
|
|
388
|
+
for (const country of countries) {
|
|
389
|
+
if (phone.startsWith(country.dial)) {
|
|
390
|
+
return country.code;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
394
|
+
};
|
|
395
|
+
var getNumberPhone = (phone, dial) => {
|
|
396
|
+
if (phone.startsWith(dial)) {
|
|
397
|
+
return phone.slice(dial.length);
|
|
398
|
+
}
|
|
399
|
+
return phone;
|
|
400
|
+
};
|
|
401
|
+
|
|
353
402
|
// src/theme/breakpoint.ts
|
|
354
403
|
var breakpoints = {
|
|
355
404
|
xs: 0,
|
|
@@ -513,6 +562,9 @@ function initTheme() {
|
|
|
513
562
|
applyTheme(createTheme());
|
|
514
563
|
}
|
|
515
564
|
|
|
565
|
+
// src/index.ts
|
|
566
|
+
__reExport(index_exports, require("@yr3/autocomplete-places"), module.exports);
|
|
567
|
+
|
|
516
568
|
// src/components/Avatar/Avatar.tsx
|
|
517
569
|
var React = __toESM(require("react"), 1);
|
|
518
570
|
|
|
@@ -1669,143 +1721,13 @@ var Input = React12.forwardRef(
|
|
|
1669
1721
|
"data-testid": "yr3Input"
|
|
1670
1722
|
}
|
|
1671
1723
|
),
|
|
1672
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { variant: "helper", "data-testid": "yr3Input-helper", children: error || internalError || "" })
|
|
1724
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { variant: "helper", color: "disabled", "data-testid": "yr3Input-helper", ui: { position: "absolute", bottom: -18, left: 0 }, children: error || internalError || "" })
|
|
1673
1725
|
] });
|
|
1674
1726
|
}
|
|
1675
1727
|
);
|
|
1676
1728
|
|
|
1677
|
-
// src/components/Input/InputPhone.tsx
|
|
1678
|
-
var React15 = __toESM(require("react"), 1);
|
|
1679
|
-
|
|
1680
|
-
// src/components/Select/Selector.tsx
|
|
1681
|
-
var React13 = __toESM(require("react"), 1);
|
|
1682
|
-
|
|
1683
|
-
// src/Icons/IconDown.tsx
|
|
1684
|
-
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1685
|
-
var IconDown = (props) => {
|
|
1686
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { width: props.width || "64px", height: props.height || "64px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-testid": "yr3Icons", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M7 10L12 15L17 10", stroke: props.stroke || "#fff", strokeWidth: props.strokeWidth || "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1687
|
-
};
|
|
1688
|
-
|
|
1689
|
-
// src/components/Select/Selector.tsx
|
|
1690
|
-
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1691
|
-
var Selector = ({ ui, style, options, name, value, defaultValue, onChange, iconColor, icon }) => {
|
|
1692
|
-
const [open, setOpen] = React13.useState(false);
|
|
1693
|
-
const [valueState, setValueState] = React13.useState(value || defaultValue || null);
|
|
1694
|
-
const ref = React13.useRef(null);
|
|
1695
|
-
useClickAway(ref, () => setOpen(false));
|
|
1696
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "yr3Selector-wrapper", ref, children: [
|
|
1697
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: `yr3Selector ${open ? "yr3Selector--open" : ""}`, style: composeStyles(ui, style), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "yr3Selector--control", children: [
|
|
1698
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "yr3Selector--icon", onClick: () => setOpen((prev) => !prev), children: icon ? icon : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconDown, { stroke: `var(--color-${iconColor || "disabled"})`, width: 24, height: 24 }) }),
|
|
1699
|
-
valueState
|
|
1700
|
-
] }) }),
|
|
1701
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "yr3Select--menu", children: options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1702
|
-
"div",
|
|
1703
|
-
{
|
|
1704
|
-
className: "yr3Select--option",
|
|
1705
|
-
onClick: (e) => {
|
|
1706
|
-
e.stopPropagation();
|
|
1707
|
-
setValueState(opt.value);
|
|
1708
|
-
setOpen(false);
|
|
1709
|
-
const event = {
|
|
1710
|
-
event: e,
|
|
1711
|
-
target: {
|
|
1712
|
-
name,
|
|
1713
|
-
value: opt.value
|
|
1714
|
-
},
|
|
1715
|
-
currentTarget: {
|
|
1716
|
-
name,
|
|
1717
|
-
value: opt.value
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
onChange?.(event, opt.value);
|
|
1721
|
-
},
|
|
1722
|
-
children: opt.label
|
|
1723
|
-
},
|
|
1724
|
-
opt.value
|
|
1725
|
-
)) })
|
|
1726
|
-
] });
|
|
1727
|
-
};
|
|
1728
|
-
var Selector_default = Selector;
|
|
1729
|
-
|
|
1730
|
-
// src/theme/ThemeProvider.tsx
|
|
1731
|
-
var React14 = __toESM(require("react"), 1);
|
|
1732
|
-
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1733
|
-
var ThemeContext = React14.createContext(null);
|
|
1734
|
-
var ThemeProvider = ({ theme, children }) => {
|
|
1735
|
-
React14.useEffect(() => {
|
|
1736
|
-
applyTheme(theme);
|
|
1737
|
-
}, [theme]);
|
|
1738
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(BackdropProvider, { children }) });
|
|
1739
|
-
};
|
|
1740
|
-
var useTheme = () => React14.useContext(ThemeContext);
|
|
1741
|
-
|
|
1742
|
-
// src/components/Input/InputPhone.tsx
|
|
1743
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1744
|
-
var Phone = ({
|
|
1745
|
-
name,
|
|
1746
|
-
value,
|
|
1747
|
-
onChange,
|
|
1748
|
-
prefix = "+39",
|
|
1749
|
-
label = "Phone",
|
|
1750
|
-
countries = [],
|
|
1751
|
-
propsComponent
|
|
1752
|
-
}) => {
|
|
1753
|
-
const [prefixValue, setPrefixValue] = React15.useState(prefix);
|
|
1754
|
-
const [number, setNumber] = React15.useState(Number(value) || null);
|
|
1755
|
-
const theme = useTheme();
|
|
1756
|
-
const handleChange = (newPrefix, newNumber) => {
|
|
1757
|
-
const full = `${newPrefix}${newNumber.toString()}`;
|
|
1758
|
-
const event = {
|
|
1759
|
-
target: {
|
|
1760
|
-
name,
|
|
1761
|
-
value: full
|
|
1762
|
-
}
|
|
1763
|
-
};
|
|
1764
|
-
onChange?.(event, full);
|
|
1765
|
-
};
|
|
1766
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Control, { variant: "outlined", children: [
|
|
1767
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Label, { text: label, className: "yr3Input--active" }),
|
|
1768
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "yr3PhoneInput", "data-testid": "yr3Phone", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Flex, { variant: "row", container: true, center: true, children: [
|
|
1769
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1770
|
-
Selector_default,
|
|
1771
|
-
{
|
|
1772
|
-
options: countries.map((c) => ({
|
|
1773
|
-
value: c.dial,
|
|
1774
|
-
label: c.code
|
|
1775
|
-
})),
|
|
1776
|
-
value: prefixValue,
|
|
1777
|
-
onChange: (_, val) => {
|
|
1778
|
-
setPrefixValue(val);
|
|
1779
|
-
handleChange(val, number);
|
|
1780
|
-
},
|
|
1781
|
-
...propsComponent?.selector,
|
|
1782
|
-
ui: {
|
|
1783
|
-
...propsComponent?.selector?.ui,
|
|
1784
|
-
padding: 4
|
|
1785
|
-
},
|
|
1786
|
-
style: propsComponent?.selector?.style
|
|
1787
|
-
}
|
|
1788
|
-
),
|
|
1789
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Divider, { orientation: "vertical", ...propsComponent?.divider }),
|
|
1790
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1791
|
-
Input,
|
|
1792
|
-
{
|
|
1793
|
-
type: "phone",
|
|
1794
|
-
variant: "base",
|
|
1795
|
-
value: number,
|
|
1796
|
-
...propsComponent?.input,
|
|
1797
|
-
onChange: (e, value2) => {
|
|
1798
|
-
setNumber(value2);
|
|
1799
|
-
handleChange(prefixValue, value2);
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
)
|
|
1803
|
-
] }) })
|
|
1804
|
-
] });
|
|
1805
|
-
};
|
|
1806
|
-
|
|
1807
1729
|
// src/components/InputArea/InputArea.tsx
|
|
1808
|
-
var
|
|
1730
|
+
var React13 = __toESM(require("react"), 1);
|
|
1809
1731
|
|
|
1810
1732
|
// src/components/InputArea/inputAreaVariants.ts
|
|
1811
1733
|
var inputAreaVariants = createVariants({
|
|
@@ -1841,7 +1763,7 @@ var inputAreaVariants = createVariants({
|
|
|
1841
1763
|
});
|
|
1842
1764
|
|
|
1843
1765
|
// src/components/InputArea/InputArea.tsx
|
|
1844
|
-
var
|
|
1766
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1845
1767
|
var initiaPropsComponent2 = {
|
|
1846
1768
|
label: {
|
|
1847
1769
|
display: true,
|
|
@@ -1866,8 +1788,8 @@ var InputArea = ({
|
|
|
1866
1788
|
rounded = false,
|
|
1867
1789
|
propsComponent = initiaPropsComponent2
|
|
1868
1790
|
}) => {
|
|
1869
|
-
const ref =
|
|
1870
|
-
const [internalValue, setInternalValue] =
|
|
1791
|
+
const ref = React13.useRef(null);
|
|
1792
|
+
const [internalValue, setInternalValue] = React13.useState(defaultValue);
|
|
1871
1793
|
const isControlled = value !== void 0;
|
|
1872
1794
|
const currentValue = isControlled ? value : internalValue;
|
|
1873
1795
|
const handleChange = (e) => {
|
|
@@ -1884,8 +1806,8 @@ var InputArea = ({
|
|
|
1884
1806
|
el.style.resize = resize;
|
|
1885
1807
|
}
|
|
1886
1808
|
const classes = inputAreaVariants({ variant, color, rounded });
|
|
1887
|
-
return /* @__PURE__ */ (0,
|
|
1888
|
-
propsComponent?.label?.display && /* @__PURE__ */ (0,
|
|
1809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { position: "relative" }, children: [
|
|
1810
|
+
propsComponent?.label?.display && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1889
1811
|
Label,
|
|
1890
1812
|
{
|
|
1891
1813
|
text: label || "",
|
|
@@ -1893,7 +1815,7 @@ var InputArea = ({
|
|
|
1893
1815
|
...propsComponent.label
|
|
1894
1816
|
}
|
|
1895
1817
|
),
|
|
1896
|
-
/* @__PURE__ */ (0,
|
|
1818
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1897
1819
|
"textarea",
|
|
1898
1820
|
{
|
|
1899
1821
|
className: classes,
|
|
@@ -1905,26 +1827,26 @@ var InputArea = ({
|
|
|
1905
1827
|
"data-testid": "yr3InputArea"
|
|
1906
1828
|
}
|
|
1907
1829
|
),
|
|
1908
|
-
/* @__PURE__ */ (0,
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Text, { variant: "helper", color: currentValue.length > maxLength ? "error" : "disabled", ui: { textAlign: "right" }, "data-testid": "yr3InputAreaError", children: validate && maxLength ? `${currentValue.length}/${maxLength}` || propsComponent.helperText : "" })
|
|
1909
1831
|
] });
|
|
1910
1832
|
};
|
|
1911
1833
|
|
|
1912
1834
|
// src/components/Modal/Modal.tsx
|
|
1913
|
-
var
|
|
1835
|
+
var React14 = __toESM(require("react"), 1);
|
|
1914
1836
|
|
|
1915
1837
|
// src/components/Modal/ModalContainer.tsx
|
|
1916
|
-
var
|
|
1838
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1917
1839
|
var ModalContainer = ({ children, size = "sm", ui, style }) => {
|
|
1918
1840
|
const classes = bem("yr3Modal-container");
|
|
1919
1841
|
const classComponent = classes(void 0, { [`${size}`]: !!size });
|
|
1920
|
-
return /* @__PURE__ */ (0,
|
|
1842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: classComponent, style: composeStyles(ui, style), "data-testid": "yr3Modal-container", children });
|
|
1921
1843
|
};
|
|
1922
1844
|
|
|
1923
1845
|
// src/components/Modal/Modal.tsx
|
|
1924
|
-
var
|
|
1846
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1925
1847
|
var Modal = ({ open, onClose, children, propsComponent }) => {
|
|
1926
1848
|
const { show, hide } = useBackdrop();
|
|
1927
|
-
|
|
1849
|
+
React14.useEffect(() => {
|
|
1928
1850
|
if (open) {
|
|
1929
1851
|
show();
|
|
1930
1852
|
} else {
|
|
@@ -1933,9 +1855,9 @@ var Modal = ({ open, onClose, children, propsComponent }) => {
|
|
|
1933
1855
|
}, [open, show]);
|
|
1934
1856
|
const classes = bem("yr3Modal");
|
|
1935
1857
|
const classComponent = classes(void 0, { "open": !!open });
|
|
1936
|
-
return /* @__PURE__ */ (0,
|
|
1858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: classComponent, onClick: (e) => e.stopPropagation(), "data-testid": "yr3Modal", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ModalContainer, { ...propsComponent?.container, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Flex, { variant: "column", container: true, center: true, gap: 1, children: [
|
|
1937
1859
|
children,
|
|
1938
|
-
propsComponent?.close ? propsComponent.close : /* @__PURE__ */ (0,
|
|
1860
|
+
propsComponent?.close ? propsComponent.close : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Button, { variant: "filled", color: "secondary", onClick: onClose, "data-testid": "yr3Modal-close", children: "Close" })
|
|
1939
1861
|
] }) }) });
|
|
1940
1862
|
};
|
|
1941
1863
|
|
|
@@ -1975,15 +1897,15 @@ var notistackVariants = createVariants({
|
|
|
1975
1897
|
});
|
|
1976
1898
|
|
|
1977
1899
|
// src/components/Notistack/Notistack.tsx
|
|
1978
|
-
var
|
|
1900
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1979
1901
|
var Notistack = ({ message, duration = 3e3, variant = "info", color, propsComponent, anchor, exiting = false }) => {
|
|
1980
1902
|
const classes = notistackVariants({ type: variant, color, exiting, direction: `${anchor?.vertical || "bottom"}-${anchor?.horizontal || "right"}` });
|
|
1981
1903
|
const containerStyle = composeStyles(propsComponent?.container?.ui, propsComponent?.container?.style);
|
|
1982
1904
|
const notistackStyle = composeStyles(propsComponent?.notistack?.ui, propsComponent?.notistack?.style);
|
|
1983
1905
|
const progressStyle = composeStyles(propsComponent?.progress?.ui, propsComponent?.progress?.style);
|
|
1984
|
-
return /* @__PURE__ */ (0,
|
|
1985
|
-
/* @__PURE__ */ (0,
|
|
1986
|
-
/* @__PURE__ */ (0,
|
|
1906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: classes, "data-testid": "yr3Notistack", style: notistackStyle, children: [
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { style: containerStyle, children: message }),
|
|
1908
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1987
1909
|
"div",
|
|
1988
1910
|
{
|
|
1989
1911
|
className: "yr3Notistack--progress",
|
|
@@ -2017,7 +1939,7 @@ var pendingVariants = createVariants({
|
|
|
2017
1939
|
});
|
|
2018
1940
|
|
|
2019
1941
|
// src/components/Pending/Pending.tsx
|
|
2020
|
-
var
|
|
1942
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2021
1943
|
var Pending = ({
|
|
2022
1944
|
variant,
|
|
2023
1945
|
width,
|
|
@@ -2030,7 +1952,7 @@ var Pending = ({
|
|
|
2030
1952
|
const widthStyle = variant === "circle" ? size : width;
|
|
2031
1953
|
const heightStyle = variant === "circle" ? size : height;
|
|
2032
1954
|
const uiStylePending = uiStyle({ width: widthStyle, height: heightStyle, ...ui });
|
|
2033
|
-
return /* @__PURE__ */ (0,
|
|
1955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2034
1956
|
"div",
|
|
2035
1957
|
{
|
|
2036
1958
|
className: pendingVariants({ variant, color }),
|
|
@@ -2040,6 +1962,249 @@ var Pending = ({
|
|
|
2040
1962
|
);
|
|
2041
1963
|
};
|
|
2042
1964
|
|
|
1965
|
+
// src/components/Phone/Phone.tsx
|
|
1966
|
+
var React16 = __toESM(require("react"), 1);
|
|
1967
|
+
|
|
1968
|
+
// src/components/Selector/Selector.tsx
|
|
1969
|
+
var React15 = __toESM(require("react"), 1);
|
|
1970
|
+
|
|
1971
|
+
// src/Icons/IconDown.tsx
|
|
1972
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1973
|
+
var IconDown = (props) => {
|
|
1974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { width: props.width || "64px", height: props.height || "64px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-testid": "yr3Icons", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M7 10L12 15L17 10", stroke: props.stroke || "#fff", strokeWidth: props.strokeWidth || "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1975
|
+
};
|
|
1976
|
+
|
|
1977
|
+
// src/components/Selector/Selector.tsx
|
|
1978
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1979
|
+
var initalPropsComponent2 = {
|
|
1980
|
+
text: {
|
|
1981
|
+
variant: "caption",
|
|
1982
|
+
color: "primary",
|
|
1983
|
+
children: void 0
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
var Selector = ({ ui, style, options, name, value, defaultValue, onChange, iconColor, icon, propsComponent = initalPropsComponent2 }) => {
|
|
1987
|
+
const [open, setOpen] = React15.useState(false);
|
|
1988
|
+
const [valueState, setValueState] = React15.useState(value || defaultValue || null);
|
|
1989
|
+
const ref = React15.useRef(null);
|
|
1990
|
+
useClickAway(ref, () => setOpen(false));
|
|
1991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "yr3Selector-wrapper", ref, children: [
|
|
1992
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: `yr3Selector ${open ? "yr3Selector--open" : ""}`, style: composeStyles(ui, style), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "yr3Selector--control", children: [
|
|
1993
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "yr3Selector--icon", onClick: () => setOpen((prev) => !prev), children: icon ? icon : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(IconDown, { stroke: `var(--color-${iconColor || "disabled"})`, width: 24, height: 24 }) }),
|
|
1994
|
+
valueState
|
|
1995
|
+
] }) }),
|
|
1996
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "yr3Selector--menu", children: options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1997
|
+
"div",
|
|
1998
|
+
{
|
|
1999
|
+
className: "yr3Selector--option",
|
|
2000
|
+
onClick: (e) => {
|
|
2001
|
+
e.stopPropagation();
|
|
2002
|
+
setValueState(opt.value);
|
|
2003
|
+
setOpen(false);
|
|
2004
|
+
const event = {
|
|
2005
|
+
event: e,
|
|
2006
|
+
target: {
|
|
2007
|
+
name,
|
|
2008
|
+
value: opt.value
|
|
2009
|
+
},
|
|
2010
|
+
currentTarget: {
|
|
2011
|
+
name,
|
|
2012
|
+
value: opt.value
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
2015
|
+
onChange?.(event, opt.value);
|
|
2016
|
+
},
|
|
2017
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Text, { ...propsComponent?.text, children: propsComponent?.text?.children || opt.label })
|
|
2018
|
+
},
|
|
2019
|
+
opt.value
|
|
2020
|
+
)) })
|
|
2021
|
+
] });
|
|
2022
|
+
};
|
|
2023
|
+
var Selector_default = Selector;
|
|
2024
|
+
|
|
2025
|
+
// src/components/Phone/Phone.tsx
|
|
2026
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2027
|
+
var Phone = ({
|
|
2028
|
+
name,
|
|
2029
|
+
value,
|
|
2030
|
+
onChange,
|
|
2031
|
+
label = "Phone",
|
|
2032
|
+
countries,
|
|
2033
|
+
propsComponent,
|
|
2034
|
+
defaultValue
|
|
2035
|
+
}) => {
|
|
2036
|
+
const [prefixValue, setPrefixValue] = React16.useState(countries?.[0].dial);
|
|
2037
|
+
const [internalValue, setInternalValue] = React16.useState(defaultValue);
|
|
2038
|
+
const isControlled = value !== void 0;
|
|
2039
|
+
const currentValue = isControlled ? value : internalValue;
|
|
2040
|
+
const checkPattern = (type, value2) => {
|
|
2041
|
+
switch (type) {
|
|
2042
|
+
case "phone":
|
|
2043
|
+
return /^\d{10}$/.test(value2);
|
|
2044
|
+
default:
|
|
2045
|
+
return true;
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
React16.useEffect(() => {
|
|
2049
|
+
if (internalValue && countries.length > 0) {
|
|
2050
|
+
const dial = getDialPhone(internalValue, countries) || null;
|
|
2051
|
+
setPrefixValue(dial);
|
|
2052
|
+
}
|
|
2053
|
+
}, [internalValue, countries]);
|
|
2054
|
+
const handleChange = (e, value2) => {
|
|
2055
|
+
const newValue = value2;
|
|
2056
|
+
const isValid = checkPattern("phone", newValue);
|
|
2057
|
+
if (!isValid) {
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
if (!isControlled) {
|
|
2061
|
+
setInternalValue(newValue);
|
|
2062
|
+
}
|
|
2063
|
+
onChange?.(e, normalizePhone(currentValue, prefixValue)?.full);
|
|
2064
|
+
};
|
|
2065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Control, { variant: "outlined", ui: { height: 50, position: "relative" }, children: [
|
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Label, { text: label, className: "yr3Input--active" }),
|
|
2067
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "yr3PhoneInput", "data-testid": "yr3Phone", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Flex, { variant: "row", container: true, center: true, children: [
|
|
2068
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2069
|
+
Selector_default,
|
|
2070
|
+
{
|
|
2071
|
+
options: countries.map((c) => ({
|
|
2072
|
+
value: c.dial,
|
|
2073
|
+
label: c.code
|
|
2074
|
+
})),
|
|
2075
|
+
value: prefixValue,
|
|
2076
|
+
onChange: (_, val) => {
|
|
2077
|
+
setPrefixValue(val);
|
|
2078
|
+
},
|
|
2079
|
+
...propsComponent?.selector,
|
|
2080
|
+
ui: {
|
|
2081
|
+
...propsComponent?.selector?.ui,
|
|
2082
|
+
padding: 4
|
|
2083
|
+
},
|
|
2084
|
+
style: propsComponent?.selector?.style
|
|
2085
|
+
}
|
|
2086
|
+
),
|
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Divider, { orientation: "vertical", color: "primary", ui: { height: 50 - 1, mb: -1 }, ...propsComponent?.divider }),
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2089
|
+
Input,
|
|
2090
|
+
{
|
|
2091
|
+
type: "phone",
|
|
2092
|
+
variant: "base",
|
|
2093
|
+
name,
|
|
2094
|
+
value: normalizePhone(currentValue, prefixValue)?.number.toString() || "",
|
|
2095
|
+
...propsComponent?.input,
|
|
2096
|
+
onChange: handleChange
|
|
2097
|
+
},
|
|
2098
|
+
currentValue
|
|
2099
|
+
)
|
|
2100
|
+
] }) })
|
|
2101
|
+
] }, prefixValue);
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
// src/components/Places/PlacesAutocomplete.tsx
|
|
2105
|
+
var React17 = __toESM(require("react"), 1);
|
|
2106
|
+
var import_autocomplete_places = require("@yr3/autocomplete-places");
|
|
2107
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2108
|
+
var initPropsComponent = {
|
|
2109
|
+
label: {
|
|
2110
|
+
display: true,
|
|
2111
|
+
ui: {},
|
|
2112
|
+
style: {}
|
|
2113
|
+
},
|
|
2114
|
+
control: {
|
|
2115
|
+
variant: "outlined",
|
|
2116
|
+
color: "primary",
|
|
2117
|
+
label: true,
|
|
2118
|
+
ui: {},
|
|
2119
|
+
style: {}
|
|
2120
|
+
},
|
|
2121
|
+
input: {
|
|
2122
|
+
variant: "outlined",
|
|
2123
|
+
color: "primary",
|
|
2124
|
+
ui: { width: "90dvw" },
|
|
2125
|
+
style: {}
|
|
2126
|
+
},
|
|
2127
|
+
menu: {
|
|
2128
|
+
ui: {},
|
|
2129
|
+
style: {},
|
|
2130
|
+
text: {
|
|
2131
|
+
variant: "body2",
|
|
2132
|
+
color: "primary",
|
|
2133
|
+
ui: {},
|
|
2134
|
+
style: {}
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
var PlacesAutocomplete = ({
|
|
2139
|
+
onSelect,
|
|
2140
|
+
onChangeForm,
|
|
2141
|
+
language = "en",
|
|
2142
|
+
provider = "google",
|
|
2143
|
+
defaultLocation,
|
|
2144
|
+
keyApi,
|
|
2145
|
+
propsComponent = initPropsComponent
|
|
2146
|
+
}) => {
|
|
2147
|
+
const [value, setValue] = React17.useState(null);
|
|
2148
|
+
const inputRef = React17.useRef(null);
|
|
2149
|
+
const [anchorEl, setAnchorEl] = React17.useState(null);
|
|
2150
|
+
const { suggestions, selectPlace } = (0, import_autocomplete_places.useAutocompletePlaces)({ input: value, apiKey: keyApi, language, provider });
|
|
2151
|
+
const handleSelect = async (id) => {
|
|
2152
|
+
const place = await selectPlace(id);
|
|
2153
|
+
const locationData = {
|
|
2154
|
+
name: place.name || "",
|
|
2155
|
+
address: place.address,
|
|
2156
|
+
city: place.city || "",
|
|
2157
|
+
country: place.country || "",
|
|
2158
|
+
zip: place.zip || "",
|
|
2159
|
+
lat: place.lat,
|
|
2160
|
+
lng: place.lng,
|
|
2161
|
+
code: place.code || "",
|
|
2162
|
+
phone: place.phone || "",
|
|
2163
|
+
placeId: id
|
|
2164
|
+
};
|
|
2165
|
+
onSelect(locationData);
|
|
2166
|
+
setValue(place.address);
|
|
2167
|
+
setAnchorEl(null);
|
|
2168
|
+
};
|
|
2169
|
+
React17.useEffect(() => {
|
|
2170
|
+
if (defaultLocation) {
|
|
2171
|
+
setValue(defaultLocation);
|
|
2172
|
+
}
|
|
2173
|
+
}, [defaultLocation]);
|
|
2174
|
+
React17.useEffect(() => {
|
|
2175
|
+
if (value === "") {
|
|
2176
|
+
onSelect(null);
|
|
2177
|
+
}
|
|
2178
|
+
}, [value]);
|
|
2179
|
+
const handleChange = (e) => {
|
|
2180
|
+
setValue(e.target.value);
|
|
2181
|
+
setAnchorEl(e.target.value ? inputRef.current : null);
|
|
2182
|
+
};
|
|
2183
|
+
const open = suggestions.length > 0 && Boolean(anchorEl);
|
|
2184
|
+
React17.useEffect(() => {
|
|
2185
|
+
if (onChangeForm) {
|
|
2186
|
+
onChangeForm({ target: { value } });
|
|
2187
|
+
}
|
|
2188
|
+
}, [onChangeForm]);
|
|
2189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Control, { ...propsComponent?.control, children: [
|
|
2190
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2191
|
+
Input,
|
|
2192
|
+
{
|
|
2193
|
+
ref: inputRef,
|
|
2194
|
+
type: "text",
|
|
2195
|
+
value,
|
|
2196
|
+
onChange: handleChange,
|
|
2197
|
+
propsComponent: {
|
|
2198
|
+
label: propsComponent.label
|
|
2199
|
+
},
|
|
2200
|
+
...propsComponent?.input
|
|
2201
|
+
},
|
|
2202
|
+
"input-places"
|
|
2203
|
+
),
|
|
2204
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "yr3Places--menu", style: composeStyles(propsComponent.menu?.ui, propsComponent?.menu?.style), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Flex, { container: true, ui: { p: 1 }, children: suggestions.map((s) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Flex, { onClick: () => handleSelect(s.id), ui: { padding: 8, cursor: "pointer", "&:hover": { backgroundColor: "rgba(0,0,0,0.1)" } }, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Text, { ...propsComponent?.menu?.text, children: s.description }) }, s.id)) }) })
|
|
2205
|
+
] });
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2043
2208
|
// src/components/Radio/radio.variants.ts
|
|
2044
2209
|
var radioVariant = createVariants({
|
|
2045
2210
|
base: "yr3Radio",
|
|
@@ -2298,6 +2463,18 @@ var IconSearch = (props) => {
|
|
|
2298
2463
|
) });
|
|
2299
2464
|
};
|
|
2300
2465
|
|
|
2466
|
+
// src/theme/ThemeProvider.tsx
|
|
2467
|
+
var React21 = __toESM(require("react"), 1);
|
|
2468
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2469
|
+
var ThemeContext = React21.createContext(null);
|
|
2470
|
+
var ThemeProvider = ({ theme, children }) => {
|
|
2471
|
+
React21.useEffect(() => {
|
|
2472
|
+
applyTheme(theme);
|
|
2473
|
+
}, [theme]);
|
|
2474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BackdropProvider, { children }) });
|
|
2475
|
+
};
|
|
2476
|
+
var useTheme = () => React21.useContext(ThemeContext);
|
|
2477
|
+
|
|
2301
2478
|
// src/theme/tokens.ts
|
|
2302
2479
|
var baseTokens = {
|
|
2303
2480
|
colors: {
|
|
@@ -2317,11 +2494,11 @@ var baseTokens = {
|
|
|
2317
2494
|
};
|
|
2318
2495
|
|
|
2319
2496
|
// src/theme/notistackContext.tsx
|
|
2320
|
-
var
|
|
2321
|
-
var
|
|
2322
|
-
var NotistackContext =
|
|
2497
|
+
var React22 = __toESM(require("react"), 1);
|
|
2498
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2499
|
+
var NotistackContext = React22.createContext(null);
|
|
2323
2500
|
var NotistackProvider = ({ children }) => {
|
|
2324
|
-
const [snacks, setSnacks] =
|
|
2501
|
+
const [snacks, setSnacks] = React22.useState([]);
|
|
2325
2502
|
const enqueueNotistack = (snack) => {
|
|
2326
2503
|
const id = Date.now();
|
|
2327
2504
|
setSnacks((prev) => [...prev, { ...snack, id, exiting: false }]);
|
|
@@ -2336,23 +2513,23 @@ var NotistackProvider = ({ children }) => {
|
|
|
2336
2513
|
setSnacks((prev) => prev.filter((s) => s.id !== id));
|
|
2337
2514
|
}, duration + exitDuration);
|
|
2338
2515
|
};
|
|
2339
|
-
return /* @__PURE__ */ (0,
|
|
2516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(NotistackContext.Provider, { value: { enqueueNotistack }, children: [
|
|
2340
2517
|
children,
|
|
2341
|
-
/* @__PURE__ */ (0,
|
|
2518
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "yr3NotistackContainer", children: snacks.map((snack) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Notistack, { ...snack }, snack.id)) })
|
|
2342
2519
|
] });
|
|
2343
2520
|
};
|
|
2344
|
-
var useNotistack = () =>
|
|
2521
|
+
var useNotistack = () => React22.useContext(NotistackContext);
|
|
2345
2522
|
|
|
2346
2523
|
// src/theme/useMediaQuery.tsx
|
|
2347
|
-
var
|
|
2524
|
+
var React23 = __toESM(require("react"), 1);
|
|
2348
2525
|
function useMediaQuery(query) {
|
|
2349
2526
|
const theme = useTheme();
|
|
2350
2527
|
const computedQuery = typeof query === "function" ? query(theme) : query;
|
|
2351
|
-
const [matches, setMatches] =
|
|
2528
|
+
const [matches, setMatches] = React23.useState(() => {
|
|
2352
2529
|
if (typeof window === "undefined") return false;
|
|
2353
2530
|
return window.matchMedia(computedQuery).matches;
|
|
2354
2531
|
});
|
|
2355
|
-
|
|
2532
|
+
React23.useEffect(() => {
|
|
2356
2533
|
if (typeof window === "undefined") return;
|
|
2357
2534
|
const media = window.matchMedia(computedQuery);
|
|
2358
2535
|
const listener = () => setMatches(media.matches);
|
|
@@ -2412,6 +2589,7 @@ initTheme();
|
|
|
2412
2589
|
NotistackProvider,
|
|
2413
2590
|
Pending,
|
|
2414
2591
|
Phone,
|
|
2592
|
+
PlacesAutocomplete,
|
|
2415
2593
|
Radio,
|
|
2416
2594
|
Select,
|
|
2417
2595
|
Slide,
|
|
@@ -2431,9 +2609,13 @@ initTheme();
|
|
|
2431
2609
|
createVariants,
|
|
2432
2610
|
cx,
|
|
2433
2611
|
getContrast,
|
|
2612
|
+
getCountryCodePhone,
|
|
2613
|
+
getDialPhone,
|
|
2434
2614
|
getMonthCalendar,
|
|
2615
|
+
getNumberPhone,
|
|
2435
2616
|
initTheme,
|
|
2436
2617
|
isEmpty,
|
|
2618
|
+
normalizePhone,
|
|
2437
2619
|
text,
|
|
2438
2620
|
times,
|
|
2439
2621
|
uiStyle,
|
|
@@ -2443,5 +2625,6 @@ initTheme();
|
|
|
2443
2625
|
useControl,
|
|
2444
2626
|
useMediaQuery,
|
|
2445
2627
|
useNotistack,
|
|
2446
|
-
useTheme
|
|
2628
|
+
useTheme,
|
|
2629
|
+
...require("@yr3/autocomplete-places")
|
|
2447
2630
|
});
|