@g4rcez/components 2.2.1 → 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.map +1 -1
- package/dist/components/floating/command-palette.jsx +5 -3
- 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 +3548 -3541
- 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>
|
|
@@ -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,I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,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,6 +66,7 @@ const findFirstClickable = (items) => {
|
|
|
66
66
|
};
|
|
67
67
|
export const CommandPalette = (props) => {
|
|
68
68
|
const id = useId();
|
|
69
|
+
const scrollContainerRef = useRef(null);
|
|
69
70
|
const [text, setText] = useState("");
|
|
70
71
|
const listRef = useRef([]);
|
|
71
72
|
const translations = useTranslations();
|
|
@@ -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))
|
|
@@ -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) {
|
|
@@ -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
|
});
|