@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.js
CHANGED
|
@@ -250,6 +250,49 @@ var createVariants = (config) => {
|
|
|
250
250
|
};
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
+
// src/utils/phone.ts
|
|
254
|
+
var normalizePhone = (phone, dial) => {
|
|
255
|
+
if (!phone) return null;
|
|
256
|
+
let clean = phone.replace(/[^\d+]/g, "");
|
|
257
|
+
let number = clean;
|
|
258
|
+
if (clean.startsWith(dial)) {
|
|
259
|
+
number = clean.slice(dial.length);
|
|
260
|
+
} else if (clean.startsWith("+")) {
|
|
261
|
+
const match = clean.match(/^\+\d{1,3}(.*)$/);
|
|
262
|
+
if (match) {
|
|
263
|
+
number = match[1];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
number = number.replace(/^0+/, "");
|
|
267
|
+
return {
|
|
268
|
+
number,
|
|
269
|
+
full: `${dial}${number}`
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
var getDialPhone = (phone, countries) => {
|
|
273
|
+
for (const country of countries) {
|
|
274
|
+
console.log("checking", phone, "against", country.dial);
|
|
275
|
+
if (phone.startsWith(country.dial)) {
|
|
276
|
+
return country.dial;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
};
|
|
281
|
+
var getCountryCodePhone = (phone, countries) => {
|
|
282
|
+
for (const country of countries) {
|
|
283
|
+
if (phone.startsWith(country.dial)) {
|
|
284
|
+
return country.code;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
};
|
|
289
|
+
var getNumberPhone = (phone, dial) => {
|
|
290
|
+
if (phone.startsWith(dial)) {
|
|
291
|
+
return phone.slice(dial.length);
|
|
292
|
+
}
|
|
293
|
+
return phone;
|
|
294
|
+
};
|
|
295
|
+
|
|
253
296
|
// src/theme/breakpoint.ts
|
|
254
297
|
var breakpoints = {
|
|
255
298
|
xs: 0,
|
|
@@ -413,6 +456,9 @@ function initTheme() {
|
|
|
413
456
|
applyTheme(createTheme());
|
|
414
457
|
}
|
|
415
458
|
|
|
459
|
+
// src/index.ts
|
|
460
|
+
export * from "@yr3/autocomplete-places";
|
|
461
|
+
|
|
416
462
|
// src/components/Avatar/Avatar.tsx
|
|
417
463
|
import * as React from "react";
|
|
418
464
|
|
|
@@ -1569,143 +1615,13 @@ var Input = React12.forwardRef(
|
|
|
1569
1615
|
"data-testid": "yr3Input"
|
|
1570
1616
|
}
|
|
1571
1617
|
),
|
|
1572
|
-
/* @__PURE__ */ jsx24(Text, { variant: "helper", "data-testid": "yr3Input-helper", children: error || internalError || "" })
|
|
1618
|
+
/* @__PURE__ */ jsx24(Text, { variant: "helper", color: "disabled", "data-testid": "yr3Input-helper", ui: { position: "absolute", bottom: -18, left: 0 }, children: error || internalError || "" })
|
|
1573
1619
|
] });
|
|
1574
1620
|
}
|
|
1575
1621
|
);
|
|
1576
1622
|
|
|
1577
|
-
// src/components/Input/InputPhone.tsx
|
|
1578
|
-
import * as React15 from "react";
|
|
1579
|
-
|
|
1580
|
-
// src/components/Select/Selector.tsx
|
|
1581
|
-
import * as React13 from "react";
|
|
1582
|
-
|
|
1583
|
-
// src/Icons/IconDown.tsx
|
|
1584
|
-
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
1585
|
-
var IconDown = (props) => {
|
|
1586
|
-
return /* @__PURE__ */ jsx25("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__ */ jsx25("path", { d: "M7 10L12 15L17 10", stroke: props.stroke || "#fff", strokeWidth: props.strokeWidth || "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1587
|
-
};
|
|
1588
|
-
|
|
1589
|
-
// src/components/Select/Selector.tsx
|
|
1590
|
-
import { jsx as jsx26, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1591
|
-
var Selector = ({ ui, style, options, name, value, defaultValue, onChange, iconColor, icon }) => {
|
|
1592
|
-
const [open, setOpen] = React13.useState(false);
|
|
1593
|
-
const [valueState, setValueState] = React13.useState(value || defaultValue || null);
|
|
1594
|
-
const ref = React13.useRef(null);
|
|
1595
|
-
useClickAway(ref, () => setOpen(false));
|
|
1596
|
-
return /* @__PURE__ */ jsxs7("div", { className: "yr3Selector-wrapper", ref, children: [
|
|
1597
|
-
/* @__PURE__ */ jsx26("div", { className: `yr3Selector ${open ? "yr3Selector--open" : ""}`, style: composeStyles(ui, style), children: /* @__PURE__ */ jsxs7("div", { className: "yr3Selector--control", children: [
|
|
1598
|
-
/* @__PURE__ */ jsx26("div", { className: "yr3Selector--icon", onClick: () => setOpen((prev) => !prev), children: icon ? icon : /* @__PURE__ */ jsx26(IconDown, { stroke: `var(--color-${iconColor || "disabled"})`, width: 24, height: 24 }) }),
|
|
1599
|
-
valueState
|
|
1600
|
-
] }) }),
|
|
1601
|
-
open && /* @__PURE__ */ jsx26("div", { className: "yr3Select--menu", children: options.map((opt) => /* @__PURE__ */ jsx26(
|
|
1602
|
-
"div",
|
|
1603
|
-
{
|
|
1604
|
-
className: "yr3Select--option",
|
|
1605
|
-
onClick: (e) => {
|
|
1606
|
-
e.stopPropagation();
|
|
1607
|
-
setValueState(opt.value);
|
|
1608
|
-
setOpen(false);
|
|
1609
|
-
const event = {
|
|
1610
|
-
event: e,
|
|
1611
|
-
target: {
|
|
1612
|
-
name,
|
|
1613
|
-
value: opt.value
|
|
1614
|
-
},
|
|
1615
|
-
currentTarget: {
|
|
1616
|
-
name,
|
|
1617
|
-
value: opt.value
|
|
1618
|
-
}
|
|
1619
|
-
};
|
|
1620
|
-
onChange?.(event, opt.value);
|
|
1621
|
-
},
|
|
1622
|
-
children: opt.label
|
|
1623
|
-
},
|
|
1624
|
-
opt.value
|
|
1625
|
-
)) })
|
|
1626
|
-
] });
|
|
1627
|
-
};
|
|
1628
|
-
var Selector_default = Selector;
|
|
1629
|
-
|
|
1630
|
-
// src/theme/ThemeProvider.tsx
|
|
1631
|
-
import * as React14 from "react";
|
|
1632
|
-
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
1633
|
-
var ThemeContext = React14.createContext(null);
|
|
1634
|
-
var ThemeProvider = ({ theme, children }) => {
|
|
1635
|
-
React14.useEffect(() => {
|
|
1636
|
-
applyTheme(theme);
|
|
1637
|
-
}, [theme]);
|
|
1638
|
-
return /* @__PURE__ */ jsx27(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ jsx27(BackdropProvider, { children }) });
|
|
1639
|
-
};
|
|
1640
|
-
var useTheme = () => React14.useContext(ThemeContext);
|
|
1641
|
-
|
|
1642
|
-
// src/components/Input/InputPhone.tsx
|
|
1643
|
-
import { jsx as jsx28, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1644
|
-
var Phone = ({
|
|
1645
|
-
name,
|
|
1646
|
-
value,
|
|
1647
|
-
onChange,
|
|
1648
|
-
prefix = "+39",
|
|
1649
|
-
label = "Phone",
|
|
1650
|
-
countries = [],
|
|
1651
|
-
propsComponent
|
|
1652
|
-
}) => {
|
|
1653
|
-
const [prefixValue, setPrefixValue] = React15.useState(prefix);
|
|
1654
|
-
const [number, setNumber] = React15.useState(Number(value) || null);
|
|
1655
|
-
const theme = useTheme();
|
|
1656
|
-
const handleChange = (newPrefix, newNumber) => {
|
|
1657
|
-
const full = `${newPrefix}${newNumber.toString()}`;
|
|
1658
|
-
const event = {
|
|
1659
|
-
target: {
|
|
1660
|
-
name,
|
|
1661
|
-
value: full
|
|
1662
|
-
}
|
|
1663
|
-
};
|
|
1664
|
-
onChange?.(event, full);
|
|
1665
|
-
};
|
|
1666
|
-
return /* @__PURE__ */ jsxs8(Control, { variant: "outlined", children: [
|
|
1667
|
-
/* @__PURE__ */ jsx28(Label, { text: label, className: "yr3Input--active" }),
|
|
1668
|
-
/* @__PURE__ */ jsx28("div", { className: "yr3PhoneInput", "data-testid": "yr3Phone", children: /* @__PURE__ */ jsxs8(Flex, { variant: "row", container: true, center: true, children: [
|
|
1669
|
-
/* @__PURE__ */ jsx28(
|
|
1670
|
-
Selector_default,
|
|
1671
|
-
{
|
|
1672
|
-
options: countries.map((c) => ({
|
|
1673
|
-
value: c.dial,
|
|
1674
|
-
label: c.code
|
|
1675
|
-
})),
|
|
1676
|
-
value: prefixValue,
|
|
1677
|
-
onChange: (_, val) => {
|
|
1678
|
-
setPrefixValue(val);
|
|
1679
|
-
handleChange(val, number);
|
|
1680
|
-
},
|
|
1681
|
-
...propsComponent?.selector,
|
|
1682
|
-
ui: {
|
|
1683
|
-
...propsComponent?.selector?.ui,
|
|
1684
|
-
padding: 4
|
|
1685
|
-
},
|
|
1686
|
-
style: propsComponent?.selector?.style
|
|
1687
|
-
}
|
|
1688
|
-
),
|
|
1689
|
-
/* @__PURE__ */ jsx28(Divider, { orientation: "vertical", ...propsComponent?.divider }),
|
|
1690
|
-
/* @__PURE__ */ jsx28(
|
|
1691
|
-
Input,
|
|
1692
|
-
{
|
|
1693
|
-
type: "phone",
|
|
1694
|
-
variant: "base",
|
|
1695
|
-
value: number,
|
|
1696
|
-
...propsComponent?.input,
|
|
1697
|
-
onChange: (e, value2) => {
|
|
1698
|
-
setNumber(value2);
|
|
1699
|
-
handleChange(prefixValue, value2);
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
)
|
|
1703
|
-
] }) })
|
|
1704
|
-
] });
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
1623
|
// src/components/InputArea/InputArea.tsx
|
|
1708
|
-
import * as
|
|
1624
|
+
import * as React13 from "react";
|
|
1709
1625
|
|
|
1710
1626
|
// src/components/InputArea/inputAreaVariants.ts
|
|
1711
1627
|
var inputAreaVariants = createVariants({
|
|
@@ -1741,7 +1657,7 @@ var inputAreaVariants = createVariants({
|
|
|
1741
1657
|
});
|
|
1742
1658
|
|
|
1743
1659
|
// src/components/InputArea/InputArea.tsx
|
|
1744
|
-
import { jsx as
|
|
1660
|
+
import { jsx as jsx25, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1745
1661
|
var initiaPropsComponent2 = {
|
|
1746
1662
|
label: {
|
|
1747
1663
|
display: true,
|
|
@@ -1766,8 +1682,8 @@ var InputArea = ({
|
|
|
1766
1682
|
rounded = false,
|
|
1767
1683
|
propsComponent = initiaPropsComponent2
|
|
1768
1684
|
}) => {
|
|
1769
|
-
const ref =
|
|
1770
|
-
const [internalValue, setInternalValue] =
|
|
1685
|
+
const ref = React13.useRef(null);
|
|
1686
|
+
const [internalValue, setInternalValue] = React13.useState(defaultValue);
|
|
1771
1687
|
const isControlled = value !== void 0;
|
|
1772
1688
|
const currentValue = isControlled ? value : internalValue;
|
|
1773
1689
|
const handleChange = (e) => {
|
|
@@ -1784,8 +1700,8 @@ var InputArea = ({
|
|
|
1784
1700
|
el.style.resize = resize;
|
|
1785
1701
|
}
|
|
1786
1702
|
const classes = inputAreaVariants({ variant, color, rounded });
|
|
1787
|
-
return /* @__PURE__ */
|
|
1788
|
-
propsComponent?.label?.display && /* @__PURE__ */
|
|
1703
|
+
return /* @__PURE__ */ jsxs7("div", { style: { position: "relative" }, children: [
|
|
1704
|
+
propsComponent?.label?.display && /* @__PURE__ */ jsx25(
|
|
1789
1705
|
Label,
|
|
1790
1706
|
{
|
|
1791
1707
|
text: label || "",
|
|
@@ -1793,7 +1709,7 @@ var InputArea = ({
|
|
|
1793
1709
|
...propsComponent.label
|
|
1794
1710
|
}
|
|
1795
1711
|
),
|
|
1796
|
-
/* @__PURE__ */
|
|
1712
|
+
/* @__PURE__ */ jsx25(
|
|
1797
1713
|
"textarea",
|
|
1798
1714
|
{
|
|
1799
1715
|
className: classes,
|
|
@@ -1805,26 +1721,26 @@ var InputArea = ({
|
|
|
1805
1721
|
"data-testid": "yr3InputArea"
|
|
1806
1722
|
}
|
|
1807
1723
|
),
|
|
1808
|
-
/* @__PURE__ */
|
|
1724
|
+
/* @__PURE__ */ jsx25(Text, { variant: "helper", color: currentValue.length > maxLength ? "error" : "disabled", ui: { textAlign: "right" }, "data-testid": "yr3InputAreaError", children: validate && maxLength ? `${currentValue.length}/${maxLength}` || propsComponent.helperText : "" })
|
|
1809
1725
|
] });
|
|
1810
1726
|
};
|
|
1811
1727
|
|
|
1812
1728
|
// src/components/Modal/Modal.tsx
|
|
1813
|
-
import * as
|
|
1729
|
+
import * as React14 from "react";
|
|
1814
1730
|
|
|
1815
1731
|
// src/components/Modal/ModalContainer.tsx
|
|
1816
|
-
import { jsx as
|
|
1732
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
1817
1733
|
var ModalContainer = ({ children, size = "sm", ui, style }) => {
|
|
1818
1734
|
const classes = bem("yr3Modal-container");
|
|
1819
1735
|
const classComponent = classes(void 0, { [`${size}`]: !!size });
|
|
1820
|
-
return /* @__PURE__ */
|
|
1736
|
+
return /* @__PURE__ */ jsx26("div", { className: classComponent, style: composeStyles(ui, style), "data-testid": "yr3Modal-container", children });
|
|
1821
1737
|
};
|
|
1822
1738
|
|
|
1823
1739
|
// src/components/Modal/Modal.tsx
|
|
1824
|
-
import { jsx as
|
|
1740
|
+
import { jsx as jsx27, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1825
1741
|
var Modal = ({ open, onClose, children, propsComponent }) => {
|
|
1826
1742
|
const { show, hide } = useBackdrop();
|
|
1827
|
-
|
|
1743
|
+
React14.useEffect(() => {
|
|
1828
1744
|
if (open) {
|
|
1829
1745
|
show();
|
|
1830
1746
|
} else {
|
|
@@ -1833,9 +1749,9 @@ var Modal = ({ open, onClose, children, propsComponent }) => {
|
|
|
1833
1749
|
}, [open, show]);
|
|
1834
1750
|
const classes = bem("yr3Modal");
|
|
1835
1751
|
const classComponent = classes(void 0, { "open": !!open });
|
|
1836
|
-
return /* @__PURE__ */
|
|
1752
|
+
return /* @__PURE__ */ jsx27("div", { className: classComponent, onClick: (e) => e.stopPropagation(), "data-testid": "yr3Modal", children: /* @__PURE__ */ jsx27(ModalContainer, { ...propsComponent?.container, children: /* @__PURE__ */ jsxs8(Flex, { variant: "column", container: true, center: true, gap: 1, children: [
|
|
1837
1753
|
children,
|
|
1838
|
-
propsComponent?.close ? propsComponent.close : /* @__PURE__ */
|
|
1754
|
+
propsComponent?.close ? propsComponent.close : /* @__PURE__ */ jsx27(Button, { variant: "filled", color: "secondary", onClick: onClose, "data-testid": "yr3Modal-close", children: "Close" })
|
|
1839
1755
|
] }) }) });
|
|
1840
1756
|
};
|
|
1841
1757
|
|
|
@@ -1875,15 +1791,15 @@ var notistackVariants = createVariants({
|
|
|
1875
1791
|
});
|
|
1876
1792
|
|
|
1877
1793
|
// src/components/Notistack/Notistack.tsx
|
|
1878
|
-
import { jsx as
|
|
1794
|
+
import { jsx as jsx28, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1879
1795
|
var Notistack = ({ message, duration = 3e3, variant = "info", color, propsComponent, anchor, exiting = false }) => {
|
|
1880
1796
|
const classes = notistackVariants({ type: variant, color, exiting, direction: `${anchor?.vertical || "bottom"}-${anchor?.horizontal || "right"}` });
|
|
1881
1797
|
const containerStyle = composeStyles(propsComponent?.container?.ui, propsComponent?.container?.style);
|
|
1882
1798
|
const notistackStyle = composeStyles(propsComponent?.notistack?.ui, propsComponent?.notistack?.style);
|
|
1883
1799
|
const progressStyle = composeStyles(propsComponent?.progress?.ui, propsComponent?.progress?.style);
|
|
1884
|
-
return /* @__PURE__ */
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
1800
|
+
return /* @__PURE__ */ jsxs9("div", { className: classes, "data-testid": "yr3Notistack", style: notistackStyle, children: [
|
|
1801
|
+
/* @__PURE__ */ jsx28("span", { style: containerStyle, children: message }),
|
|
1802
|
+
/* @__PURE__ */ jsx28(
|
|
1887
1803
|
"div",
|
|
1888
1804
|
{
|
|
1889
1805
|
className: "yr3Notistack--progress",
|
|
@@ -1917,7 +1833,7 @@ var pendingVariants = createVariants({
|
|
|
1917
1833
|
});
|
|
1918
1834
|
|
|
1919
1835
|
// src/components/Pending/Pending.tsx
|
|
1920
|
-
import { jsx as
|
|
1836
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
1921
1837
|
var Pending = ({
|
|
1922
1838
|
variant,
|
|
1923
1839
|
width,
|
|
@@ -1930,7 +1846,7 @@ var Pending = ({
|
|
|
1930
1846
|
const widthStyle = variant === "circle" ? size : width;
|
|
1931
1847
|
const heightStyle = variant === "circle" ? size : height;
|
|
1932
1848
|
const uiStylePending = uiStyle({ width: widthStyle, height: heightStyle, ...ui });
|
|
1933
|
-
return /* @__PURE__ */
|
|
1849
|
+
return /* @__PURE__ */ jsx29(
|
|
1934
1850
|
"div",
|
|
1935
1851
|
{
|
|
1936
1852
|
className: pendingVariants({ variant, color }),
|
|
@@ -1940,6 +1856,249 @@ var Pending = ({
|
|
|
1940
1856
|
);
|
|
1941
1857
|
};
|
|
1942
1858
|
|
|
1859
|
+
// src/components/Phone/Phone.tsx
|
|
1860
|
+
import * as React16 from "react";
|
|
1861
|
+
|
|
1862
|
+
// src/components/Selector/Selector.tsx
|
|
1863
|
+
import * as React15 from "react";
|
|
1864
|
+
|
|
1865
|
+
// src/Icons/IconDown.tsx
|
|
1866
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1867
|
+
var IconDown = (props) => {
|
|
1868
|
+
return /* @__PURE__ */ jsx30("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__ */ jsx30("path", { d: "M7 10L12 15L17 10", stroke: props.stroke || "#fff", strokeWidth: props.strokeWidth || "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
// src/components/Selector/Selector.tsx
|
|
1872
|
+
import { jsx as jsx31, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1873
|
+
var initalPropsComponent2 = {
|
|
1874
|
+
text: {
|
|
1875
|
+
variant: "caption",
|
|
1876
|
+
color: "primary",
|
|
1877
|
+
children: void 0
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
var Selector = ({ ui, style, options, name, value, defaultValue, onChange, iconColor, icon, propsComponent = initalPropsComponent2 }) => {
|
|
1881
|
+
const [open, setOpen] = React15.useState(false);
|
|
1882
|
+
const [valueState, setValueState] = React15.useState(value || defaultValue || null);
|
|
1883
|
+
const ref = React15.useRef(null);
|
|
1884
|
+
useClickAway(ref, () => setOpen(false));
|
|
1885
|
+
return /* @__PURE__ */ jsxs10("div", { className: "yr3Selector-wrapper", ref, children: [
|
|
1886
|
+
/* @__PURE__ */ jsx31("div", { className: `yr3Selector ${open ? "yr3Selector--open" : ""}`, style: composeStyles(ui, style), children: /* @__PURE__ */ jsxs10("div", { className: "yr3Selector--control", children: [
|
|
1887
|
+
/* @__PURE__ */ jsx31("div", { className: "yr3Selector--icon", onClick: () => setOpen((prev) => !prev), children: icon ? icon : /* @__PURE__ */ jsx31(IconDown, { stroke: `var(--color-${iconColor || "disabled"})`, width: 24, height: 24 }) }),
|
|
1888
|
+
valueState
|
|
1889
|
+
] }) }),
|
|
1890
|
+
open && /* @__PURE__ */ jsx31("div", { className: "yr3Selector--menu", children: options.map((opt) => /* @__PURE__ */ jsx31(
|
|
1891
|
+
"div",
|
|
1892
|
+
{
|
|
1893
|
+
className: "yr3Selector--option",
|
|
1894
|
+
onClick: (e) => {
|
|
1895
|
+
e.stopPropagation();
|
|
1896
|
+
setValueState(opt.value);
|
|
1897
|
+
setOpen(false);
|
|
1898
|
+
const event = {
|
|
1899
|
+
event: e,
|
|
1900
|
+
target: {
|
|
1901
|
+
name,
|
|
1902
|
+
value: opt.value
|
|
1903
|
+
},
|
|
1904
|
+
currentTarget: {
|
|
1905
|
+
name,
|
|
1906
|
+
value: opt.value
|
|
1907
|
+
}
|
|
1908
|
+
};
|
|
1909
|
+
onChange?.(event, opt.value);
|
|
1910
|
+
},
|
|
1911
|
+
children: /* @__PURE__ */ jsx31(Text, { ...propsComponent?.text, children: propsComponent?.text?.children || opt.label })
|
|
1912
|
+
},
|
|
1913
|
+
opt.value
|
|
1914
|
+
)) })
|
|
1915
|
+
] });
|
|
1916
|
+
};
|
|
1917
|
+
var Selector_default = Selector;
|
|
1918
|
+
|
|
1919
|
+
// src/components/Phone/Phone.tsx
|
|
1920
|
+
import { jsx as jsx32, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1921
|
+
var Phone = ({
|
|
1922
|
+
name,
|
|
1923
|
+
value,
|
|
1924
|
+
onChange,
|
|
1925
|
+
label = "Phone",
|
|
1926
|
+
countries,
|
|
1927
|
+
propsComponent,
|
|
1928
|
+
defaultValue
|
|
1929
|
+
}) => {
|
|
1930
|
+
const [prefixValue, setPrefixValue] = React16.useState(countries?.[0].dial);
|
|
1931
|
+
const [internalValue, setInternalValue] = React16.useState(defaultValue);
|
|
1932
|
+
const isControlled = value !== void 0;
|
|
1933
|
+
const currentValue = isControlled ? value : internalValue;
|
|
1934
|
+
const checkPattern = (type, value2) => {
|
|
1935
|
+
switch (type) {
|
|
1936
|
+
case "phone":
|
|
1937
|
+
return /^\d{10}$/.test(value2);
|
|
1938
|
+
default:
|
|
1939
|
+
return true;
|
|
1940
|
+
}
|
|
1941
|
+
};
|
|
1942
|
+
React16.useEffect(() => {
|
|
1943
|
+
if (internalValue && countries.length > 0) {
|
|
1944
|
+
const dial = getDialPhone(internalValue, countries) || null;
|
|
1945
|
+
setPrefixValue(dial);
|
|
1946
|
+
}
|
|
1947
|
+
}, [internalValue, countries]);
|
|
1948
|
+
const handleChange = (e, value2) => {
|
|
1949
|
+
const newValue = value2;
|
|
1950
|
+
const isValid = checkPattern("phone", newValue);
|
|
1951
|
+
if (!isValid) {
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
if (!isControlled) {
|
|
1955
|
+
setInternalValue(newValue);
|
|
1956
|
+
}
|
|
1957
|
+
onChange?.(e, normalizePhone(currentValue, prefixValue)?.full);
|
|
1958
|
+
};
|
|
1959
|
+
return /* @__PURE__ */ jsxs11(Control, { variant: "outlined", ui: { height: 50, position: "relative" }, children: [
|
|
1960
|
+
/* @__PURE__ */ jsx32(Label, { text: label, className: "yr3Input--active" }),
|
|
1961
|
+
/* @__PURE__ */ jsx32("div", { className: "yr3PhoneInput", "data-testid": "yr3Phone", children: /* @__PURE__ */ jsxs11(Flex, { variant: "row", container: true, center: true, children: [
|
|
1962
|
+
/* @__PURE__ */ jsx32(
|
|
1963
|
+
Selector_default,
|
|
1964
|
+
{
|
|
1965
|
+
options: countries.map((c) => ({
|
|
1966
|
+
value: c.dial,
|
|
1967
|
+
label: c.code
|
|
1968
|
+
})),
|
|
1969
|
+
value: prefixValue,
|
|
1970
|
+
onChange: (_, val) => {
|
|
1971
|
+
setPrefixValue(val);
|
|
1972
|
+
},
|
|
1973
|
+
...propsComponent?.selector,
|
|
1974
|
+
ui: {
|
|
1975
|
+
...propsComponent?.selector?.ui,
|
|
1976
|
+
padding: 4
|
|
1977
|
+
},
|
|
1978
|
+
style: propsComponent?.selector?.style
|
|
1979
|
+
}
|
|
1980
|
+
),
|
|
1981
|
+
/* @__PURE__ */ jsx32(Divider, { orientation: "vertical", color: "primary", ui: { height: 50 - 1, mb: -1 }, ...propsComponent?.divider }),
|
|
1982
|
+
/* @__PURE__ */ jsx32(
|
|
1983
|
+
Input,
|
|
1984
|
+
{
|
|
1985
|
+
type: "phone",
|
|
1986
|
+
variant: "base",
|
|
1987
|
+
name,
|
|
1988
|
+
value: normalizePhone(currentValue, prefixValue)?.number.toString() || "",
|
|
1989
|
+
...propsComponent?.input,
|
|
1990
|
+
onChange: handleChange
|
|
1991
|
+
},
|
|
1992
|
+
currentValue
|
|
1993
|
+
)
|
|
1994
|
+
] }) })
|
|
1995
|
+
] }, prefixValue);
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
// src/components/Places/PlacesAutocomplete.tsx
|
|
1999
|
+
import * as React17 from "react";
|
|
2000
|
+
import { useAutocompletePlaces } from "@yr3/autocomplete-places";
|
|
2001
|
+
import { jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2002
|
+
var initPropsComponent = {
|
|
2003
|
+
label: {
|
|
2004
|
+
display: true,
|
|
2005
|
+
ui: {},
|
|
2006
|
+
style: {}
|
|
2007
|
+
},
|
|
2008
|
+
control: {
|
|
2009
|
+
variant: "outlined",
|
|
2010
|
+
color: "primary",
|
|
2011
|
+
label: true,
|
|
2012
|
+
ui: {},
|
|
2013
|
+
style: {}
|
|
2014
|
+
},
|
|
2015
|
+
input: {
|
|
2016
|
+
variant: "outlined",
|
|
2017
|
+
color: "primary",
|
|
2018
|
+
ui: { width: "90dvw" },
|
|
2019
|
+
style: {}
|
|
2020
|
+
},
|
|
2021
|
+
menu: {
|
|
2022
|
+
ui: {},
|
|
2023
|
+
style: {},
|
|
2024
|
+
text: {
|
|
2025
|
+
variant: "body2",
|
|
2026
|
+
color: "primary",
|
|
2027
|
+
ui: {},
|
|
2028
|
+
style: {}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
};
|
|
2032
|
+
var PlacesAutocomplete = ({
|
|
2033
|
+
onSelect,
|
|
2034
|
+
onChangeForm,
|
|
2035
|
+
language = "en",
|
|
2036
|
+
provider = "google",
|
|
2037
|
+
defaultLocation,
|
|
2038
|
+
keyApi,
|
|
2039
|
+
propsComponent = initPropsComponent
|
|
2040
|
+
}) => {
|
|
2041
|
+
const [value, setValue] = React17.useState(null);
|
|
2042
|
+
const inputRef = React17.useRef(null);
|
|
2043
|
+
const [anchorEl, setAnchorEl] = React17.useState(null);
|
|
2044
|
+
const { suggestions, selectPlace } = useAutocompletePlaces({ input: value, apiKey: keyApi, language, provider });
|
|
2045
|
+
const handleSelect = async (id) => {
|
|
2046
|
+
const place = await selectPlace(id);
|
|
2047
|
+
const locationData = {
|
|
2048
|
+
name: place.name || "",
|
|
2049
|
+
address: place.address,
|
|
2050
|
+
city: place.city || "",
|
|
2051
|
+
country: place.country || "",
|
|
2052
|
+
zip: place.zip || "",
|
|
2053
|
+
lat: place.lat,
|
|
2054
|
+
lng: place.lng,
|
|
2055
|
+
code: place.code || "",
|
|
2056
|
+
phone: place.phone || "",
|
|
2057
|
+
placeId: id
|
|
2058
|
+
};
|
|
2059
|
+
onSelect(locationData);
|
|
2060
|
+
setValue(place.address);
|
|
2061
|
+
setAnchorEl(null);
|
|
2062
|
+
};
|
|
2063
|
+
React17.useEffect(() => {
|
|
2064
|
+
if (defaultLocation) {
|
|
2065
|
+
setValue(defaultLocation);
|
|
2066
|
+
}
|
|
2067
|
+
}, [defaultLocation]);
|
|
2068
|
+
React17.useEffect(() => {
|
|
2069
|
+
if (value === "") {
|
|
2070
|
+
onSelect(null);
|
|
2071
|
+
}
|
|
2072
|
+
}, [value]);
|
|
2073
|
+
const handleChange = (e) => {
|
|
2074
|
+
setValue(e.target.value);
|
|
2075
|
+
setAnchorEl(e.target.value ? inputRef.current : null);
|
|
2076
|
+
};
|
|
2077
|
+
const open = suggestions.length > 0 && Boolean(anchorEl);
|
|
2078
|
+
React17.useEffect(() => {
|
|
2079
|
+
if (onChangeForm) {
|
|
2080
|
+
onChangeForm({ target: { value } });
|
|
2081
|
+
}
|
|
2082
|
+
}, [onChangeForm]);
|
|
2083
|
+
return /* @__PURE__ */ jsxs12(Control, { ...propsComponent?.control, children: [
|
|
2084
|
+
/* @__PURE__ */ jsx33(
|
|
2085
|
+
Input,
|
|
2086
|
+
{
|
|
2087
|
+
ref: inputRef,
|
|
2088
|
+
type: "text",
|
|
2089
|
+
value,
|
|
2090
|
+
onChange: handleChange,
|
|
2091
|
+
propsComponent: {
|
|
2092
|
+
label: propsComponent.label
|
|
2093
|
+
},
|
|
2094
|
+
...propsComponent?.input
|
|
2095
|
+
},
|
|
2096
|
+
"input-places"
|
|
2097
|
+
),
|
|
2098
|
+
open && /* @__PURE__ */ jsx33("div", { className: "yr3Places--menu", style: composeStyles(propsComponent.menu?.ui, propsComponent?.menu?.style), children: /* @__PURE__ */ jsx33(Flex, { container: true, ui: { p: 1 }, children: suggestions.map((s) => /* @__PURE__ */ jsx33(Flex, { onClick: () => handleSelect(s.id), ui: { padding: 8, cursor: "pointer", "&:hover": { backgroundColor: "rgba(0,0,0,0.1)" } }, children: /* @__PURE__ */ jsx33(Text, { ...propsComponent?.menu?.text, children: s.description }) }, s.id)) }) })
|
|
2099
|
+
] });
|
|
2100
|
+
};
|
|
2101
|
+
|
|
1943
2102
|
// src/components/Radio/radio.variants.ts
|
|
1944
2103
|
var radioVariant = createVariants({
|
|
1945
2104
|
base: "yr3Radio",
|
|
@@ -1959,7 +2118,7 @@ var radioVariant = createVariants({
|
|
|
1959
2118
|
});
|
|
1960
2119
|
|
|
1961
2120
|
// src/components/Radio/Radio.tsx
|
|
1962
|
-
import { jsx as jsx34, jsxs as
|
|
2121
|
+
import { jsx as jsx34, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1963
2122
|
var Radio = ({
|
|
1964
2123
|
checked,
|
|
1965
2124
|
value,
|
|
@@ -1975,7 +2134,7 @@ var Radio = ({
|
|
|
1975
2134
|
const bemClass = bem("yr3Radio");
|
|
1976
2135
|
const classes = bemClass(void 0, { [color]: `color-${color}` });
|
|
1977
2136
|
const variantClass = radioVariant({ variant });
|
|
1978
|
-
return /* @__PURE__ */
|
|
2137
|
+
return /* @__PURE__ */ jsxs13("label", { className: classes, "data-testid": "yr3Radio", style: composeStyles(propsComponent?.radio?.ui, propsComponent?.radio?.style), children: [
|
|
1979
2138
|
/* @__PURE__ */ jsx34(
|
|
1980
2139
|
"input",
|
|
1981
2140
|
{
|
|
@@ -2003,13 +2162,13 @@ var Radio = ({
|
|
|
2003
2162
|
|
|
2004
2163
|
// src/components/Select/Select.tsx
|
|
2005
2164
|
import * as React18 from "react";
|
|
2006
|
-
import { jsx as jsx35, jsxs as
|
|
2165
|
+
import { jsx as jsx35, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2007
2166
|
var Select = ({ label, options, name, value, defaultValue, onChange, propsComponent }) => {
|
|
2008
2167
|
const [open, setOpen] = React18.useState(false);
|
|
2009
2168
|
const [valueState, setValueState] = React18.useState(value || defaultValue || null);
|
|
2010
2169
|
const ref = React18.useRef(null);
|
|
2011
2170
|
useClickAway(ref, () => setOpen(false));
|
|
2012
|
-
return /* @__PURE__ */
|
|
2171
|
+
return /* @__PURE__ */ jsxs14(Control, { ...propsComponent?.control, children: [
|
|
2013
2172
|
/* @__PURE__ */ jsx35(
|
|
2014
2173
|
Label,
|
|
2015
2174
|
{
|
|
@@ -2018,8 +2177,8 @@ var Select = ({ label, options, name, value, defaultValue, onChange, propsCompon
|
|
|
2018
2177
|
className: open || valueState ? "yr3Input--active" : ""
|
|
2019
2178
|
}
|
|
2020
2179
|
),
|
|
2021
|
-
/* @__PURE__ */
|
|
2022
|
-
/* @__PURE__ */
|
|
2180
|
+
/* @__PURE__ */ jsxs14("div", { className: "yr3Select-wrapper", ref, children: [
|
|
2181
|
+
/* @__PURE__ */ jsxs14("div", { className: `yr3Select ${open ? "yr3Select--open" : ""}`, "data-testid": "yr3Select-wrapper", style: composeStyles(propsComponent?.wrapper?.ui, propsComponent?.wrapper?.style), children: [
|
|
2023
2182
|
/* @__PURE__ */ jsx35("div", { className: "yr3Select--control", children: valueState }),
|
|
2024
2183
|
/* @__PURE__ */ jsx35("div", { className: "yr3Select--icon", onClick: () => setOpen((prev) => !prev), "data-testid": "yr3Select-icon", children: propsComponent?.icon?.component ? propsComponent.icon.component : /* @__PURE__ */ jsx35(
|
|
2025
2184
|
IconDown,
|
|
@@ -2143,7 +2302,7 @@ var switchVariants = createVariants({
|
|
|
2143
2302
|
});
|
|
2144
2303
|
|
|
2145
2304
|
// src/components/Switch/Switch.tsx
|
|
2146
|
-
import { jsx as jsx37, jsxs as
|
|
2305
|
+
import { jsx as jsx37, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2147
2306
|
var Switch = ({
|
|
2148
2307
|
checked,
|
|
2149
2308
|
defaultChecked,
|
|
@@ -2161,7 +2320,7 @@ var Switch = ({
|
|
|
2161
2320
|
if (!isControlled) setInternal(e.target.checked);
|
|
2162
2321
|
onChange?.(e, e.target.checked);
|
|
2163
2322
|
};
|
|
2164
|
-
return /* @__PURE__ */
|
|
2323
|
+
return /* @__PURE__ */ jsxs15(
|
|
2165
2324
|
"label",
|
|
2166
2325
|
{
|
|
2167
2326
|
className: classname,
|
|
@@ -2198,6 +2357,18 @@ var IconSearch = (props) => {
|
|
|
2198
2357
|
) });
|
|
2199
2358
|
};
|
|
2200
2359
|
|
|
2360
|
+
// src/theme/ThemeProvider.tsx
|
|
2361
|
+
import * as React21 from "react";
|
|
2362
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2363
|
+
var ThemeContext = React21.createContext(null);
|
|
2364
|
+
var ThemeProvider = ({ theme, children }) => {
|
|
2365
|
+
React21.useEffect(() => {
|
|
2366
|
+
applyTheme(theme);
|
|
2367
|
+
}, [theme]);
|
|
2368
|
+
return /* @__PURE__ */ jsx39(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ jsx39(BackdropProvider, { children }) });
|
|
2369
|
+
};
|
|
2370
|
+
var useTheme = () => React21.useContext(ThemeContext);
|
|
2371
|
+
|
|
2201
2372
|
// src/theme/tokens.ts
|
|
2202
2373
|
var baseTokens = {
|
|
2203
2374
|
colors: {
|
|
@@ -2217,11 +2388,11 @@ var baseTokens = {
|
|
|
2217
2388
|
};
|
|
2218
2389
|
|
|
2219
2390
|
// src/theme/notistackContext.tsx
|
|
2220
|
-
import * as
|
|
2221
|
-
import { jsx as
|
|
2222
|
-
var NotistackContext =
|
|
2391
|
+
import * as React22 from "react";
|
|
2392
|
+
import { jsx as jsx40, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2393
|
+
var NotistackContext = React22.createContext(null);
|
|
2223
2394
|
var NotistackProvider = ({ children }) => {
|
|
2224
|
-
const [snacks, setSnacks] =
|
|
2395
|
+
const [snacks, setSnacks] = React22.useState([]);
|
|
2225
2396
|
const enqueueNotistack = (snack) => {
|
|
2226
2397
|
const id = Date.now();
|
|
2227
2398
|
setSnacks((prev) => [...prev, { ...snack, id, exiting: false }]);
|
|
@@ -2236,23 +2407,23 @@ var NotistackProvider = ({ children }) => {
|
|
|
2236
2407
|
setSnacks((prev) => prev.filter((s) => s.id !== id));
|
|
2237
2408
|
}, duration + exitDuration);
|
|
2238
2409
|
};
|
|
2239
|
-
return /* @__PURE__ */
|
|
2410
|
+
return /* @__PURE__ */ jsxs16(NotistackContext.Provider, { value: { enqueueNotistack }, children: [
|
|
2240
2411
|
children,
|
|
2241
|
-
/* @__PURE__ */
|
|
2412
|
+
/* @__PURE__ */ jsx40("div", { className: "yr3NotistackContainer", children: snacks.map((snack) => /* @__PURE__ */ jsx40(Notistack, { ...snack }, snack.id)) })
|
|
2242
2413
|
] });
|
|
2243
2414
|
};
|
|
2244
|
-
var useNotistack = () =>
|
|
2415
|
+
var useNotistack = () => React22.useContext(NotistackContext);
|
|
2245
2416
|
|
|
2246
2417
|
// src/theme/useMediaQuery.tsx
|
|
2247
|
-
import * as
|
|
2418
|
+
import * as React23 from "react";
|
|
2248
2419
|
function useMediaQuery(query) {
|
|
2249
2420
|
const theme = useTheme();
|
|
2250
2421
|
const computedQuery = typeof query === "function" ? query(theme) : query;
|
|
2251
|
-
const [matches, setMatches] =
|
|
2422
|
+
const [matches, setMatches] = React23.useState(() => {
|
|
2252
2423
|
if (typeof window === "undefined") return false;
|
|
2253
2424
|
return window.matchMedia(computedQuery).matches;
|
|
2254
2425
|
});
|
|
2255
|
-
|
|
2426
|
+
React23.useEffect(() => {
|
|
2256
2427
|
if (typeof window === "undefined") return;
|
|
2257
2428
|
const media = window.matchMedia(computedQuery);
|
|
2258
2429
|
const listener = () => setMatches(media.matches);
|
|
@@ -2311,6 +2482,7 @@ export {
|
|
|
2311
2482
|
NotistackProvider,
|
|
2312
2483
|
Pending,
|
|
2313
2484
|
Phone,
|
|
2485
|
+
PlacesAutocomplete,
|
|
2314
2486
|
Radio,
|
|
2315
2487
|
Select,
|
|
2316
2488
|
Slide,
|
|
@@ -2330,9 +2502,13 @@ export {
|
|
|
2330
2502
|
createVariants,
|
|
2331
2503
|
cx,
|
|
2332
2504
|
getContrast,
|
|
2505
|
+
getCountryCodePhone,
|
|
2506
|
+
getDialPhone,
|
|
2333
2507
|
getMonthCalendar,
|
|
2508
|
+
getNumberPhone,
|
|
2334
2509
|
initTheme,
|
|
2335
2510
|
isEmpty,
|
|
2511
|
+
normalizePhone,
|
|
2336
2512
|
text,
|
|
2337
2513
|
times,
|
|
2338
2514
|
uiStyle,
|