@pathscale/ui 0.0.82 → 0.0.84
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.
|
@@ -2,9 +2,7 @@ import { type JSX } from "solid-js";
|
|
|
2
2
|
import type { IComponentBaseProps } from "../types";
|
|
3
3
|
export type DropdownMenuProps = JSX.HTMLAttributes<HTMLUListElement> & IComponentBaseProps & {
|
|
4
4
|
id?: string;
|
|
5
|
-
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: JSX.CSSProperties;
|
|
5
|
+
hideOverflow?: boolean;
|
|
8
6
|
"aria-labelledby"?: string;
|
|
9
7
|
};
|
|
10
8
|
declare const DropdownMenu: (props: DropdownMenuProps) => JSX.Element;
|
|
@@ -2,7 +2,10 @@ import { type JSX, type ParentComponent } from "solid-js";
|
|
|
2
2
|
import { IComponentBaseProps } from "../types";
|
|
3
3
|
import ValidatedForm, { useFormValidation } from "./ValidatedForm";
|
|
4
4
|
export { type ValidatedFormProps } from "./ValidatedForm";
|
|
5
|
-
export type FormProps = Omit<JSX.HTMLAttributes<HTMLFormElement>, "ref"> & IComponentBaseProps
|
|
5
|
+
export type FormProps = Omit<JSX.HTMLAttributes<HTMLFormElement>, "ref"> & IComponentBaseProps & {
|
|
6
|
+
autoFocus?: boolean;
|
|
7
|
+
cycleOnEnter?: boolean;
|
|
8
|
+
};
|
|
6
9
|
export { useFormValidation };
|
|
7
10
|
declare const _default: ParentComponent<FormProps> & {
|
|
8
11
|
Label: ParentComponent<import("./Label").LabelProps>;
|
package/dist/index.js
CHANGED
|
@@ -6921,9 +6921,13 @@ const DropdownMenu = (props)=>{
|
|
|
6921
6921
|
"dataTheme",
|
|
6922
6922
|
"style",
|
|
6923
6923
|
"id",
|
|
6924
|
+
"hideOverflow",
|
|
6924
6925
|
"aria-labelledby"
|
|
6925
6926
|
]);
|
|
6926
|
-
const
|
|
6927
|
+
const hideOverflowMemo = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>local.hideOverflow ?? true);
|
|
6928
|
+
const classes = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>twMerge("dropdown-content menu p-2 shadow bg-base-100 overflow-y-auto flex-nowrap w-full rounded-box", dist_clsx({
|
|
6929
|
+
"max-h-50": hideOverflowMemo()
|
|
6930
|
+
}), local.class, local.className));
|
|
6927
6931
|
return (()=>{
|
|
6928
6932
|
var _el$ = DropdownMenu_tmpl$();
|
|
6929
6933
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.spread)(_el$, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(others, {
|
|
@@ -7436,16 +7440,61 @@ function ValidatedForm(props) {
|
|
|
7436
7440
|
const form_ValidatedForm = ValidatedForm;
|
|
7437
7441
|
var Form_tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<form role=form>");
|
|
7438
7442
|
const Form = (props)=>{
|
|
7439
|
-
const
|
|
7443
|
+
const merged = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.mergeProps)({
|
|
7444
|
+
autoFocus: true,
|
|
7445
|
+
cycleOnEnter: true
|
|
7446
|
+
}, props);
|
|
7447
|
+
const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(merged, [
|
|
7440
7448
|
"children",
|
|
7441
7449
|
"dataTheme",
|
|
7442
7450
|
"class",
|
|
7443
|
-
"className"
|
|
7451
|
+
"className",
|
|
7452
|
+
"autoFocus",
|
|
7453
|
+
"cycleOnEnter"
|
|
7444
7454
|
]);
|
|
7445
7455
|
const resolvedChildren = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.children)(()=>local.children);
|
|
7446
7456
|
const classes = ()=>twMerge("form-control", local.class, local.className);
|
|
7457
|
+
let formRef;
|
|
7458
|
+
const getFocusableElements = ()=>{
|
|
7459
|
+
if (!formRef) return [];
|
|
7460
|
+
return Array.from(formRef.querySelectorAll('input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled])'));
|
|
7461
|
+
};
|
|
7462
|
+
const handleKeyDown = (e)=>{
|
|
7463
|
+
if (!local.cycleOnEnter || "Enter" !== e.key) return;
|
|
7464
|
+
const focusableElements = getFocusableElements();
|
|
7465
|
+
const activeElement = document.activeElement;
|
|
7466
|
+
if (!formRef?.contains(activeElement)) return;
|
|
7467
|
+
const currentIndex = focusableElements.indexOf(activeElement);
|
|
7468
|
+
if (-1 === currentIndex) return;
|
|
7469
|
+
e.preventDefault();
|
|
7470
|
+
if (currentIndex === focusableElements.length - 1) formRef?.dispatchEvent(new Event("submit", {
|
|
7471
|
+
bubbles: true,
|
|
7472
|
+
cancelable: true
|
|
7473
|
+
}));
|
|
7474
|
+
else {
|
|
7475
|
+
const nextElement = focusableElements[currentIndex + 1];
|
|
7476
|
+
nextElement?.focus();
|
|
7477
|
+
}
|
|
7478
|
+
};
|
|
7479
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onMount)(()=>{
|
|
7480
|
+
if (local.autoFocus && formRef) {
|
|
7481
|
+
const focusableElements = getFocusableElements();
|
|
7482
|
+
if (focusableElements.length > 0) {
|
|
7483
|
+
const firstElement = focusableElements[0];
|
|
7484
|
+
firstElement.focus();
|
|
7485
|
+
}
|
|
7486
|
+
}
|
|
7487
|
+
if (local.cycleOnEnter && formRef) {
|
|
7488
|
+
formRef.addEventListener("keydown", handleKeyDown);
|
|
7489
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>{
|
|
7490
|
+
formRef?.removeEventListener("keydown", handleKeyDown);
|
|
7491
|
+
});
|
|
7492
|
+
}
|
|
7493
|
+
});
|
|
7447
7494
|
return (()=>{
|
|
7448
7495
|
var _el$ = Form_tmpl$();
|
|
7496
|
+
var _ref$ = formRef;
|
|
7497
|
+
"function" == typeof _ref$ ? (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.use)(_ref$, _el$) : formRef = _el$;
|
|
7449
7498
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.spread)(_el$, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.mergeProps)(others, {
|
|
7450
7499
|
get ["data-theme"] () {
|
|
7451
7500
|
return local.dataTheme;
|