@equinor/roma-ui 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +8 -6
- package/lib/NumberField/NumberField.d.ts +3 -0
- package/lib/select/styled-comps.d.ts +3 -0
- package/number.js +15 -0
- package/number.mjs +875 -0
- package/package.json +6 -1
- package/select.js +35 -34
- package/select.mjs +76 -81
- package/switch.js +1 -1
- package/switch.mjs +55 -79
- package/useControlledState-D0L6S_5r.js +1 -0
- package/useControlledState-u436Wbp1.mjs +30 -0
package/switch.mjs
CHANGED
|
@@ -1,68 +1,43 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSwitch as
|
|
3
|
-
import {
|
|
4
|
-
import { tokens as
|
|
5
|
-
import { useEds as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, [
|
|
12
|
-
l
|
|
13
|
-
]);
|
|
14
|
-
let d = l ? e : o, b = v((c, ...s) => {
|
|
15
|
-
let n = (h, ...p) => {
|
|
16
|
-
i && (Object.is(d, h) || i(h, ...p)), l || (d = h);
|
|
17
|
-
};
|
|
18
|
-
typeof c == "function" ? (process.env.NODE_ENV !== "production" && console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"), f((p, ...y) => {
|
|
19
|
-
let g = c(l ? d : p, ...y);
|
|
20
|
-
return n(g, ...s), l ? p : g;
|
|
21
|
-
})) : (l || f(c), n(c, ...s));
|
|
22
|
-
}, [
|
|
23
|
-
l,
|
|
24
|
-
d,
|
|
25
|
-
i
|
|
26
|
-
]);
|
|
27
|
-
return [
|
|
28
|
-
d,
|
|
29
|
-
b
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
function E(e = {}) {
|
|
33
|
-
let { isReadOnly: t } = e, [i, o] = V(e.isSelected, e.defaultSelected || !1, e.onChange);
|
|
34
|
-
function f(l) {
|
|
35
|
-
t || o(l);
|
|
1
|
+
import { jsxs as h, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useSwitch as b, useFocusRing as x, useHover as _, VisuallyHidden as v } from "react-aria";
|
|
3
|
+
import { useRef as C, useMemo as R } from "react";
|
|
4
|
+
import { tokens as c } from "@equinor/eds-tokens";
|
|
5
|
+
import { useEds as L, Typography as k } from "@equinor/eds-core-react";
|
|
6
|
+
import { $ as O } from "./useControlledState-u436Wbp1.mjs";
|
|
7
|
+
function $(t = {}) {
|
|
8
|
+
let { isReadOnly: e } = t, [i, s] = O(t.isSelected, t.defaultSelected || !1, t.onChange);
|
|
9
|
+
function o(f) {
|
|
10
|
+
e || s(f);
|
|
36
11
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
12
|
+
function d() {
|
|
13
|
+
e || s(!i);
|
|
39
14
|
}
|
|
40
15
|
return {
|
|
41
16
|
isSelected: i,
|
|
42
|
-
setSelected:
|
|
43
|
-
toggle:
|
|
17
|
+
setSelected: o,
|
|
18
|
+
toggle: d
|
|
44
19
|
};
|
|
45
20
|
}
|
|
46
|
-
const
|
|
21
|
+
const y = {
|
|
47
22
|
close: "M8.21967 9.28033C8.51256 9.57322 8.98744 9.57322 9.28033 9.28033C9.57322 8.98744 9.57322 8.51256 9.28033 8.21967L6.06066 5L9.28033 1.78033C9.57322 1.48744 9.57322 1.01256 9.28033 0.71967C8.98744 0.426777 8.51256 0.426777 8.21967 0.71967L5 3.93934L1.78033 0.71967C1.48744 0.426777 1.01256 0.426777 0.71967 0.71967C0.426777 1.01256 0.426777 1.48744 0.71967 1.78033L3.93934 5L0.71967 8.21967C0.426777 8.51256 0.426777 8.98744 0.71967 9.28033C1.01256 9.57322 1.48744 9.57322 1.78033 9.28033L5 6.06066L8.21967 9.28033Z",
|
|
48
23
|
check: "M13.0303 4.21967C13.3232 4.51256 13.3232 4.98744 13.0303 5.28033L6.78033 11.5303C6.48744 11.8232 6.01256 11.8232 5.71967 11.5303L2.96967 8.78033C2.67678 8.48744 2.67678 8.01256 2.96967 7.71967C3.26256 7.42678 3.73744 7.42678 4.03033 7.71967L6.25 9.93934L11.9697 4.21967C12.2626 3.92678 12.7374 3.92678 13.0303 4.21967Z"
|
|
49
24
|
};
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
...
|
|
53
|
-
isDisabled:
|
|
54
|
-
isReadOnly:
|
|
55
|
-
isSelected:
|
|
56
|
-
defaultSelected:
|
|
57
|
-
}, i =
|
|
58
|
-
ripple:
|
|
59
|
-
background: i.isSelected ?
|
|
60
|
-
circle: i.isSelected ?
|
|
61
|
-
icon: i.isSelected ?
|
|
62
|
-
focus:
|
|
63
|
-
}), [i.isSelected]),
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
-
|
|
25
|
+
function F(t) {
|
|
26
|
+
const e = {
|
|
27
|
+
...t,
|
|
28
|
+
isDisabled: t.isDisabled ?? t.disabled,
|
|
29
|
+
isReadOnly: t.isReadOnly ?? t.readOnly,
|
|
30
|
+
isSelected: t.isSelected ?? t.checked,
|
|
31
|
+
defaultSelected: t.defaultSelected ?? t.defaultChecked
|
|
32
|
+
}, i = $(e), s = C(null), { inputProps: o } = b(e, i, s), { isFocusVisible: d, focusProps: f } = x(), { isHovered: u, hoverProps: g } = _({ isDisabled: !1 }), { density: p } = L(), r = p === "compact", n = R(() => ({
|
|
33
|
+
ripple: c.colors.interactive.primary__hover_alt.rgba,
|
|
34
|
+
background: i.isSelected ? c.colors.interactive.primary__resting.hex : "rgba(220, 220, 220, 1)",
|
|
35
|
+
circle: i.isSelected ? c.colors.interactive.primary__hover_alt.hex : "rgba(111, 111, 111, 1)",
|
|
36
|
+
icon: i.isSelected ? c.colors.interactive.primary__resting.hex : "white",
|
|
37
|
+
focus: c.colors.interactive.primary__resting.hex
|
|
38
|
+
}), [i.isSelected]), m = r ? 32 : 48, S = r ? 4 : 12, a = r ? 0 : 8;
|
|
39
|
+
return /* @__PURE__ */ h(
|
|
40
|
+
k,
|
|
66
41
|
{
|
|
67
42
|
as: "label",
|
|
68
43
|
variant: "text",
|
|
@@ -70,72 +45,73 @@ function W(e) {
|
|
|
70
45
|
style: {
|
|
71
46
|
display: "flex",
|
|
72
47
|
alignItems: "center",
|
|
73
|
-
|
|
74
|
-
|
|
48
|
+
width: "fit-content",
|
|
49
|
+
color: e.isReadOnly || e.isDisabled ? c.colors.text.static_icons__tertiary.rgba : c.colors.text.static_icons__default.rgba,
|
|
50
|
+
cursor: e.isReadOnly || e.isDisabled ? "not-allowed" : "pointer"
|
|
75
51
|
},
|
|
76
52
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ l(v, { children: /* @__PURE__ */ l("input", { ...o, ...f, ref: s }) }),
|
|
54
|
+
/* @__PURE__ */ l(
|
|
79
55
|
"div",
|
|
80
56
|
{
|
|
81
|
-
style: { display: "inline", height:
|
|
82
|
-
...
|
|
83
|
-
children: /* @__PURE__ */
|
|
57
|
+
style: { display: "inline", height: r ? 32 : 48 },
|
|
58
|
+
...g,
|
|
59
|
+
children: /* @__PURE__ */ h(
|
|
84
60
|
"svg",
|
|
85
61
|
{
|
|
86
62
|
width: 60,
|
|
87
|
-
height:
|
|
63
|
+
height: m,
|
|
88
64
|
"aria-hidden": "true",
|
|
89
65
|
style: {
|
|
90
66
|
marginRight: 4,
|
|
91
|
-
opacity:
|
|
67
|
+
opacity: e.isDisabled || e.isReadOnly ? 0.4 : 1
|
|
92
68
|
},
|
|
93
69
|
children: [
|
|
94
|
-
|
|
70
|
+
u && !e.isDisabled && !e.isReadOnly && /* @__PURE__ */ l(
|
|
95
71
|
"circle",
|
|
96
72
|
{
|
|
97
73
|
cx: i.isSelected ? 42 : 20,
|
|
98
|
-
cy: 16 +
|
|
99
|
-
r:
|
|
74
|
+
cy: 16 + a,
|
|
75
|
+
r: r ? 16 : 20,
|
|
100
76
|
fill: n.ripple
|
|
101
77
|
}
|
|
102
78
|
),
|
|
103
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ l(
|
|
104
80
|
"rect",
|
|
105
81
|
{
|
|
106
82
|
x: 8,
|
|
107
|
-
y:
|
|
83
|
+
y: S,
|
|
108
84
|
width: 46,
|
|
109
85
|
height: 24,
|
|
110
86
|
rx: 12,
|
|
111
87
|
fill: n.background
|
|
112
88
|
}
|
|
113
89
|
),
|
|
114
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ l(
|
|
115
91
|
"circle",
|
|
116
92
|
{
|
|
117
93
|
cx: i.isSelected ? 42 : 20,
|
|
118
|
-
cy: 16 +
|
|
94
|
+
cy: 16 + a,
|
|
119
95
|
r: 9.5,
|
|
120
96
|
fill: n.circle
|
|
121
97
|
}
|
|
122
98
|
),
|
|
123
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ l(
|
|
124
100
|
"path",
|
|
125
101
|
{
|
|
126
102
|
fillRule: "evenodd",
|
|
127
103
|
clipRule: "evenodd",
|
|
128
|
-
d: i.isSelected ?
|
|
129
|
-
transform: `translate(${i.isSelected ? 32 : 14},${(i.isSelected ? 6 : 10) +
|
|
104
|
+
d: i.isSelected ? y.check : y.close,
|
|
105
|
+
transform: `translate(${i.isSelected ? 32 : 14},${(i.isSelected ? 6 : 10) + a}) scale(1.2)`,
|
|
130
106
|
fill: n.icon,
|
|
131
107
|
style: { pointerEvents: "none" }
|
|
132
108
|
}
|
|
133
109
|
),
|
|
134
|
-
|
|
110
|
+
d && /* @__PURE__ */ l(
|
|
135
111
|
"rect",
|
|
136
112
|
{
|
|
137
113
|
x: 6,
|
|
138
|
-
y,
|
|
114
|
+
y: a,
|
|
139
115
|
width: 50,
|
|
140
116
|
height: 32,
|
|
141
117
|
rx: 12,
|
|
@@ -150,11 +126,11 @@ function W(e) {
|
|
|
150
126
|
)
|
|
151
127
|
}
|
|
152
128
|
),
|
|
153
|
-
|
|
129
|
+
e.children ?? e.label
|
|
154
130
|
]
|
|
155
131
|
}
|
|
156
132
|
);
|
|
157
133
|
}
|
|
158
134
|
export {
|
|
159
|
-
|
|
135
|
+
F as Switch
|
|
160
136
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("react");function E(o,p,l){let[b,i]=s.useState(o||p),u=s.useRef(o!==void 0),e=o!==void 0;s.useEffect(()=>{let t=u.current;t!==e&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${t?"controlled":"uncontrolled"} to ${e?"controlled":"uncontrolled"}.`),u.current=e},[e]);let n=e?o:b,$=s.useCallback((t,...f)=>{let a=(c,...r)=>{l&&(Object.is(n,c)||l(c,...r)),e||(n=c)};typeof t=="function"?(process.env.NODE_ENV!=="production"&&console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),i((r,...V)=>{let d=t(e?n:r,...V);return a(d,...f),e?r:d})):(e||i(t),a(t,...f))},[e,n,l]);return[n,$]}exports.$458b0a5536c1a7cf$export$40bfa8c7b0832715=E;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState as V, useRef as $, useEffect as E, useCallback as N } from "react";
|
|
2
|
+
function h(o, a, l) {
|
|
3
|
+
let [p, s] = V(o || a), i = $(o !== void 0), e = o !== void 0;
|
|
4
|
+
E(() => {
|
|
5
|
+
let t = i.current;
|
|
6
|
+
t !== e && process.env.NODE_ENV !== "production" && console.warn(`WARN: A component changed from ${t ? "controlled" : "uncontrolled"} to ${e ? "controlled" : "uncontrolled"}.`), i.current = e;
|
|
7
|
+
}, [
|
|
8
|
+
e
|
|
9
|
+
]);
|
|
10
|
+
let n = e ? o : p, b = N((t, ...u) => {
|
|
11
|
+
let f = (r, ...c) => {
|
|
12
|
+
l && (Object.is(n, r) || l(r, ...c)), e || (n = r);
|
|
13
|
+
};
|
|
14
|
+
typeof t == "function" ? (process.env.NODE_ENV !== "production" && console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"), s((c, ...m) => {
|
|
15
|
+
let d = t(e ? n : c, ...m);
|
|
16
|
+
return f(d, ...u), e ? c : d;
|
|
17
|
+
})) : (e || s(t), f(t, ...u));
|
|
18
|
+
}, [
|
|
19
|
+
e,
|
|
20
|
+
n,
|
|
21
|
+
l
|
|
22
|
+
]);
|
|
23
|
+
return [
|
|
24
|
+
n,
|
|
25
|
+
b
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
h as $
|
|
30
|
+
};
|