@equinor/roma-ui 0.1.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/dates.js +1 -0
- package/dates.mjs +17 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/index.mjs +8 -0
- package/lib/dates/date-distance.d.ts +4 -0
- package/lib/dates/index.d.ts +1 -0
- package/lib/select/HelperText.d.ts +4 -0
- package/lib/select/select.d.ts +28 -0
- package/lib/select/styled-comps.d.ts +370 -0
- package/lib/switch/Switch.d.ts +12 -0
- package/package.json +29 -0
- package/select.js +149 -0
- package/select.mjs +284 -0
- package/switch.js +1 -0
- package/switch.mjs +160 -0
package/dates.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("date-fns"),t=require("react"),c=({date:e,now:n=new Date})=>{const[,r]=t.useState(new Date);return t.useEffect(()=>{const a=setInterval(()=>{r(new Date)},6e4);return()=>clearInterval(a)},[]),e?s.formatDistance(new Date(e),n,{addSuffix:!0}):""};exports.DateDistance=c;
|
package/dates.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { formatDistance as a } from "date-fns";
|
|
2
|
+
import { useState as o, useEffect as s } from "react";
|
|
3
|
+
const c = ({
|
|
4
|
+
date: e,
|
|
5
|
+
now: t = /* @__PURE__ */ new Date()
|
|
6
|
+
}) => {
|
|
7
|
+
const [, r] = o(/* @__PURE__ */ new Date());
|
|
8
|
+
return s(() => {
|
|
9
|
+
const n = setInterval(() => {
|
|
10
|
+
r(/* @__PURE__ */ new Date());
|
|
11
|
+
}, 6e4);
|
|
12
|
+
return () => clearInterval(n);
|
|
13
|
+
}, []), e ? a(new Date(e), t, { addSuffix: !0 }) : "";
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
c as DateDistance
|
|
17
|
+
};
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./select.js"),t=require("./switch.js");exports.Option=e.Option;exports.Select=e.Select;exports.Styled=e.Styled;exports.Switch=t.Switch;
|
package/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './date-distance';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ListBoxItemProps, SelectProps, SelectValueRenderProps } from 'react-aria-components';
|
|
2
|
+
import { InputProps } from '@equinor/eds-core-react';
|
|
3
|
+
import { ChangeEventHandler, ReactNode } from 'react';
|
|
4
|
+
import { default as Styled } from './styled-comps';
|
|
5
|
+
type EdsOptionProps<T, U = any> = Partial<{
|
|
6
|
+
value: T;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
item: U;
|
|
10
|
+
}> & ListBoxItemProps<T>;
|
|
11
|
+
export declare const Select: import('react').ForwardRefExoticComponent<Partial<{
|
|
12
|
+
selected: any;
|
|
13
|
+
onSelectedChange: (v: any) => void;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
variant: InputProps["variant"];
|
|
16
|
+
helperText: ReactNode;
|
|
17
|
+
label: string;
|
|
18
|
+
items: Array<object>;
|
|
19
|
+
placeholder: string;
|
|
20
|
+
ariaLabel: string;
|
|
21
|
+
getValueText: (props: SelectValueRenderProps<any>) => ReactNode;
|
|
22
|
+
onChange: ChangeEventHandler;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
readOnly: boolean;
|
|
25
|
+
showClearButton: boolean;
|
|
26
|
+
}> & SelectProps<any> & import('react').RefAttributes<unknown>>;
|
|
27
|
+
export declare const Option: <T>({ value, children, item, ...rest }: EdsOptionProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export { Styled };
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { InputProps } from '@equinor/eds-core-react';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
ListBox: import('styled-components').IStyledComponent<"web", {
|
|
4
|
+
style?: import('react').CSSProperties | ((values: import('react-aria-components').ListBoxRenderProps & {
|
|
5
|
+
defaultStyle: import('react').CSSProperties;
|
|
6
|
+
}) => import('react').CSSProperties | undefined) | undefined;
|
|
7
|
+
slot?: string | null | undefined;
|
|
8
|
+
className?: string | ((values: import('react-aria-components').ListBoxRenderProps & {
|
|
9
|
+
defaultClassName: string | undefined;
|
|
10
|
+
}) => string) | undefined;
|
|
11
|
+
id?: string | undefined;
|
|
12
|
+
orientation?: import('react-aria').Orientation | undefined;
|
|
13
|
+
'aria-describedby'?: string | undefined;
|
|
14
|
+
'aria-details'?: string | undefined;
|
|
15
|
+
'aria-label'?: string | undefined;
|
|
16
|
+
'aria-labelledby'?: string | undefined;
|
|
17
|
+
children?: import('react').ReactNode | ((item: object) => import('react').ReactNode);
|
|
18
|
+
onFocus?: ((e: import('react').FocusEvent<Element, Element>) => void) | undefined;
|
|
19
|
+
onBlur?: ((e: import('react').FocusEvent<Element, Element>) => void) | undefined;
|
|
20
|
+
onScroll?: ((e: import('react').UIEvent<HTMLDivElement, UIEvent>) => void) | undefined;
|
|
21
|
+
key?: import('react').Key | null | undefined;
|
|
22
|
+
autoFocus?: (boolean | import('@react-types/shared').FocusStrategy) | undefined;
|
|
23
|
+
items?: Iterable<object> | undefined;
|
|
24
|
+
disallowEmptySelection?: boolean | undefined;
|
|
25
|
+
onSelectionChange?: ((keys: import('react-aria-components').Selection) => void) | undefined;
|
|
26
|
+
disabledKeys?: Iterable<import('react-aria-components').Key> | undefined;
|
|
27
|
+
onFocusChange?: ((isFocused: boolean) => void) | undefined;
|
|
28
|
+
selectionBehavior?: import('react-stately').SelectionBehavior | undefined;
|
|
29
|
+
onAction?: ((key: import('react-aria-components').Key) => void) | undefined;
|
|
30
|
+
shouldFocusWrap?: boolean | undefined;
|
|
31
|
+
selectionMode?: import('react-aria-components').SelectionMode | undefined;
|
|
32
|
+
selectedKeys?: ("all" | Iterable<import('react-aria-components').Key>) | undefined;
|
|
33
|
+
defaultSelectedKeys?: ("all" | Iterable<import('react-aria-components').Key>) | undefined;
|
|
34
|
+
dragAndDropHooks?: import('react-aria-components').DragAndDropHooks | undefined;
|
|
35
|
+
renderEmptyState?: ((props: import('react-aria-components').ListBoxRenderProps) => import('react').ReactNode) | undefined;
|
|
36
|
+
layout?: "stack" | "grid" | undefined;
|
|
37
|
+
dependencies?: any[] | undefined;
|
|
38
|
+
ref?: ((instance: HTMLDivElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLDivElement> | null | undefined;
|
|
39
|
+
}> & (<T extends object>(props: import('react-aria-components').ListBoxProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null);
|
|
40
|
+
ListBoxItem: import('styled-components').IStyledComponent<"web", import('styled-components/dist/types').Substitute<Omit<import('react-aria-components').ListBoxItemProps<object> & import('react').RefAttributes<object>, "ref"> & {
|
|
41
|
+
ref?: ((instance: object | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<object> | null | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
$density: "compact" | "comfortable";
|
|
44
|
+
}>> & (<T extends object>(props: import('react-aria-components').ListBoxItemProps<T> & React.RefAttributes<T>) => React.ReactElement | null);
|
|
45
|
+
Trigger: import('styled-components').IStyledComponent<"web", import('styled-components/dist/types').Substitute<Omit<import('react-aria-components').ButtonProps & import('react').RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
46
|
+
ref?: ((instance: HTMLButtonElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLButtonElement> | null | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
$variant?: InputProps["variant"];
|
|
49
|
+
$hasLabel: boolean;
|
|
50
|
+
$readonly: boolean;
|
|
51
|
+
$density: "compact" | "comfortable";
|
|
52
|
+
}>> & ((props: import('react-aria-components').ButtonProps & React.RefAttributes<HTMLButtonElement>) => React.ReactElement | null);
|
|
53
|
+
Wrapper: import('styled-components').IStyledComponent<"web", import('styled-components/dist/types').Substitute<Omit<import('react-aria-components').SelectProps<object> & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
|
|
54
|
+
ref?: ((instance: HTMLDivElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLDivElement> | null | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
$variant?: InputProps["variant"];
|
|
57
|
+
}>> & (<T extends object>(props: import('react-aria-components').SelectProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null);
|
|
58
|
+
Label: import('styled-components').IStyledComponent<"web", {
|
|
59
|
+
form?: string | undefined | undefined;
|
|
60
|
+
style?: import('react').CSSProperties | undefined;
|
|
61
|
+
slot?: string | undefined | undefined;
|
|
62
|
+
title?: string | undefined | undefined;
|
|
63
|
+
suppressHydrationWarning?: boolean | undefined | undefined;
|
|
64
|
+
className?: string | undefined | undefined;
|
|
65
|
+
color?: string | undefined | undefined;
|
|
66
|
+
id?: string | undefined | undefined;
|
|
67
|
+
lang?: string | undefined | undefined;
|
|
68
|
+
role?: import('react').AriaRole | undefined;
|
|
69
|
+
tabIndex?: number | undefined | undefined;
|
|
70
|
+
"aria-activedescendant"?: string | undefined | undefined;
|
|
71
|
+
"aria-atomic"?: (boolean | "true" | "false") | undefined;
|
|
72
|
+
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
73
|
+
"aria-braillelabel"?: string | undefined | undefined;
|
|
74
|
+
"aria-brailleroledescription"?: string | undefined | undefined;
|
|
75
|
+
"aria-busy"?: (boolean | "true" | "false") | undefined;
|
|
76
|
+
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
|
|
77
|
+
"aria-colcount"?: number | undefined | undefined;
|
|
78
|
+
"aria-colindex"?: number | undefined | undefined;
|
|
79
|
+
"aria-colindextext"?: string | undefined | undefined;
|
|
80
|
+
"aria-colspan"?: number | undefined | undefined;
|
|
81
|
+
"aria-controls"?: string | undefined | undefined;
|
|
82
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined | undefined;
|
|
83
|
+
"aria-describedby"?: string | undefined | undefined;
|
|
84
|
+
"aria-description"?: string | undefined | undefined;
|
|
85
|
+
"aria-details"?: string | undefined | undefined;
|
|
86
|
+
"aria-disabled"?: (boolean | "true" | "false") | undefined;
|
|
87
|
+
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
|
|
88
|
+
"aria-errormessage"?: string | undefined | undefined;
|
|
89
|
+
"aria-expanded"?: (boolean | "true" | "false") | undefined;
|
|
90
|
+
"aria-flowto"?: string | undefined | undefined;
|
|
91
|
+
"aria-grabbed"?: (boolean | "true" | "false") | undefined;
|
|
92
|
+
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | undefined;
|
|
93
|
+
"aria-hidden"?: (boolean | "true" | "false") | undefined;
|
|
94
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined;
|
|
95
|
+
"aria-keyshortcuts"?: string | undefined | undefined;
|
|
96
|
+
"aria-label"?: string | undefined | undefined;
|
|
97
|
+
"aria-labelledby"?: string | undefined | undefined;
|
|
98
|
+
"aria-level"?: number | undefined | undefined;
|
|
99
|
+
"aria-live"?: "off" | "assertive" | "polite" | undefined | undefined;
|
|
100
|
+
"aria-modal"?: (boolean | "true" | "false") | undefined;
|
|
101
|
+
"aria-multiline"?: (boolean | "true" | "false") | undefined;
|
|
102
|
+
"aria-multiselectable"?: (boolean | "true" | "false") | undefined;
|
|
103
|
+
"aria-orientation"?: "horizontal" | "vertical" | undefined | undefined;
|
|
104
|
+
"aria-owns"?: string | undefined | undefined;
|
|
105
|
+
"aria-placeholder"?: string | undefined | undefined;
|
|
106
|
+
"aria-posinset"?: number | undefined | undefined;
|
|
107
|
+
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
|
|
108
|
+
"aria-readonly"?: (boolean | "true" | "false") | undefined;
|
|
109
|
+
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
|
|
110
|
+
"aria-required"?: (boolean | "true" | "false") | undefined;
|
|
111
|
+
"aria-roledescription"?: string | undefined | undefined;
|
|
112
|
+
"aria-rowcount"?: number | undefined | undefined;
|
|
113
|
+
"aria-rowindex"?: number | undefined | undefined;
|
|
114
|
+
"aria-rowindextext"?: string | undefined | undefined;
|
|
115
|
+
"aria-rowspan"?: number | undefined | undefined;
|
|
116
|
+
"aria-selected"?: (boolean | "true" | "false") | undefined;
|
|
117
|
+
"aria-setsize"?: number | undefined | undefined;
|
|
118
|
+
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
|
|
119
|
+
"aria-valuemax"?: number | undefined | undefined;
|
|
120
|
+
"aria-valuemin"?: number | undefined | undefined;
|
|
121
|
+
"aria-valuenow"?: number | undefined | undefined;
|
|
122
|
+
"aria-valuetext"?: string | undefined | undefined;
|
|
123
|
+
children?: import('react').ReactNode;
|
|
124
|
+
dangerouslySetInnerHTML?: {
|
|
125
|
+
__html: string | TrustedHTML;
|
|
126
|
+
} | undefined | undefined;
|
|
127
|
+
onCopy?: import('react').ClipboardEventHandler<HTMLLabelElement> | undefined;
|
|
128
|
+
onCopyCapture?: import('react').ClipboardEventHandler<HTMLLabelElement> | undefined;
|
|
129
|
+
onCut?: import('react').ClipboardEventHandler<HTMLLabelElement> | undefined;
|
|
130
|
+
onCutCapture?: import('react').ClipboardEventHandler<HTMLLabelElement> | undefined;
|
|
131
|
+
onPaste?: import('react').ClipboardEventHandler<HTMLLabelElement> | undefined;
|
|
132
|
+
onPasteCapture?: import('react').ClipboardEventHandler<HTMLLabelElement> | undefined;
|
|
133
|
+
onCompositionEnd?: import('react').CompositionEventHandler<HTMLLabelElement> | undefined;
|
|
134
|
+
onCompositionEndCapture?: import('react').CompositionEventHandler<HTMLLabelElement> | undefined;
|
|
135
|
+
onCompositionStart?: import('react').CompositionEventHandler<HTMLLabelElement> | undefined;
|
|
136
|
+
onCompositionStartCapture?: import('react').CompositionEventHandler<HTMLLabelElement> | undefined;
|
|
137
|
+
onCompositionUpdate?: import('react').CompositionEventHandler<HTMLLabelElement> | undefined;
|
|
138
|
+
onCompositionUpdateCapture?: import('react').CompositionEventHandler<HTMLLabelElement> | undefined;
|
|
139
|
+
onFocus?: import('react').FocusEventHandler<HTMLLabelElement> | undefined;
|
|
140
|
+
onFocusCapture?: import('react').FocusEventHandler<HTMLLabelElement> | undefined;
|
|
141
|
+
onBlur?: import('react').FocusEventHandler<HTMLLabelElement> | undefined;
|
|
142
|
+
onBlurCapture?: import('react').FocusEventHandler<HTMLLabelElement> | undefined;
|
|
143
|
+
onChange?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
144
|
+
onChangeCapture?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
145
|
+
onBeforeInput?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
146
|
+
onBeforeInputCapture?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
147
|
+
onInput?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
148
|
+
onInputCapture?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
149
|
+
onReset?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
150
|
+
onResetCapture?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
151
|
+
onSubmit?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
152
|
+
onSubmitCapture?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
153
|
+
onInvalid?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
154
|
+
onInvalidCapture?: import('react').FormEventHandler<HTMLLabelElement> | undefined;
|
|
155
|
+
onLoad?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
156
|
+
onLoadCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
157
|
+
onError?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
158
|
+
onErrorCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
159
|
+
onKeyDown?: import('react').KeyboardEventHandler<HTMLLabelElement> | undefined;
|
|
160
|
+
onKeyDownCapture?: import('react').KeyboardEventHandler<HTMLLabelElement> | undefined;
|
|
161
|
+
onKeyPress?: import('react').KeyboardEventHandler<HTMLLabelElement> | undefined;
|
|
162
|
+
onKeyPressCapture?: import('react').KeyboardEventHandler<HTMLLabelElement> | undefined;
|
|
163
|
+
onKeyUp?: import('react').KeyboardEventHandler<HTMLLabelElement> | undefined;
|
|
164
|
+
onKeyUpCapture?: import('react').KeyboardEventHandler<HTMLLabelElement> | undefined;
|
|
165
|
+
onAbort?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
166
|
+
onAbortCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
167
|
+
onCanPlay?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
168
|
+
onCanPlayCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
169
|
+
onCanPlayThrough?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
170
|
+
onCanPlayThroughCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
171
|
+
onDurationChange?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
172
|
+
onDurationChangeCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
173
|
+
onEmptied?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
174
|
+
onEmptiedCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
175
|
+
onEncrypted?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
176
|
+
onEncryptedCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
177
|
+
onEnded?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
178
|
+
onEndedCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
179
|
+
onLoadedData?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
180
|
+
onLoadedDataCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
181
|
+
onLoadedMetadata?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
182
|
+
onLoadedMetadataCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
183
|
+
onLoadStart?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
184
|
+
onLoadStartCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
185
|
+
onPause?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
186
|
+
onPauseCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
187
|
+
onPlay?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
188
|
+
onPlayCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
189
|
+
onPlaying?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
190
|
+
onPlayingCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
191
|
+
onProgress?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
192
|
+
onProgressCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
193
|
+
onRateChange?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
194
|
+
onRateChangeCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
195
|
+
onResize?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
196
|
+
onResizeCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
197
|
+
onSeeked?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
198
|
+
onSeekedCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
199
|
+
onSeeking?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
200
|
+
onSeekingCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
201
|
+
onStalled?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
202
|
+
onStalledCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
203
|
+
onSuspend?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
204
|
+
onSuspendCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
205
|
+
onTimeUpdate?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
206
|
+
onTimeUpdateCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
207
|
+
onVolumeChange?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
208
|
+
onVolumeChangeCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
209
|
+
onWaiting?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
210
|
+
onWaitingCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
211
|
+
onAuxClick?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
212
|
+
onAuxClickCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
213
|
+
onClick?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
214
|
+
onClickCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
215
|
+
onContextMenu?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
216
|
+
onContextMenuCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
217
|
+
onDoubleClick?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
218
|
+
onDoubleClickCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
219
|
+
onDrag?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
220
|
+
onDragCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
221
|
+
onDragEnd?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
222
|
+
onDragEndCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
223
|
+
onDragEnter?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
224
|
+
onDragEnterCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
225
|
+
onDragExit?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
226
|
+
onDragExitCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
227
|
+
onDragLeave?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
228
|
+
onDragLeaveCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
229
|
+
onDragOver?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
230
|
+
onDragOverCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
231
|
+
onDragStart?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
232
|
+
onDragStartCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
233
|
+
onDrop?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
234
|
+
onDropCapture?: import('react').DragEventHandler<HTMLLabelElement> | undefined;
|
|
235
|
+
onMouseDown?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
236
|
+
onMouseDownCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
237
|
+
onMouseEnter?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
238
|
+
onMouseLeave?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
239
|
+
onMouseMove?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
240
|
+
onMouseMoveCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
241
|
+
onMouseOut?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
242
|
+
onMouseOutCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
243
|
+
onMouseOver?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
244
|
+
onMouseOverCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
245
|
+
onMouseUp?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
246
|
+
onMouseUpCapture?: import('react').MouseEventHandler<HTMLLabelElement> | undefined;
|
|
247
|
+
onSelect?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
248
|
+
onSelectCapture?: import('react').ReactEventHandler<HTMLLabelElement> | undefined;
|
|
249
|
+
onTouchCancel?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
250
|
+
onTouchCancelCapture?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
251
|
+
onTouchEnd?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
252
|
+
onTouchEndCapture?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
253
|
+
onTouchMove?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
254
|
+
onTouchMoveCapture?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
255
|
+
onTouchStart?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
256
|
+
onTouchStartCapture?: import('react').TouchEventHandler<HTMLLabelElement> | undefined;
|
|
257
|
+
onPointerDown?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
258
|
+
onPointerDownCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
259
|
+
onPointerMove?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
260
|
+
onPointerMoveCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
261
|
+
onPointerUp?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
262
|
+
onPointerUpCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
263
|
+
onPointerCancel?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
264
|
+
onPointerCancelCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
265
|
+
onPointerEnter?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
266
|
+
onPointerLeave?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
267
|
+
onPointerOver?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
268
|
+
onPointerOverCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
269
|
+
onPointerOut?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
270
|
+
onPointerOutCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
271
|
+
onGotPointerCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
272
|
+
onGotPointerCaptureCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
273
|
+
onLostPointerCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
274
|
+
onLostPointerCaptureCapture?: import('react').PointerEventHandler<HTMLLabelElement> | undefined;
|
|
275
|
+
onScroll?: import('react').UIEventHandler<HTMLLabelElement> | undefined;
|
|
276
|
+
onScrollCapture?: import('react').UIEventHandler<HTMLLabelElement> | undefined;
|
|
277
|
+
onWheel?: import('react').WheelEventHandler<HTMLLabelElement> | undefined;
|
|
278
|
+
onWheelCapture?: import('react').WheelEventHandler<HTMLLabelElement> | undefined;
|
|
279
|
+
onAnimationStart?: import('react').AnimationEventHandler<HTMLLabelElement> | undefined;
|
|
280
|
+
onAnimationStartCapture?: import('react').AnimationEventHandler<HTMLLabelElement> | undefined;
|
|
281
|
+
onAnimationEnd?: import('react').AnimationEventHandler<HTMLLabelElement> | undefined;
|
|
282
|
+
onAnimationEndCapture?: import('react').AnimationEventHandler<HTMLLabelElement> | undefined;
|
|
283
|
+
onAnimationIteration?: import('react').AnimationEventHandler<HTMLLabelElement> | undefined;
|
|
284
|
+
onAnimationIterationCapture?: import('react').AnimationEventHandler<HTMLLabelElement> | undefined;
|
|
285
|
+
onTransitionEnd?: import('react').TransitionEventHandler<HTMLLabelElement> | undefined;
|
|
286
|
+
onTransitionEndCapture?: import('react').TransitionEventHandler<HTMLLabelElement> | undefined;
|
|
287
|
+
key?: import('react').Key | null | undefined;
|
|
288
|
+
defaultChecked?: boolean | undefined | undefined;
|
|
289
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
290
|
+
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
291
|
+
accessKey?: string | undefined | undefined;
|
|
292
|
+
autoFocus?: boolean | undefined | undefined;
|
|
293
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
294
|
+
contextMenu?: string | undefined | undefined;
|
|
295
|
+
dir?: string | undefined | undefined;
|
|
296
|
+
draggable?: (boolean | "true" | "false") | undefined;
|
|
297
|
+
hidden?: boolean | undefined | undefined;
|
|
298
|
+
nonce?: string | undefined | undefined;
|
|
299
|
+
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
300
|
+
translate?: "yes" | "no" | undefined | undefined;
|
|
301
|
+
radioGroup?: string | undefined | undefined;
|
|
302
|
+
about?: string | undefined | undefined;
|
|
303
|
+
content?: string | undefined | undefined;
|
|
304
|
+
datatype?: string | undefined | undefined;
|
|
305
|
+
inlist?: any;
|
|
306
|
+
prefix?: string | undefined | undefined;
|
|
307
|
+
property?: string | undefined | undefined;
|
|
308
|
+
rel?: string | undefined | undefined;
|
|
309
|
+
resource?: string | undefined | undefined;
|
|
310
|
+
rev?: string | undefined | undefined;
|
|
311
|
+
typeof?: string | undefined | undefined;
|
|
312
|
+
vocab?: string | undefined | undefined;
|
|
313
|
+
autoCapitalize?: string | undefined | undefined;
|
|
314
|
+
autoCorrect?: string | undefined | undefined;
|
|
315
|
+
autoSave?: string | undefined | undefined;
|
|
316
|
+
itemProp?: string | undefined | undefined;
|
|
317
|
+
itemScope?: boolean | undefined | undefined;
|
|
318
|
+
itemType?: string | undefined | undefined;
|
|
319
|
+
itemID?: string | undefined | undefined;
|
|
320
|
+
itemRef?: string | undefined | undefined;
|
|
321
|
+
results?: number | undefined | undefined;
|
|
322
|
+
security?: string | undefined | undefined;
|
|
323
|
+
unselectable?: "on" | "off" | undefined | undefined;
|
|
324
|
+
inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
325
|
+
is?: string | undefined | undefined;
|
|
326
|
+
htmlFor?: string | undefined | undefined;
|
|
327
|
+
elementType?: string | undefined;
|
|
328
|
+
ref?: ((instance: HTMLLabelElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLLabelElement> | null | undefined;
|
|
329
|
+
}> & ((props: import('react-aria-components').LabelProps & React.RefAttributes<HTMLLabelElement>) => React.ReactElement | null);
|
|
330
|
+
Popover: import('styled-components').IStyledComponent<"web", {
|
|
331
|
+
style?: import('react').CSSProperties | ((values: import('react-aria-components').PopoverRenderProps & {
|
|
332
|
+
defaultStyle: import('react').CSSProperties;
|
|
333
|
+
}) => import('react').CSSProperties | undefined) | undefined;
|
|
334
|
+
slot?: string | null | undefined;
|
|
335
|
+
className?: string | ((values: import('react-aria-components').PopoverRenderProps & {
|
|
336
|
+
defaultClassName: string | undefined;
|
|
337
|
+
}) => string) | undefined;
|
|
338
|
+
offset?: number | undefined;
|
|
339
|
+
children?: import('react').ReactNode | ((values: import('react-aria-components').PopoverRenderProps & {
|
|
340
|
+
defaultChildren: import('react').ReactNode | undefined;
|
|
341
|
+
}) => import('react').ReactNode);
|
|
342
|
+
key?: import('react').Key | null | undefined;
|
|
343
|
+
isOpen?: boolean | undefined;
|
|
344
|
+
defaultOpen?: boolean | undefined;
|
|
345
|
+
onOpenChange?: ((isOpen: boolean) => void) | undefined;
|
|
346
|
+
placement?: import('react-aria').Placement | undefined;
|
|
347
|
+
containerPadding?: number | undefined;
|
|
348
|
+
crossOffset?: number | undefined;
|
|
349
|
+
shouldFlip?: boolean | undefined;
|
|
350
|
+
triggerRef?: import('@react-types/shared').RefObject<Element | null> | undefined;
|
|
351
|
+
boundaryElement?: Element | undefined;
|
|
352
|
+
scrollRef?: import('@react-types/shared').RefObject<Element | null> | undefined;
|
|
353
|
+
shouldUpdatePosition?: boolean | undefined;
|
|
354
|
+
maxHeight?: number | undefined;
|
|
355
|
+
arrowBoundaryOffset?: number | undefined;
|
|
356
|
+
groupRef?: import('@react-types/shared').RefObject<Element | null> | undefined;
|
|
357
|
+
isNonModal?: boolean | undefined;
|
|
358
|
+
isKeyboardDismissDisabled?: boolean | undefined;
|
|
359
|
+
shouldCloseOnInteractOutside?: ((element: Element) => boolean) | undefined;
|
|
360
|
+
trigger?: string | undefined;
|
|
361
|
+
isEntering?: boolean | undefined;
|
|
362
|
+
isExiting?: boolean | undefined;
|
|
363
|
+
UNSTABLE_portalContainer?: Element | undefined;
|
|
364
|
+
ref?: ((instance: HTMLElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLElement> | null | undefined;
|
|
365
|
+
}> & ((props: import('react-aria-components').PopoverProps & React.RefAttributes<HTMLElement>) => React.ReactElement | null);
|
|
366
|
+
HelperText: ({ helperText }: {
|
|
367
|
+
helperText?: import('react').ReactNode;
|
|
368
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
369
|
+
};
|
|
370
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ToggleStateOptions } from '@react-types/checkbox';
|
|
3
|
+
type Props = ToggleStateOptions & {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function Switch(sourceProps: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@equinor/roma-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": {
|
|
6
|
+
"import": "./index.mjs",
|
|
7
|
+
"require": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"./switch": {
|
|
10
|
+
"types": "./lib/switch/Switch.d.ts",
|
|
11
|
+
"import": "./switch.mjs",
|
|
12
|
+
"require": "./switch.js"
|
|
13
|
+
},
|
|
14
|
+
"./select": {
|
|
15
|
+
"types": "./lib/select/select.d.ts",
|
|
16
|
+
"import": "./select.mjs",
|
|
17
|
+
"require": "./select.js"
|
|
18
|
+
},
|
|
19
|
+
"./dates": {
|
|
20
|
+
"types": "./lib/dates/index.d.ts",
|
|
21
|
+
"import": "./dates.mjs",
|
|
22
|
+
"require": "./dates.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react-aria": "^3.38.0",
|
|
27
|
+
"react-aria-components": "^1.2.1"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/select.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("react-aria-components"),u=require("@equinor/eds-core-react"),A=require("@equinor/eds-icons"),n=require("react"),r=require("styled-components"),t=require("@equinor/eds-tokens"),D=r(u.Typography)`
|
|
2
|
+
variant={'helper'};
|
|
3
|
+
group={$group};
|
|
4
|
+
margin-left: 8px;
|
|
5
|
+
margin-top: 8px;
|
|
6
|
+
`,_=({helperText:e})=>e?o.jsx(D,{group:"input",children:e}):null,W=r(i.Select)`
|
|
7
|
+
--focus-ring-color: red;
|
|
8
|
+
--text-color-placeholder: ${t.tokens.colors.text.static_icons__tertiary.rgba};
|
|
9
|
+
--highlight-background: ${t.tokens.colors.ui.background__light.rgba};
|
|
10
|
+
--highlight-foreground: ${t.tokens.colors.ui.background__light.rgba};
|
|
11
|
+
--trigger-width: 300px;
|
|
12
|
+
--text-color: ${({$variant:e})=>e==="error"?t.tokens.colors.interactive.danger__text.rgba:e==="success"?t.tokens.colors.interactive.success__text.rgba:e==="warning"?t.tokens.colors.interactive.warning__text.rgba:"#000"};
|
|
13
|
+
--label-color: ${({$variant:e})=>e==="error"?t.tokens.colors.interactive.danger__text.rgba:e==="success"?t.tokens.colors.interactive.success__text.rgba:e==="warning"?t.tokens.colors.interactive.warning__text.rgba:t.tokens.colors.text.static_icons__tertiary.rgba};
|
|
14
|
+
--outline-color: ${({$variant:e})=>e==="error"?t.tokens.colors.interactive.danger__resting.rgba:e==="success"?t.tokens.colors.interactive.success__resting.rgba:e==="warning"?t.tokens.colors.interactive.warning__resting.rgba:t.tokens.colors.interactive.primary__resting.rgba};
|
|
15
|
+
outline: none;
|
|
16
|
+
`,F=r(i.Button)`
|
|
17
|
+
--shadow: inset 0px -1px 0px 0px ${t.tokens.colors.text.static_icons__tertiary.rgba};
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
border: 0;
|
|
24
|
+
align-items: center;
|
|
25
|
+
font-size: 1rem;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
text-overflow: ellipsis;
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
background-color: ${({$readonly:e})=>e?t.tokens.colors.ui.background__default.rgba:t.tokens.colors.ui.background__light.rgba};
|
|
30
|
+
> span {
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
text-overflow: ellipsis;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
}
|
|
35
|
+
font-family: ${t.tokens.typography.input.text.fontFamily};
|
|
36
|
+
${({$variant:e,$readonly:a})=>e!=="error"&&!a&&"box-shadow: var(--shadow);"}
|
|
37
|
+
span[data-placeholder] {
|
|
38
|
+
color: ${t.tokens.colors.text.static_icons__tertiary.rgba};
|
|
39
|
+
}
|
|
40
|
+
height: ${({$density:e})=>e==="compact"?"24px":"36px"};
|
|
41
|
+
|
|
42
|
+
&:not([data-focused], [data-pressed]) {
|
|
43
|
+
${({$variant:e})=>e==="error"&&"outline: 1px solid var(--outline-color) !important;"}
|
|
44
|
+
}
|
|
45
|
+
&:focus-visible,
|
|
46
|
+
&[data-pressed] {
|
|
47
|
+
${({$hasLabel:e})=>!e&&`background-color: ${t.tokens.colors.ui.background__medium.rgba};`}
|
|
48
|
+
}
|
|
49
|
+
&:focus-within,
|
|
50
|
+
&[data-pressed] {
|
|
51
|
+
outline: 2px solid var(--outline-color);
|
|
52
|
+
box-shadow: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&[data-readonly] {
|
|
56
|
+
color: var(--text-color) !important;
|
|
57
|
+
cursor: default;
|
|
58
|
+
}
|
|
59
|
+
`,K=r(i.ListBox)`
|
|
60
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 7px 8px, rgba(0, 0, 0, 0.12) 0px 5px 22px,
|
|
61
|
+
rgba(0, 0, 0, 0.14) 0px 12px 17px;
|
|
62
|
+
background-color: var(--eds_ui_background__default, rgba(255, 255, 255, 1));
|
|
63
|
+
border-radius: 4px;
|
|
64
|
+
overflow-y: auto;
|
|
65
|
+
max-height: 300px;
|
|
66
|
+
height: min-content;
|
|
67
|
+
display: block;
|
|
68
|
+
min-height: unset;
|
|
69
|
+
border: none;
|
|
70
|
+
outline: none;
|
|
71
|
+
width: fit-content;
|
|
72
|
+
|
|
73
|
+
.react-aria-Header {
|
|
74
|
+
padding-left: 1.571rem;
|
|
75
|
+
}
|
|
76
|
+
`,f=r(i.ListBoxItem)`
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
outline: none;
|
|
79
|
+
padding: 0 24px;
|
|
80
|
+
height: ${({$density:e})=>e==="compact"?"32px":"48px"};
|
|
81
|
+
display: flex;
|
|
82
|
+
min-width: calc(var(--trigger-width) - 63px);
|
|
83
|
+
align-items: center;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
white-space: nowrap;
|
|
86
|
+
text-overflow: ellipsis;
|
|
87
|
+
& > div {
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
text-overflow: ellipsis;
|
|
91
|
+
}
|
|
92
|
+
&:hover:not([data-disabled]) {
|
|
93
|
+
background-color: ${t.tokens.colors.ui.background__medium.rgba};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&[data-focus-visible] {
|
|
97
|
+
outline: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&[data-disabled] {
|
|
101
|
+
color: var(--text-color-placeholder);
|
|
102
|
+
cursor: not-allowed;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&[data-selected] {
|
|
106
|
+
font-weight: 600;
|
|
107
|
+
background: var(
|
|
108
|
+
--eds_interactive_primary__selected_highlight,
|
|
109
|
+
rgba(230, 250, 236, 1)
|
|
110
|
+
);
|
|
111
|
+
color: var(--text-color);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&[data-focused],
|
|
115
|
+
&[data-pressed] {
|
|
116
|
+
background: var(--highlight-background);
|
|
117
|
+
color: var(--highlight-foreground);
|
|
118
|
+
}
|
|
119
|
+
`,N=r(i.Label)`
|
|
120
|
+
font-size: ${t.tokens.typography.input.label.fontSize};
|
|
121
|
+
font-family: ${t.tokens.typography.input.label.fontFamily};
|
|
122
|
+
font-weight: ${t.tokens.typography.input.label.fontWeight};
|
|
123
|
+
line-height: ${t.tokens.typography.input.label.lineHeight};
|
|
124
|
+
text-align: ${t.tokens.typography.input.label.textAlign};
|
|
125
|
+
color: ${t.tokens.colors.text.static_icons__tertiary.rgba};
|
|
126
|
+
|
|
127
|
+
display: flex;
|
|
128
|
+
justify-content: space-between;
|
|
129
|
+
position: relative;
|
|
130
|
+
margin: 0 8px;
|
|
131
|
+
`,O=r(i.Popover)`
|
|
132
|
+
--text-color: ${t.tokens.colors.text.static_icons__default.rgba};
|
|
133
|
+
--text-color-placeholder: ${t.tokens.colors.text.static_icons__tertiary.rgba};
|
|
134
|
+
--highlight-background: ${t.tokens.colors.ui.background__medium.rgba};
|
|
135
|
+
--highlight-foreground: var(--text-color);
|
|
136
|
+
font-family: Equinor;
|
|
137
|
+
max-width: var(--trigger-width);
|
|
138
|
+
width: 100%;
|
|
139
|
+
border-radius: 10px;
|
|
140
|
+
outline: none;
|
|
141
|
+
`;f.displayName="StyledListBoxItem";const s={ListBox:K,ListBoxItem:f,Trigger:F,Wrapper:W,Label:N,Popover:O,HelperText:_},U=r.div`
|
|
142
|
+
width: 24px;
|
|
143
|
+
height: 24px;
|
|
144
|
+
min-width: 18px;
|
|
145
|
+
margin-right: 2px;
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
border-radius: 50%;
|
|
148
|
+
background-color: ${({$isHover:e})=>e?t.tokens.colors.interactive.primary__hover_alt.rgba:""};
|
|
149
|
+
`,V=n.forwardRef(function({children:e,variant:a,selected:d,onSelectedChange:l,label:g,helperText:y,placeholder:k,items:v,ariaLabel:w,disabledKeys:J,disabled:m,readOnly:p,getValueText:$,onChange:h,showClearButton:Q,...S},L){const[x,j]=n.useState(),{density:B}=u.useEds(),I=n.useMemo(()=>d?`select-option-${d}`:x?`select-option-${x}`:"",[x,d]),q=n.useCallback(R=>{let c=(R??"").toString().replace("select-option-","");c===""&&(c=null),l?l(c):h?h({target:{value:c},currentTarget:{value:c}}):j(c)},[h,l]),T=n.useRef(),C=L??T,[E,H]=n.useState(!1),[M,b]=n.useState(!1),z=()=>{b(!0)},P=()=>{b(!1)};return o.jsxs(s.Wrapper,{onSelectionChange:q,selectedKey:I,$variant:a,autoComplete:"text",placeholder:k??" ",isOpen:p?!1:E,onOpenChange:H,isDisabled:m??p,"aria-label":w,...S,children:[g&&o.jsx(s.Label,{elementType:"label",children:g}),o.jsxs(s.Trigger,{ref:C,$density:B,$variant:a,$readonly:p??!1,"data-readonly":p,$hasLabel:!!g,children:[o.jsx(i.SelectValue,{children:$}),!p&&o.jsx(U,{onMouseEnter:z,onMouseLeave:P,$isHover:M,children:o.jsx(u.Icon,{size:24,data:A.arrow_drop_down,color:t.tokens.colors.interactive.primary__resting.rgba})})]}),o.jsx(s.Popover,{offset:4,UNSTABLE_portalContainer:document.querySelector("#roma-deal")??document.body,children:o.jsx(s.ListBox,{items:v,children:e})}),o.jsx(_,{helperText:y})]})}),G=({value:e,children:a,item:d,...l})=>{const{density:g}=u.useEds();return o.jsx(s.ListBoxItem,{$density:g,id:`select-option-${e}`,value:d,isDisabled:l.disabled,...l,children:a})};exports.Option=G;exports.Select=V;exports.Styled=s;
|
package/select.mjs
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { jsx as t, jsxs as b } from "react/jsx-runtime";
|
|
2
|
+
import { Select as W, Button as q, ListBox as A, ListBoxItem as F, Label as K, Popover as N, SelectValue as U } from "react-aria-components";
|
|
3
|
+
import { Typography as V, useEds as x, Icon as G } from "@equinor/eds-core-react";
|
|
4
|
+
import { arrow_drop_down as J } from "@equinor/eds-icons";
|
|
5
|
+
import { forwardRef as Q, useState as u, useMemo as X, useCallback as Y, useRef as Z } from "react";
|
|
6
|
+
import r from "styled-components";
|
|
7
|
+
import { tokens as o } from "@equinor/eds-tokens";
|
|
8
|
+
const O = r(V)`
|
|
9
|
+
variant={'helper'};
|
|
10
|
+
group={$group};
|
|
11
|
+
margin-left: 8px;
|
|
12
|
+
margin-top: 8px;
|
|
13
|
+
`, _ = ({ helperText: e }) => e ? /* @__PURE__ */ t(
|
|
14
|
+
O,
|
|
15
|
+
{
|
|
16
|
+
group: "input",
|
|
17
|
+
children: e
|
|
18
|
+
}
|
|
19
|
+
) : null, ee = r(W)`
|
|
20
|
+
--focus-ring-color: red;
|
|
21
|
+
--text-color-placeholder: ${o.colors.text.static_icons__tertiary.rgba};
|
|
22
|
+
--highlight-background: ${o.colors.ui.background__light.rgba};
|
|
23
|
+
--highlight-foreground: ${o.colors.ui.background__light.rgba};
|
|
24
|
+
--trigger-width: 300px;
|
|
25
|
+
--text-color: ${({ $variant: e }) => e === "error" ? o.colors.interactive.danger__text.rgba : e === "success" ? o.colors.interactive.success__text.rgba : e === "warning" ? o.colors.interactive.warning__text.rgba : "#000"};
|
|
26
|
+
--label-color: ${({ $variant: e }) => e === "error" ? o.colors.interactive.danger__text.rgba : e === "success" ? o.colors.interactive.success__text.rgba : e === "warning" ? o.colors.interactive.warning__text.rgba : o.colors.text.static_icons__tertiary.rgba};
|
|
27
|
+
--outline-color: ${({ $variant: e }) => e === "error" ? o.colors.interactive.danger__resting.rgba : e === "success" ? o.colors.interactive.success__resting.rgba : e === "warning" ? o.colors.interactive.warning__resting.rgba : o.colors.interactive.primary__resting.rgba};
|
|
28
|
+
outline: none;
|
|
29
|
+
`, oe = r(q)`
|
|
30
|
+
--shadow: inset 0px -1px 0px 0px ${o.colors.text.static_icons__tertiary.rgba};
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
width: 100%;
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
border: 0;
|
|
37
|
+
align-items: center;
|
|
38
|
+
font-size: 1rem;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
background-color: ${({ $readonly: e }) => e ? o.colors.ui.background__default.rgba : o.colors.ui.background__light.rgba};
|
|
43
|
+
> span {
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
}
|
|
48
|
+
font-family: ${o.typography.input.text.fontFamily};
|
|
49
|
+
${({ $variant: e, $readonly: i }) => e !== "error" && !i && "box-shadow: var(--shadow);"}
|
|
50
|
+
span[data-placeholder] {
|
|
51
|
+
color: ${o.colors.text.static_icons__tertiary.rgba};
|
|
52
|
+
}
|
|
53
|
+
height: ${({ $density: e }) => e === "compact" ? "24px" : "36px"};
|
|
54
|
+
|
|
55
|
+
&:not([data-focused], [data-pressed]) {
|
|
56
|
+
${({ $variant: e }) => e === "error" && "outline: 1px solid var(--outline-color) !important;"}
|
|
57
|
+
}
|
|
58
|
+
&:focus-visible,
|
|
59
|
+
&[data-pressed] {
|
|
60
|
+
${({ $hasLabel: e }) => !e && `background-color: ${o.colors.ui.background__medium.rgba};`}
|
|
61
|
+
}
|
|
62
|
+
&:focus-within,
|
|
63
|
+
&[data-pressed] {
|
|
64
|
+
outline: 2px solid var(--outline-color);
|
|
65
|
+
box-shadow: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&[data-readonly] {
|
|
69
|
+
color: var(--text-color) !important;
|
|
70
|
+
cursor: default;
|
|
71
|
+
}
|
|
72
|
+
`, te = r(A)`
|
|
73
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 7px 8px, rgba(0, 0, 0, 0.12) 0px 5px 22px,
|
|
74
|
+
rgba(0, 0, 0, 0.14) 0px 12px 17px;
|
|
75
|
+
background-color: var(--eds_ui_background__default, rgba(255, 255, 255, 1));
|
|
76
|
+
border-radius: 4px;
|
|
77
|
+
overflow-y: auto;
|
|
78
|
+
max-height: 300px;
|
|
79
|
+
height: min-content;
|
|
80
|
+
display: block;
|
|
81
|
+
min-height: unset;
|
|
82
|
+
border: none;
|
|
83
|
+
outline: none;
|
|
84
|
+
width: fit-content;
|
|
85
|
+
|
|
86
|
+
.react-aria-Header {
|
|
87
|
+
padding-left: 1.571rem;
|
|
88
|
+
}
|
|
89
|
+
`, f = r(F)`
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
outline: none;
|
|
92
|
+
padding: 0 24px;
|
|
93
|
+
height: ${({ $density: e }) => e === "compact" ? "32px" : "48px"};
|
|
94
|
+
display: flex;
|
|
95
|
+
min-width: calc(var(--trigger-width) - 63px);
|
|
96
|
+
align-items: center;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
& > div {
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
text-overflow: ellipsis;
|
|
104
|
+
}
|
|
105
|
+
&:hover:not([data-disabled]) {
|
|
106
|
+
background-color: ${o.colors.ui.background__medium.rgba};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&[data-focus-visible] {
|
|
110
|
+
outline: none;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&[data-disabled] {
|
|
114
|
+
color: var(--text-color-placeholder);
|
|
115
|
+
cursor: not-allowed;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&[data-selected] {
|
|
119
|
+
font-weight: 600;
|
|
120
|
+
background: var(
|
|
121
|
+
--eds_interactive_primary__selected_highlight,
|
|
122
|
+
rgba(230, 250, 236, 1)
|
|
123
|
+
);
|
|
124
|
+
color: var(--text-color);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&[data-focused],
|
|
128
|
+
&[data-pressed] {
|
|
129
|
+
background: var(--highlight-background);
|
|
130
|
+
color: var(--highlight-foreground);
|
|
131
|
+
}
|
|
132
|
+
`, re = r(K)`
|
|
133
|
+
font-size: ${o.typography.input.label.fontSize};
|
|
134
|
+
font-family: ${o.typography.input.label.fontFamily};
|
|
135
|
+
font-weight: ${o.typography.input.label.fontWeight};
|
|
136
|
+
line-height: ${o.typography.input.label.lineHeight};
|
|
137
|
+
text-align: ${o.typography.input.label.textAlign};
|
|
138
|
+
color: ${o.colors.text.static_icons__tertiary.rgba};
|
|
139
|
+
|
|
140
|
+
display: flex;
|
|
141
|
+
justify-content: space-between;
|
|
142
|
+
position: relative;
|
|
143
|
+
margin: 0 8px;
|
|
144
|
+
`, ie = r(N)`
|
|
145
|
+
--text-color: ${o.colors.text.static_icons__default.rgba};
|
|
146
|
+
--text-color-placeholder: ${o.colors.text.static_icons__tertiary.rgba};
|
|
147
|
+
--highlight-background: ${o.colors.ui.background__medium.rgba};
|
|
148
|
+
--highlight-foreground: var(--text-color);
|
|
149
|
+
font-family: Equinor;
|
|
150
|
+
max-width: var(--trigger-width);
|
|
151
|
+
width: 100%;
|
|
152
|
+
border-radius: 10px;
|
|
153
|
+
outline: none;
|
|
154
|
+
`;
|
|
155
|
+
f.displayName = "StyledListBoxItem";
|
|
156
|
+
const s = {
|
|
157
|
+
ListBox: te,
|
|
158
|
+
ListBoxItem: f,
|
|
159
|
+
Trigger: oe,
|
|
160
|
+
Wrapper: ee,
|
|
161
|
+
Label: re,
|
|
162
|
+
Popover: ie,
|
|
163
|
+
HelperText: _
|
|
164
|
+
}, ae = r.div`
|
|
165
|
+
width: 24px;
|
|
166
|
+
height: 24px;
|
|
167
|
+
min-width: 18px;
|
|
168
|
+
margin-right: 2px;
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
border-radius: 50%;
|
|
171
|
+
background-color: ${({ $isHover: e }) => e ? o.colors.interactive.primary__hover_alt.rgba : ""};
|
|
172
|
+
`, xe = Q(function({
|
|
173
|
+
children: e,
|
|
174
|
+
variant: i,
|
|
175
|
+
selected: l,
|
|
176
|
+
onSelectedChange: a,
|
|
177
|
+
label: c,
|
|
178
|
+
helperText: m,
|
|
179
|
+
placeholder: y,
|
|
180
|
+
items: w,
|
|
181
|
+
ariaLabel: v,
|
|
182
|
+
disabledKeys: ne,
|
|
183
|
+
disabled: $,
|
|
184
|
+
readOnly: d,
|
|
185
|
+
getValueText: k,
|
|
186
|
+
onChange: p,
|
|
187
|
+
showClearButton: se,
|
|
188
|
+
...L
|
|
189
|
+
}, S) {
|
|
190
|
+
const [g, B] = u(), { density: I } = x(), T = X(() => l ? `select-option-${l}` : g ? `select-option-${g}` : "", [g, l]), H = Y(
|
|
191
|
+
(R) => {
|
|
192
|
+
let n = (R ?? "").toString().replace("select-option-", "");
|
|
193
|
+
n === "" && (n = null), a ? a(n) : p ? p({
|
|
194
|
+
target: { value: n },
|
|
195
|
+
currentTarget: { value: n }
|
|
196
|
+
}) : B(n);
|
|
197
|
+
},
|
|
198
|
+
[p, a]
|
|
199
|
+
), E = Z(), M = S ?? E, [j, z] = u(!1), [C, h] = u(!1), D = () => {
|
|
200
|
+
h(!0);
|
|
201
|
+
}, P = () => {
|
|
202
|
+
h(!1);
|
|
203
|
+
};
|
|
204
|
+
return /* @__PURE__ */ b(
|
|
205
|
+
s.Wrapper,
|
|
206
|
+
{
|
|
207
|
+
onSelectionChange: H,
|
|
208
|
+
selectedKey: T,
|
|
209
|
+
$variant: i,
|
|
210
|
+
autoComplete: "text",
|
|
211
|
+
placeholder: y ?? " ",
|
|
212
|
+
isOpen: d ? !1 : j,
|
|
213
|
+
onOpenChange: z,
|
|
214
|
+
isDisabled: $ ?? d,
|
|
215
|
+
"aria-label": v,
|
|
216
|
+
...L,
|
|
217
|
+
children: [
|
|
218
|
+
c && /* @__PURE__ */ t(s.Label, { elementType: "label", children: c }),
|
|
219
|
+
/* @__PURE__ */ b(
|
|
220
|
+
s.Trigger,
|
|
221
|
+
{
|
|
222
|
+
ref: M,
|
|
223
|
+
$density: I,
|
|
224
|
+
$variant: i,
|
|
225
|
+
$readonly: d ?? !1,
|
|
226
|
+
"data-readonly": d,
|
|
227
|
+
$hasLabel: !!c,
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ t(U, { children: k }),
|
|
230
|
+
!d && /* @__PURE__ */ t(
|
|
231
|
+
ae,
|
|
232
|
+
{
|
|
233
|
+
onMouseEnter: D,
|
|
234
|
+
onMouseLeave: P,
|
|
235
|
+
$isHover: C,
|
|
236
|
+
children: /* @__PURE__ */ t(
|
|
237
|
+
G,
|
|
238
|
+
{
|
|
239
|
+
size: 24,
|
|
240
|
+
data: J,
|
|
241
|
+
color: o.colors.interactive.primary__resting.rgba
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
),
|
|
249
|
+
/* @__PURE__ */ t(
|
|
250
|
+
s.Popover,
|
|
251
|
+
{
|
|
252
|
+
offset: 4,
|
|
253
|
+
UNSTABLE_portalContainer: document.querySelector("#roma-deal") ?? document.body,
|
|
254
|
+
children: /* @__PURE__ */ t(s.ListBox, { items: w, children: e })
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ t(_, { helperText: m })
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}), _e = ({
|
|
262
|
+
value: e,
|
|
263
|
+
children: i,
|
|
264
|
+
item: l,
|
|
265
|
+
...a
|
|
266
|
+
}) => {
|
|
267
|
+
const { density: c } = x();
|
|
268
|
+
return /* @__PURE__ */ t(
|
|
269
|
+
s.ListBoxItem,
|
|
270
|
+
{
|
|
271
|
+
$density: c,
|
|
272
|
+
id: `select-option-${e}`,
|
|
273
|
+
value: l,
|
|
274
|
+
isDisabled: a.disabled,
|
|
275
|
+
...a,
|
|
276
|
+
children: i
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
export {
|
|
281
|
+
_e as Option,
|
|
282
|
+
xe as Select,
|
|
283
|
+
s as Styled
|
|
284
|
+
};
|
package/switch.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),S=require("react-aria"),b=require("react"),d=require("@equinor/eds-tokens"),C=require("@equinor/eds-core-react");function k(e,t,i){let[o,u]=b.useState(e||t),f=b.useRef(e!==void 0),s=e!==void 0;b.useEffect(()=>{let l=f.current;l!==s&&process.env.NODE_ENV!=="production"&&console.warn(`WARN: A component changed from ${l?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}.`),f.current=s},[s]);let a=s?e:o,g=b.useCallback((l,...n)=>{let r=(h,...y)=>{i&&(Object.is(a,h)||i(h,...y)),s||(a=h)};typeof l=="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"),u((y,...p)=>{let x=l(s?a:y,...p);return r(x,...n),s?y:x})):(s||u(l),r(l,...n))},[s,a,i]);return[a,g]}function R(e={}){let{isReadOnly:t}=e,[i,o]=k(e.isSelected,e.defaultSelected||!1,e.onChange);function u(s){t||o(s)}function f(){t||o(!i)}return{isSelected:i,setSelected:u,toggle:f}}const _={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",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"};function m(e){const t={...e,isDisabled:e.isDisabled??e.disabled,isReadOnly:e.isReadOnly??e.readOnly,isSelected:e.isSelected??e.checked,defaultSelected:e.defaultSelected??e.defaultChecked},i=R(t),o=b.useRef(null),{inputProps:u}=S.useSwitch(t,i,o),{isFocusVisible:f,focusProps:s}=S.useFocusRing(),{isHovered:a,hoverProps:g}=S.useHover({isDisabled:!1}),{density:l}=C.useEds(),n=l==="compact",r=b.useMemo(()=>({ripple:d.tokens.colors.interactive.primary__hover_alt.rgba,background:i.isSelected?d.tokens.colors.interactive.primary__resting.hex:"rgba(220, 220, 220, 1)",circle:i.isSelected?d.tokens.colors.interactive.primary__hover_alt.hex:"rgba(111, 111, 111, 1)",icon:i.isSelected?d.tokens.colors.interactive.primary__resting.hex:"white",focus:d.tokens.colors.interactive.primary__resting.hex}),[i.isSelected]),h=n?32:48,y=n?4:12,p=n?0:8;return c.jsxs(C.Typography,{as:"label",variant:"text",group:"input",style:{display:"flex",alignItems:"center",color:t.isReadOnly||t.isDisabled?d.tokens.colors.text.static_icons__tertiary.rgba:d.tokens.colors.text.static_icons__default.rgba,cursor:t.isReadOnly||t.isDisabled?"not-allowed":"pointer"},children:[c.jsx(S.VisuallyHidden,{children:c.jsx("input",{...u,...s,ref:o})}),c.jsx("div",{style:{display:"inline",height:n?32:48},...g,children:c.jsxs("svg",{width:60,height:h,"aria-hidden":"true",style:{marginRight:4,opacity:t.isDisabled||t.isReadOnly?.4:1},children:[a&&!t.isDisabled&&!t.isReadOnly&&c.jsx("circle",{cx:i.isSelected?42:20,cy:16+p,r:n?16:20,fill:r.ripple}),c.jsx("rect",{x:8,y,width:46,height:24,rx:12,fill:r.background}),c.jsx("circle",{cx:i.isSelected?42:20,cy:16+p,r:9.5,fill:r.circle}),c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:i.isSelected?_.check:_.close,transform:`translate(${i.isSelected?32:14},${(i.isSelected?6:10)+p}) scale(1.2)`,fill:r.icon,style:{pointerEvents:"none"}}),f&&c.jsx("rect",{x:6,y:p,width:50,height:32,rx:12,fill:"none",strokeDasharray:2,stroke:r.focus,strokeWidth:2})]})}),t.children??t.label]})}exports.Switch=m;
|
package/switch.mjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsxs as S, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useSwitch as _, useFocusRing as x, useHover as R, VisuallyHidden as O } from "react-aria";
|
|
3
|
+
import { useState as k, useRef as C, useEffect as L, useCallback as v, useMemo as w } from "react";
|
|
4
|
+
import { tokens as a } from "@equinor/eds-tokens";
|
|
5
|
+
import { useEds as D, Typography as $ } from "@equinor/eds-core-react";
|
|
6
|
+
function V(e, t, i) {
|
|
7
|
+
let [o, f] = k(e || t), u = C(e !== void 0), l = e !== void 0;
|
|
8
|
+
L(() => {
|
|
9
|
+
let c = u.current;
|
|
10
|
+
c !== l && process.env.NODE_ENV !== "production" && console.warn(`WARN: A component changed from ${c ? "controlled" : "uncontrolled"} to ${l ? "controlled" : "uncontrolled"}.`), u.current = l;
|
|
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);
|
|
36
|
+
}
|
|
37
|
+
function u() {
|
|
38
|
+
t || o(!i);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
isSelected: i,
|
|
42
|
+
setSelected: f,
|
|
43
|
+
toggle: u
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const m = {
|
|
47
|
+
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
|
+
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
|
+
};
|
|
50
|
+
function W(e) {
|
|
51
|
+
const t = {
|
|
52
|
+
...e,
|
|
53
|
+
isDisabled: e.isDisabled ?? e.disabled,
|
|
54
|
+
isReadOnly: e.isReadOnly ?? e.readOnly,
|
|
55
|
+
isSelected: e.isSelected ?? e.checked,
|
|
56
|
+
defaultSelected: e.defaultSelected ?? e.defaultChecked
|
|
57
|
+
}, i = E(t), o = C(null), { inputProps: f } = _(t, i, o), { isFocusVisible: u, focusProps: l } = x(), { isHovered: d, hoverProps: b } = R({ isDisabled: !1 }), { density: c } = D(), s = c === "compact", n = w(() => ({
|
|
58
|
+
ripple: a.colors.interactive.primary__hover_alt.rgba,
|
|
59
|
+
background: i.isSelected ? a.colors.interactive.primary__resting.hex : "rgba(220, 220, 220, 1)",
|
|
60
|
+
circle: i.isSelected ? a.colors.interactive.primary__hover_alt.hex : "rgba(111, 111, 111, 1)",
|
|
61
|
+
icon: i.isSelected ? a.colors.interactive.primary__resting.hex : "white",
|
|
62
|
+
focus: a.colors.interactive.primary__resting.hex
|
|
63
|
+
}), [i.isSelected]), h = s ? 32 : 48, p = s ? 4 : 12, y = s ? 0 : 8;
|
|
64
|
+
return /* @__PURE__ */ S(
|
|
65
|
+
$,
|
|
66
|
+
{
|
|
67
|
+
as: "label",
|
|
68
|
+
variant: "text",
|
|
69
|
+
group: "input",
|
|
70
|
+
style: {
|
|
71
|
+
display: "flex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
color: t.isReadOnly || t.isDisabled ? a.colors.text.static_icons__tertiary.rgba : a.colors.text.static_icons__default.rgba,
|
|
74
|
+
cursor: t.isReadOnly || t.isDisabled ? "not-allowed" : "pointer"
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ r(O, { children: /* @__PURE__ */ r("input", { ...f, ...l, ref: o }) }),
|
|
78
|
+
/* @__PURE__ */ r(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
style: { display: "inline", height: s ? 32 : 48 },
|
|
82
|
+
...b,
|
|
83
|
+
children: /* @__PURE__ */ S(
|
|
84
|
+
"svg",
|
|
85
|
+
{
|
|
86
|
+
width: 60,
|
|
87
|
+
height: h,
|
|
88
|
+
"aria-hidden": "true",
|
|
89
|
+
style: {
|
|
90
|
+
marginRight: 4,
|
|
91
|
+
opacity: t.isDisabled || t.isReadOnly ? 0.4 : 1
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
d && !t.isDisabled && !t.isReadOnly && /* @__PURE__ */ r(
|
|
95
|
+
"circle",
|
|
96
|
+
{
|
|
97
|
+
cx: i.isSelected ? 42 : 20,
|
|
98
|
+
cy: 16 + y,
|
|
99
|
+
r: s ? 16 : 20,
|
|
100
|
+
fill: n.ripple
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ r(
|
|
104
|
+
"rect",
|
|
105
|
+
{
|
|
106
|
+
x: 8,
|
|
107
|
+
y: p,
|
|
108
|
+
width: 46,
|
|
109
|
+
height: 24,
|
|
110
|
+
rx: 12,
|
|
111
|
+
fill: n.background
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ r(
|
|
115
|
+
"circle",
|
|
116
|
+
{
|
|
117
|
+
cx: i.isSelected ? 42 : 20,
|
|
118
|
+
cy: 16 + y,
|
|
119
|
+
r: 9.5,
|
|
120
|
+
fill: n.circle
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ r(
|
|
124
|
+
"path",
|
|
125
|
+
{
|
|
126
|
+
fillRule: "evenodd",
|
|
127
|
+
clipRule: "evenodd",
|
|
128
|
+
d: i.isSelected ? m.check : m.close,
|
|
129
|
+
transform: `translate(${i.isSelected ? 32 : 14},${(i.isSelected ? 6 : 10) + y}) scale(1.2)`,
|
|
130
|
+
fill: n.icon,
|
|
131
|
+
style: { pointerEvents: "none" }
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
u && /* @__PURE__ */ r(
|
|
135
|
+
"rect",
|
|
136
|
+
{
|
|
137
|
+
x: 6,
|
|
138
|
+
y,
|
|
139
|
+
width: 50,
|
|
140
|
+
height: 32,
|
|
141
|
+
rx: 12,
|
|
142
|
+
fill: "none",
|
|
143
|
+
strokeDasharray: 2,
|
|
144
|
+
stroke: n.focus,
|
|
145
|
+
strokeWidth: 2
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
t.children ?? t.label
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
W as Switch
|
|
160
|
+
};
|