@g4rcez/components 2.2.0 → 2.2.2
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/core/typography.jsx +1 -1
- package/dist/components/floating/command-palette.d.ts +1 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.jsx +17 -15
- package/dist/components/form/free-text.d.ts.map +1 -1
- package/dist/components/form/free-text.jsx +4 -4
- package/dist/components/form/input-field.d.ts +3 -2
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.jsx +40 -39
- package/dist/components/form/select.d.ts.map +1 -1
- package/dist/components/form/select.jsx +15 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4266 -4255
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +13 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/dom.d.ts +1 -0
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/dom.js +15 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ export const Description = (props) => (<p {...props} className={css("mb-kilo tex
|
|
|
5
5
|
export const Info = (props) => (<div className={css(`flex ${props.row ? "flex-row items-center" : "flex-col"} gap-1`, props.className)}>
|
|
6
6
|
<Fragment>
|
|
7
7
|
<span className="text-sm font-medium tracking-wide">{props.row ? `${props.label}:` : props.label}</span>
|
|
8
|
-
<span className={
|
|
8
|
+
<span className={css(props.disabled ? "text-disabled" : "", props.row ? "text-base w-fit" : "w-full text-lg")}>
|
|
9
9
|
{props.children}
|
|
10
10
|
</span>
|
|
11
11
|
</Fragment>
|
|
@@ -16,6 +16,7 @@ type CommandShortcutItem = CommandItem<"shortcut", {
|
|
|
16
16
|
shortcut?: string;
|
|
17
17
|
action: (args: {
|
|
18
18
|
text: string;
|
|
19
|
+
setText: (state: string) => void;
|
|
19
20
|
setOpen: (state: boolean) => void;
|
|
20
21
|
event: KeyboardEvent | React.MouseEvent | React.KeyboardEvent;
|
|
21
22
|
}) => void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../../../src/components/floating/command-palette.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAmE,MAAM,OAAO,CAAC;AAQxF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IACzD,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;CACrD,CAAC;AAEF,KAAK,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC,CAAC;AAEpD,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,EACV;IACE,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,IAAI,EAAE;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QAClC,KAAK,EAAE,aAAa,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC;KAC/D,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CACF,CAAC;AAEF,KAAK,gBAAgB,GAAG,WAAW,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,KAA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AAC;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,kBAAkB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC,CAAC;CACjF,CAAC;AAgCF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,sBAsLxD,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { useStableRef } from "../../hooks/use-stable-ref";
|
|
|
7
7
|
import { useTranslations } from "../../hooks/use-translations";
|
|
8
8
|
import { CombiKeys } from "../../lib/combi-keys";
|
|
9
9
|
import { Dict } from "../../lib/dict";
|
|
10
|
-
import { css, isReactFC } from "../../lib/dom";
|
|
10
|
+
import { css, isChildVisible, isReactFC } from "../../lib/dom";
|
|
11
11
|
import { fzf } from "../../lib/fzf";
|
|
12
12
|
import { Shortcut } from "../display/shortcut";
|
|
13
13
|
import { SkeletonCell } from "../display/skeleton";
|
|
@@ -66,10 +66,11 @@ const findFirstClickable = (items) => {
|
|
|
66
66
|
};
|
|
67
67
|
export const CommandPalette = (props) => {
|
|
68
68
|
const id = useId();
|
|
69
|
-
const
|
|
69
|
+
const scrollContainerRef = useRef(null);
|
|
70
|
+
const [text, setText] = useState("");
|
|
70
71
|
const listRef = useRef([]);
|
|
71
72
|
const translations = useTranslations();
|
|
72
|
-
const valueRef = useStableRef(
|
|
73
|
+
const valueRef = useStableRef(text);
|
|
73
74
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
74
75
|
const bindKey = props.bind ?? "Mod + k";
|
|
75
76
|
const root = useFloating({
|
|
@@ -79,7 +80,7 @@ export const CommandPalette = (props) => {
|
|
|
79
80
|
onOpenChange: props.onChangeVisibility,
|
|
80
81
|
});
|
|
81
82
|
const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
|
|
82
|
-
const fuzzy = getFuzzyData(commands,
|
|
83
|
+
const fuzzy = getFuzzyData(commands, text);
|
|
83
84
|
const listNav = useListNavigation(root.context, {
|
|
84
85
|
listRef,
|
|
85
86
|
loop: true,
|
|
@@ -99,7 +100,8 @@ export const CommandPalette = (props) => {
|
|
|
99
100
|
},
|
|
100
101
|
onNavigate: (n) => {
|
|
101
102
|
if (Is.number(n)) {
|
|
102
|
-
listRef.current[n]
|
|
103
|
+
if (!isChildVisible(scrollContainerRef.current, listRef.current[n]))
|
|
104
|
+
listRef.current[n]?.scrollIntoView({ block: "start", inline: "start" });
|
|
103
105
|
}
|
|
104
106
|
setActiveIndex((prev) => {
|
|
105
107
|
if (Is.number(n))
|
|
@@ -109,7 +111,7 @@ export const CommandPalette = (props) => {
|
|
|
109
111
|
}
|
|
110
112
|
});
|
|
111
113
|
const { getItemProps, getReferenceProps, getFloatingProps } = useInteractions([listNav]);
|
|
112
|
-
const displayItems =
|
|
114
|
+
const displayItems = text === ""
|
|
113
115
|
? commands
|
|
114
116
|
: [
|
|
115
117
|
{
|
|
@@ -128,6 +130,7 @@ export const CommandPalette = (props) => {
|
|
|
128
130
|
if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
|
|
129
131
|
combi.add(cmd.shortcut, (event) => cmd.action({
|
|
130
132
|
event,
|
|
133
|
+
setText,
|
|
131
134
|
text: valueRef.current,
|
|
132
135
|
setOpen: props.onChangeVisibility,
|
|
133
136
|
}));
|
|
@@ -139,8 +142,7 @@ export const CommandPalette = (props) => {
|
|
|
139
142
|
<Modal {...getFloatingProps()} animated={false} closable={false} open={props.open} overlayClickClose ariaTitle="Command palette" bodyClassName="px-0 py-0 pt-0" data-component="command-palette" onChange={props.onChangeVisibility} className="container relative py-0 md:max-w-screen-sm lg:max-w-screen-md overflow-clip">
|
|
140
143
|
<header className="flex sticky top-0 items-center w-full h-12 border-b overflow-clip isolate z-floating border-floating-border bg-floating-background">
|
|
141
144
|
<div className="flex justify-center items-center size-10">
|
|
142
|
-
{props.Icon ? <Icon Default={FilterIcon} text={
|
|
143
|
-
|
|
145
|
+
{props.Icon ? <Icon Default={FilterIcon} text={text} size={16}/> : <FilterIcon size={16}/>}
|
|
144
146
|
</div>
|
|
145
147
|
<input {...getReferenceProps({
|
|
146
148
|
ref: root.refs.setReference,
|
|
@@ -150,16 +152,16 @@ export const CommandPalette = (props) => {
|
|
|
150
152
|
if (key === "Enter") {
|
|
151
153
|
if (item) {
|
|
152
154
|
if (item.type === "shortcut")
|
|
153
|
-
item.action({ event: e, text:
|
|
155
|
+
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
154
156
|
}
|
|
155
157
|
else {
|
|
156
158
|
const item = findFirstClickable(fuzzy);
|
|
157
159
|
if (item?.type === "shortcut")
|
|
158
|
-
item.action({ event: e, text:
|
|
160
|
+
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
|
-
})} autoFocus value={
|
|
164
|
+
})} autoFocus value={text} data-combikeysbypass="true" placeholder="Search for..." onChange={(e) => setText(e.target.value)} className="items-center py-2 px-2 pb-2 w-full h-12 text-lg text-left bg-transparent outline-none"/>
|
|
163
165
|
</header>
|
|
164
166
|
{props.loading ? (<ul role="listbox" data-component="command-palette-list" className="flex overflow-y-auto flex-col gap-1 px-2 my-2 w-full max-h-96 origin-[top_center]">
|
|
165
167
|
<div className="px-2 pt-2 pb-1 h-10">{translations.commandPaletteLoading}</div>
|
|
@@ -167,7 +169,7 @@ export const CommandPalette = (props) => {
|
|
|
167
169
|
{SkeletonCell}
|
|
168
170
|
</li>))}
|
|
169
171
|
</ul>) : (<div className="flex flex-row flex-nowrap min-w-full" data-component="command-palette-container">
|
|
170
|
-
<ul role="listbox" data-component="command-palette-list" className="flex overflow-y-auto flex-col gap-1 px-2 my-2 w-full max-h-96 h-fit origin-[top_center]">
|
|
172
|
+
<ul role="listbox" ref={scrollContainerRef} data-component="command-palette-list" className="flex overflow-y-auto flex-col gap-1 px-2 my-2 w-full max-h-96 h-fit origin-[top_center]">
|
|
171
173
|
{displayItems.map((item, index) => (<Item {...getItemProps({
|
|
172
174
|
onMouseEnter: () => setActiveIndex(index),
|
|
173
175
|
ref(node) {
|
|
@@ -177,14 +179,14 @@ export const CommandPalette = (props) => {
|
|
|
177
179
|
e.preventDefault();
|
|
178
180
|
props.onChangeVisibility(false);
|
|
179
181
|
if (item.type === "shortcut")
|
|
180
|
-
item.action({ event: e, text:
|
|
182
|
+
item.action({ event: e, text: text, setOpen: props.onChangeVisibility, setText });
|
|
181
183
|
},
|
|
182
|
-
})} item={item} text={
|
|
184
|
+
})} item={item} text={text} active={activeIndex === index} key={`${id}-${item.type}-${index}`}/>))}
|
|
183
185
|
{displayItems.length === 1 ? (<div className={css("flex items-center justify-between rounded-lg p-2 text-secondary")}>
|
|
184
186
|
{translations.commandPaletteEmpty ?? props.emptyMessage}
|
|
185
187
|
</div>) : null}
|
|
186
188
|
</ul>
|
|
187
|
-
{props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={
|
|
189
|
+
{props.Preview && Is.number(activeIndex) ? <props.Preview command={displayItems[activeIndex]} text={text}/> : null}
|
|
188
190
|
</div>)}
|
|
189
191
|
{props.footer ? <footer className="flex items-center p-2 h-8 rounded-b-lg border-t border-floating-border">{props.footer}</footer> : null}
|
|
190
192
|
</Modal>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"free-text.d.ts","sourceRoot":"","sources":["../../../src/components/form/free-text.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,KAAK,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,UAAU,SAAS,GAAG,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"free-text.d.ts","sourceRoot":"","sources":["../../../src/components/form/free-text.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,KAAK,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,UAAU,SAAS,GAAG,IAAI,QAAQ,CACjF,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EAChF,UAAU,CACX,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,CAAC,IAAI,SAAS,gBAAgB,GAAG,mBAAmB,EAAE,KAAK,SAAS,GAAG,EACtI,SAAS,OAAO,GAAG,UAAU,GAAG,OAAO,SAAS,EAChD,aAAa,OAAO,GAAG,UAAU,EACjC,cAAc,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,EACrC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,IAAI,4CAyGpC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef, useEffect, useRef } from "react";
|
|
|
3
3
|
import { css, initializeInputDataset, mergeRefs } from "../../lib/dom";
|
|
4
4
|
import { InputField } from "./input-field";
|
|
5
5
|
export const createFreeText = (Element, elementName, defaultProps, register) => {
|
|
6
|
-
const FreeText = forwardRef(({ info, left, next, error, right, container, rightLabel, interactive, optionalText, type = "text", labelClassName, feedback = null, hideLeft = false, loading, ...props }, ref) => {
|
|
6
|
+
const FreeText = forwardRef(({ info, left, next, error, right, container, rightLabel, interactive, optionalText, type = "text", labelClassName, feedback = null, hideLeft = false, loading, hiddenLabel, ...props }, ref) => {
|
|
7
7
|
const Render = Element;
|
|
8
8
|
const id = props.id ?? props.name;
|
|
9
9
|
const inputRef = useRef(null);
|
|
@@ -33,9 +33,9 @@ export const createFreeText = (Element, elementName, defaultProps, register) =>
|
|
|
33
33
|
input.removeEventListener("keydown", goNextInputImpl);
|
|
34
34
|
};
|
|
35
35
|
}, []);
|
|
36
|
-
return (<InputField {...defaultProps} info={info} left={left} error={error} right={right}
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
return (<InputField {...defaultProps} info={info} left={left} error={error} right={right} form={props.form} loading={loading} name={props.name} feedback={feedback} hideLeft={hideLeft} title={props.title} rightLabel={rightLabel} disabled={props.disabled} hiddenLabel={hiddenLabel} interactive={interactive} required={props.required} componentName={elementName} id={props.name || props.id} optionalText={optionalText} labelClassName={labelClassName} placeholder={props.placeholder} container={css(container, defaultProps.container)}>
|
|
37
|
+
<Render {...defaultProps} {...props} id={id} name={id} type={type} data-next={next} aria-busy={props.disabled} aria-disabled={props.disabled} aria-readonly={props.readOnly} ref={mergeRefs(ref, inputRef)} className={css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-base text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", "disabled:cursor-not-allowed disabled:text-disabled", props.className)}/>
|
|
38
|
+
</InputField>);
|
|
39
39
|
});
|
|
40
40
|
return FreeText;
|
|
41
41
|
};
|
|
@@ -5,10 +5,11 @@ export type FeedbackProps = React.PropsWithChildren<Partial<{
|
|
|
5
5
|
id: string;
|
|
6
6
|
info: Label;
|
|
7
7
|
title: Label;
|
|
8
|
-
hideLeft
|
|
9
|
-
className
|
|
8
|
+
hideLeft: boolean;
|
|
9
|
+
className: string;
|
|
10
10
|
placeholder: string;
|
|
11
11
|
reportStatus: boolean;
|
|
12
|
+
hiddenLabel: boolean;
|
|
12
13
|
}>>;
|
|
13
14
|
export declare const InputFeedback: ({ reportStatus, id, hideLeft, className, info, children, title }: FeedbackProps) => React.JSX.Element;
|
|
14
15
|
export type InputFieldProps<T extends "input" | "select" | "textarea"> = PolymorphicProps<Partial<Override<FeedbackProps, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAwB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI5E,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAwB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI5E,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CACjD,OAAO,CAAC;IACN,EAAE,EAAE,MAA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ating/tooltip";
|
|
8
8
|
export const InputFeedback = ({ reportStatus, id, hideLeft = false, className, info, children, title }) => (<span className={css("w-full justify-between", hideLeft && children === null ? "hidden" : "flex", className)}>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export const InputField = forwardRef(({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName = "", name, title, componentName, placeholder, hideLeft = false, required, disabled, reportStatus, }, ref) => {
|
|
9
|
+
{hideLeft ? null : (<span className="flex gap-1 items-center transition-colors group-disabled:text-disabled group-error:text-danger group-hover:text-primary group-focus-within:text-primary">
|
|
10
|
+
{title}
|
|
11
|
+
{reportStatus || info ? (<span className="flex gap-1 justify-center items-center">
|
|
12
|
+
{info ? (<Tooltip as="button" type="button" aria-label={typeof info === "string" ? info : undefined} aria-describedby={typeof info === "string" ? undefined : id ? `tooltip-info-content-${id}` : undefined} title={<span className="cursor-help">
|
|
13
|
+
<InfoIcon className="aspect-square size-3" aria-hidden="true" size={16} strokeWidth={1} absoluteStrokeWidth/>
|
|
14
|
+
</span>}>
|
|
15
|
+
<div id={id ? `tooltip-info-content-${id}` : undefined} className="w-full break-words max-w-48 whitespace-break-spaces">{info}</div>
|
|
16
|
+
</Tooltip>) : null}
|
|
17
|
+
{reportStatus ? (<span className="flex items-center h-3 min-w-6">
|
|
18
|
+
<CheckCircle className="hidden opacity-0 transition-opacity aspect-square size-3 group-assert:block group-assert:text-success group-assert:opacity-100" aria-hidden="true" size={16} strokeWidth={1} absoluteStrokeWidth/>
|
|
19
|
+
<XCircle className="hidden opacity-0 transition-opacity aspect-square size-3 group-error:block group-error:opacity-100" aria-hidden="true" size={16} strokeWidth={1} absoluteStrokeWidth/>
|
|
20
|
+
</span>) : null}
|
|
21
|
+
</span>) : null}
|
|
22
|
+
</span>)}
|
|
23
|
+
{children}
|
|
24
|
+
</span>);
|
|
25
|
+
export const InputField = forwardRef(({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName = "", name, title, componentName, placeholder, hideLeft = false, required, disabled, reportStatus, hiddenLabel }, ref) => {
|
|
26
26
|
const tweaks = useTweaks();
|
|
27
27
|
const reportStatusDefault = reportStatus !== undefined ? reportStatus : tweaks.input.iconFeedback;
|
|
28
28
|
const ID = id ?? name;
|
|
29
29
|
const translation = useTranslations();
|
|
30
30
|
const optionalText = _optionalText ?? translation.inputOptionalLabel;
|
|
31
31
|
return (<fieldset ref={ref} form={form} disabled={disabled} data-error={!!error} aria-disabled={disabled} data-component={componentName} data-interactive={!!interactive} className={css("group flex min-h-0 max-w-full min-w-0 flex-col items-start", container)}>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
<label form={form} htmlFor={ID} className="inline-flex relative flex-row flex-wrap gap-1 justify-between w-full max-w-full text-sm transition-colors cursor-text empty:hidden text-field-label group-disabled:cursor-not-allowed group-error:text-danger">
|
|
33
|
+
{hiddenLabel ? null
|
|
34
|
+
: <InputFeedback info={info} hideLeft={hideLeft} reportStatus={reportStatusDefault} title={title} placeholder={placeholder}>
|
|
35
|
+
{optionalText || rightLabel ? (<Fragment>
|
|
36
|
+
{!required ? (<span aria-disabled={disabled} className="text-opacity-70 transition-colors aria-disabled:text-disabled group-hover:text-primary group-focus-within:text-primary">
|
|
37
|
+
{optionalText}
|
|
38
|
+
</span>) : null}
|
|
39
|
+
{rightLabel ? <Fragment>{rightLabel}</Fragment> : null}
|
|
40
|
+
</Fragment>) : null}
|
|
41
|
+
</InputFeedback>}
|
|
42
|
+
<div className={`group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${labelClassName}`}>
|
|
43
|
+
{left ? <span className="flex flex-nowrap gap-1 pl-2 whitespace-nowrap">{left}</span> : null}
|
|
44
|
+
{children}
|
|
45
|
+
{right ? <span className="flex flex-nowrap gap-2 pr-2 whitespace-nowrap">{right}</span> : null}
|
|
46
|
+
</div>
|
|
47
|
+
</label>
|
|
48
|
+
<p className="mt-input-gap hidden whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:flex group-error:flex group-error:text-danger">
|
|
49
|
+
{error}
|
|
50
|
+
</p>
|
|
51
|
+
<p className="mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden">
|
|
52
|
+
{feedback}
|
|
53
|
+
</p>
|
|
54
|
+
</fieldset>);
|
|
54
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/components/form/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/components/form/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,QAAQ,CAChC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC9B;IACE,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAChC,eAAe,CAAC,QAAQ,CAAC,EACzB;IACE,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CACF,CAAC;AAEF,eAAO,MAAM,MAAM,oGA2GlB,CAAC"}
|
|
@@ -4,7 +4,7 @@ import React, { forwardRef, useEffect, useImperativeHandle, useRef } from "react
|
|
|
4
4
|
import { useTranslations } from "../../hooks/use-translations";
|
|
5
5
|
import { css, initializeInputDataset, mergeRefs } from "../../lib/dom";
|
|
6
6
|
import { InputField } from "./input-field";
|
|
7
|
-
export const Select = forwardRef(({ required = true, options, info, selectContainer = "", feedback = null, labelClassName, interactive, rightLabel, loading, optionalText, container, hideLeft = false, right, left, error, ...props }, ref) => {
|
|
7
|
+
export const Select = forwardRef(({ required = true, options, info, selectContainer = "", feedback = null, labelClassName, interactive, rightLabel, hiddenLabel, loading, optionalText, container, hideLeft = false, right, left, error, ...props }, ref) => {
|
|
8
8
|
const translation = useTranslations();
|
|
9
9
|
const inputRef = useRef(null);
|
|
10
10
|
const id = props.id ?? props.name;
|
|
@@ -25,18 +25,18 @@ export const Select = forwardRef(({ required = true, options, info, selectContai
|
|
|
25
25
|
};
|
|
26
26
|
}, []);
|
|
27
27
|
const onClickLabel = () => inputRef.current?.focus();
|
|
28
|
-
return (<InputField info={info} left={left} error={error} form={props.form} loading={loading} name={props.name} feedback={feedback} hideLeft={hideLeft} required={required} title={props.title} container={container} componentName="select" rightLabel={rightLabel} interactive={interactive} id={props.name || props.id} optionalText={optionalText} labelClassName={labelClassName} placeholder={props.placeholder} right={<label htmlFor={id}>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
return (<InputField info={info} left={left} error={error} form={props.form} loading={loading} name={props.name} feedback={feedback} hideLeft={hideLeft} required={required} title={props.title} container={container} componentName="select" rightLabel={rightLabel} hiddenLabel={hiddenLabel} interactive={interactive} id={props.name || props.id} optionalText={optionalText} labelClassName={labelClassName} placeholder={props.placeholder} right={<label htmlFor={id}>
|
|
29
|
+
{right}
|
|
30
|
+
<button onClick={onClickLabel} type="button" className="mt-2 transition-colors hover:text-primary">
|
|
31
|
+
<ChevronDownIcon size={20}/>
|
|
32
|
+
<span className="sr-only">{translation.inputCaretDown}</span>
|
|
33
|
+
</button>
|
|
34
|
+
</label>}>
|
|
35
|
+
<select {...props} id={id} name={id} required={required} ref={mergeRefs(ref, inputRef)} data-selected={!!props.value || false} title={typeof props.title === "string" ? props.title : undefined} className={css("input select group text-base h-10 w-full flex-1 appearance-none rounded-md", "bg-transparent px-2 py-1 text-foreground placeholder-input-placeholder", "outline-none transition-colors group-error:text-danger group-error:placeholder-input-mask-error", "data-[selected=false]:text-input-placeholder", props.className)}>
|
|
36
|
+
<option value="" disabled hidden>
|
|
37
|
+
{props.placeholder}
|
|
38
|
+
</option>
|
|
39
|
+
{options.map((option) => (<option {...option} value={option.value} children={option.label ?? option.value} key={`${id}-select-option-${option.value}`}/>))}
|
|
40
|
+
</select>
|
|
41
|
+
</InputField>);
|
|
42
42
|
});
|