@pathscale/ui 3.0.0 → 3.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/dist/components/auth-field-group/AuthFieldGroup.css +11 -3
- package/dist/components/button/Button.css +4 -4
- package/dist/components/card/Card.generated.d.ts +21 -2
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.generated.d.ts +23 -2
- package/dist/components/checkbox/Checkbox.generated.js +14 -6
- package/dist/components/connection-settings/ConnectionSettings.css +76 -0
- package/dist/components/connection-settings/ConnectionSettings.generated.d.ts +45 -0
- package/dist/components/connection-settings/ConnectionSettings.generated.js +300 -0
- package/dist/components/connection-settings/ConnectionSettings.recipe.d.ts +54 -0
- package/dist/components/connection-settings/ConnectionSettings.recipe.js +111 -0
- package/dist/components/connection-settings/index.d.ts +2 -0
- package/dist/components/connection-settings/index.js +1 -0
- package/dist/components/dialog/Dialog.generated.js +17 -79
- package/dist/components/drawer/Drawer.a11y.d.ts +1 -3
- package/dist/components/drawer/Drawer.a11y.js +2 -30
- package/dist/components/drawer/Drawer.generated.js +17 -40
- package/dist/components/grid/Grid.generated.js +3 -3
- package/dist/components/input/Input.css +5 -3
- package/dist/components/input/Input.generated.js +6 -3
- package/dist/components/password-field/PasswordField.generated.d.ts +9 -1
- package/dist/components/password-field/PasswordField.generated.js +2 -2
- package/dist/components/password-field/PasswordField.interactions.d.ts +2 -2
- package/dist/components/password-field/PasswordField.interactions.js +2 -2
- package/dist/components/popover/Popover.generated.js +14 -11
- package/dist/components/radio/Radio.generated.d.ts +26 -2
- package/dist/components/radio/Radio.generated.js +9 -5
- package/dist/components/select/Select.generated.js +5 -0
- package/dist/components/slider/Slider.generated.d.ts +14 -1
- package/dist/components/slider/Slider.generated.js +3 -2
- package/dist/components/switch/Switch.css +0 -3
- package/dist/components/switch/Switch.generated.d.ts +23 -2
- package/dist/components/switch/Switch.generated.js +21 -44
- package/dist/components/switch/Switch.recipe.d.ts +61 -38
- package/dist/components/switch/Switch.recipe.js +88 -68
- package/dist/components/text/Text.generated.js +2 -6
- package/dist/components/text/Text.recipe.d.ts +17 -5
- package/dist/components/text/Text.recipe.js +7 -13
- package/dist/hooks/connection/createConnectionSettings.d.ts +128 -0
- package/dist/hooks/connection/createConnectionSettings.js +211 -0
- package/dist/hooks/connection/index.d.ts +2 -0
- package/dist/hooks/connection/index.js +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -0
- package/dist/layouts.manifest.json +1 -1
- package/dist/lib/focus.d.ts +31 -0
- package/dist/lib/focus.js +39 -0
- package/dist/lib/overlay.d.ts +94 -0
- package/dist/lib/overlay.js +72 -0
- package/dist/purge-manifest.json +14427 -15269
- package/dist/styles/base/index.css +42 -0
- package/package.json +3 -3
|
@@ -5,15 +5,23 @@
|
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
/*
|
|
9
|
+
* The same three gaps `Flex` names.
|
|
10
|
+
*
|
|
11
|
+
* `md` and `lg` already matched `gap-4` and `gap-6`; `sm` was 0.75rem where
|
|
12
|
+
* Flex's is 0.5rem. One name meaning two spacings is the kind of thing an
|
|
13
|
+
* application fixes with a corrective class once per form, forever -- and it
|
|
14
|
+
* is the same defect `--control-h-*` was added for, one axis over.
|
|
15
|
+
*/
|
|
8
16
|
.auth-field-group--sm {
|
|
9
|
-
gap:
|
|
17
|
+
gap: var(--gap-sm);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
.auth-field-group--md {
|
|
13
|
-
gap:
|
|
21
|
+
gap: var(--gap-md);
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
.auth-field-group--lg {
|
|
17
|
-
gap:
|
|
25
|
+
gap: var(--gap-lg);
|
|
18
26
|
}
|
|
19
27
|
}
|
|
@@ -225,20 +225,20 @@
|
|
|
225
225
|
* Size
|
|
226
226
|
* --------------------------------------------------------------------- */
|
|
227
227
|
.button--xs {
|
|
228
|
-
height:
|
|
228
|
+
height: var(--control-h-xs);
|
|
229
229
|
padding-inline: 0.5rem;
|
|
230
230
|
font-size: 0.75rem;
|
|
231
231
|
}
|
|
232
232
|
.button--sm {
|
|
233
|
-
height:
|
|
233
|
+
height: var(--control-h-sm);
|
|
234
234
|
padding-inline: 0.75rem;
|
|
235
235
|
}
|
|
236
236
|
.button--md {
|
|
237
|
-
height:
|
|
237
|
+
height: var(--control-h-md);
|
|
238
238
|
padding-inline: 1rem;
|
|
239
239
|
}
|
|
240
240
|
.button--lg {
|
|
241
|
-
height:
|
|
241
|
+
height: var(--control-h-lg);
|
|
242
242
|
padding-inline: 1.125rem;
|
|
243
243
|
font-size: 1rem;
|
|
244
244
|
}
|
|
@@ -2,7 +2,7 @@ import type { Component as __LayoutComponent } from "solid-js";
|
|
|
2
2
|
import "../_shared/material.css";
|
|
3
3
|
import type { JSX } from "@solidjs/web";
|
|
4
4
|
import "./Card.css";
|
|
5
|
-
import type { Flavor, Material, Radius, Space,
|
|
5
|
+
import type { Flavor, Material, Radius, Space, UIBaseProps, Variant } from "../vocabulary";
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Use `Material` from the shared vocabulary. Kept as an alias
|
|
8
8
|
* because it is exported publicly and removing it would break call sites; it
|
|
@@ -10,12 +10,31 @@ import type { Flavor, Material, Radius, Space, State, UIBaseProps, Variant } fro
|
|
|
10
10
|
*/
|
|
11
11
|
export type CardMaterial = Material;
|
|
12
12
|
export type CardElevation = "none" | "sm" | "md" | "lg";
|
|
13
|
+
/**
|
|
14
|
+
* The states this card actually renders.
|
|
15
|
+
*
|
|
16
|
+
* Not the shared `State`, which is what the prop was typed as. That union is
|
|
17
|
+
* `default | loading | error | invalid | disabled | hidden` and this recipe
|
|
18
|
+
* implements `info | success | warning | danger`: the two have **no member in
|
|
19
|
+
* common**. So every value the type permitted resolved to no class, and every
|
|
20
|
+
* value the recipe implements was a type error.
|
|
21
|
+
*
|
|
22
|
+
* A prop that accepts only values it ignores is worse than one that does not
|
|
23
|
+
* exist, because it reads as configured. Narrowed to what is implemented;
|
|
24
|
+
* `state="disabled"` and friends stop type-checking, and they never did
|
|
25
|
+
* anything, so nothing that worked stops working.
|
|
26
|
+
*
|
|
27
|
+
* A card is not a form control, which is why the shared vocabulary does not
|
|
28
|
+
* fit: it has no validity and nothing to disable. Behaviour lives on
|
|
29
|
+
* `isInteractive`.
|
|
30
|
+
*/
|
|
31
|
+
export type CardState = "info" | "success" | "warning" | "danger";
|
|
13
32
|
export type CardProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, "children"> & UIBaseProps & {
|
|
14
33
|
variant?: Variant;
|
|
15
34
|
material?: Material;
|
|
16
35
|
elevation?: CardElevation;
|
|
17
36
|
flavor?: Flavor;
|
|
18
|
-
state?:
|
|
37
|
+
state?: CardState;
|
|
19
38
|
padding?: Space;
|
|
20
39
|
radius?: Radius;
|
|
21
40
|
/** Replaces isHoverable and isPressable, which had one call site each across 330. */
|
|
@@ -11,6 +11,6 @@ declare const Card: import("solid-js").Component<import("./Card.generated").Card
|
|
|
11
11
|
Content: import("solid-js").Component<import("./Card.generated").CardSectionProps>;
|
|
12
12
|
Footer: import("solid-js").Component<import("./Card.generated").CardSectionProps>;
|
|
13
13
|
};
|
|
14
|
-
export type { CardElevation, CardMaterial, CardProps, CardSectionProps, } from "./Card.generated";
|
|
14
|
+
export type { CardElevation, CardMaterial, CardState, CardProps, CardSectionProps, } from "./Card.generated";
|
|
15
15
|
export { card, cardBody, cardFooter, cardHeader } from "./Card.recipe";
|
|
16
16
|
export { Card as default, Card, CardBodyLayout as CardBody, CardFooterLayout as CardFooter, CardHeaderLayout as CardHeader, };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Component as __LayoutComponent } from "solid-js";
|
|
2
2
|
import "./Checkbox.css";
|
|
3
3
|
import type { JSX } from "@solidjs/web";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Issue, State, UIBaseProps } from "../vocabulary";
|
|
5
5
|
export type CheckboxVariant = "primary" | "secondary";
|
|
6
|
-
export type CheckboxProps = Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "type" | "children"> & UIBaseProps & {
|
|
6
|
+
export type CheckboxProps = Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "type" | "children" | "onChange"> & UIBaseProps & {
|
|
7
7
|
defaultChecked?: boolean;
|
|
8
8
|
children?: JSX.Element;
|
|
9
9
|
description?: JSX.Element;
|
|
@@ -12,6 +12,27 @@ export type CheckboxProps = Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "typ
|
|
|
12
12
|
isIndeterminate?: boolean;
|
|
13
13
|
indeterminate?: boolean;
|
|
14
14
|
variant?: CheckboxVariant;
|
|
15
|
+
/**
|
|
16
|
+
* The new checked state.
|
|
17
|
+
*
|
|
18
|
+
* **Breaking in 3.1.** This was the input's native `onChange`, handing you
|
|
19
|
+
* an `Event`, while `Slider`, `RadioGroup` and `CheckboxGroup` handed you a
|
|
20
|
+
* value under the same name. Every control now reports its value here.
|
|
21
|
+
*
|
|
22
|
+
* Fires for a checkbox inside a `CheckboxGroup` too, reporting this box's
|
|
23
|
+
* own state; the group separately reports the whole selection through its
|
|
24
|
+
* own `onChange`.
|
|
25
|
+
*
|
|
26
|
+
* The native handler is {@link onNativeChange}.
|
|
27
|
+
*/
|
|
28
|
+
onChange?: (checked: boolean) => void;
|
|
29
|
+
/**
|
|
30
|
+
* The underlying `change` event, before the toggle is applied.
|
|
31
|
+
*
|
|
32
|
+
* `preventDefault()` here leaves the box as it was, suppresses
|
|
33
|
+
* {@link onChange}, and does not notify an enclosing group.
|
|
34
|
+
*/
|
|
35
|
+
onNativeChange?: JSX.EventHandlerUnion<HTMLInputElement, Event>;
|
|
15
36
|
};
|
|
16
37
|
declare const Checkbox: __LayoutComponent<CheckboxProps>;
|
|
17
38
|
export default Checkbox;
|
|
@@ -4,8 +4,8 @@ import "./Checkbox.css";
|
|
|
4
4
|
import { Show, createSignal, createTrackedEffect, omit, useContext } from "solid-js";
|
|
5
5
|
import { twMerge } from "../../lib/twMerge.js";
|
|
6
6
|
import { CheckboxGroupContext } from "../checkbox-group/context.js";
|
|
7
|
-
import { CLASSES, componentRecipe } from "./Checkbox.recipe.js";
|
|
8
7
|
import { resolveState } from "../vocabulary.js";
|
|
8
|
+
import { CLASSES, componentRecipe } from "./Checkbox.recipe.js";
|
|
9
9
|
var _tmpl$ = /*#__PURE__*/ template('<svg aria-hidden=true data-slot=checkbox-default-indicator--indeterminate fill=none role=presentation stroke=currentColor stroke-linecap=round stroke-width=3 viewBox="0 0 24 24"><line x1=21 x2=3 y1=12 y2=12>'), _tmpl$2 = /*#__PURE__*/ template("<span data-slot=label>"), _tmpl$3 = /*#__PURE__*/ template("<span>"), _tmpl$4 = /*#__PURE__*/ template("<span><!><!>"), _tmpl$5 = /*#__PURE__*/ template("<label><input><span><span>"), _tmpl$6 = /*#__PURE__*/ template('<svg aria-hidden=true data-slot=checkbox-default-indicator--checkmark fill=none role=presentation stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 viewBox="0 0 17 18"><polyline points="1 9 7 14 15 4">');
|
|
10
10
|
const invokeEventHandler = (handler, event)=>{
|
|
11
11
|
if ("function" == typeof handler) return void handler(event);
|
|
@@ -14,7 +14,7 @@ const invokeEventHandler = (handler, event)=>{
|
|
|
14
14
|
const __solidLayoutCheckbox = (_stable, p)=>{
|
|
15
15
|
let inputRef;
|
|
16
16
|
const group = useContext(CheckboxGroupContext);
|
|
17
|
-
const others = omit(p, "class", "children", "description", "state", "issues", "isIndeterminate", "indeterminate", "variant", "checked", "defaultChecked", "value", "name", "disabled", "onChange", "dataTheme", "aria-invalid");
|
|
17
|
+
const others = omit(p, "class", "children", "description", "state", "issues", "isIndeterminate", "indeterminate", "variant", "checked", "defaultChecked", "value", "name", "disabled", "onChange", "onNativeChange", "dataTheme", "aria-invalid");
|
|
18
18
|
const [internalSelected, setInternalSelected] = createSignal(Boolean(p.defaultChecked));
|
|
19
19
|
const isControlled = ()=>void 0 !== p.checked;
|
|
20
20
|
const optionValue = ()=>null != p.value ? String(p.value) : void 0;
|
|
@@ -31,11 +31,17 @@ const __solidLayoutCheckbox = (_stable, p)=>{
|
|
|
31
31
|
inputRef.indeterminate = isIndeterminate();
|
|
32
32
|
});
|
|
33
33
|
const handleChange = (event)=>{
|
|
34
|
-
invokeEventHandler(p.
|
|
34
|
+
invokeEventHandler(p.onNativeChange, event);
|
|
35
35
|
if (event.defaultPrevented) return;
|
|
36
36
|
if (isDisabled()) return;
|
|
37
|
-
|
|
38
|
-
if (
|
|
37
|
+
const checked = event.currentTarget.checked;
|
|
38
|
+
if (group && void 0 !== optionValue()) {
|
|
39
|
+
group.toggleValue(optionValue(), checked, event);
|
|
40
|
+
p.onChange?.(checked);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!isControlled()) setInternalSelected(checked);
|
|
44
|
+
p.onChange?.(checked);
|
|
39
45
|
};
|
|
40
46
|
var _el$ = _tmpl$5(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild;
|
|
41
47
|
spread(_el$, mergeProps(()=>({
|
|
@@ -168,7 +174,9 @@ const Checkbox = defineComponent({
|
|
|
168
174
|
"issues",
|
|
169
175
|
"isIndeterminate",
|
|
170
176
|
"indeterminate",
|
|
171
|
-
"variant"
|
|
177
|
+
"variant",
|
|
178
|
+
"onChange",
|
|
179
|
+
"onNativeChange"
|
|
172
180
|
]
|
|
173
181
|
});
|
|
174
182
|
const Checkbox_generated = Checkbox;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.connection-settings {
|
|
3
|
+
display: flex;
|
|
4
|
+
width: 100%;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: 1.5rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.connection-settings__header {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
gap: 1rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.connection-settings__title {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.connection-settings__description {
|
|
21
|
+
font-size: 0.875rem;
|
|
22
|
+
opacity: 0.7;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* The fields are absent from the tree while closed rather than hidden. A
|
|
27
|
+
* reveal that only sets `display: none` reads as present to anything driving
|
|
28
|
+
* the renderer, so a broken toggle still looks like it worked.
|
|
29
|
+
*/
|
|
30
|
+
.connection-settings__fields {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: 1rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.connection-settings__field {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: 0.375rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.connection-settings__label {
|
|
43
|
+
font-size: 0.875rem;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.connection-settings__input {
|
|
48
|
+
width: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.connection-settings__hint {
|
|
52
|
+
font-size: 0.875rem;
|
|
53
|
+
opacity: 0.7;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.connection-settings__current {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
gap: 0.25rem;
|
|
60
|
+
font-size: 0.875rem;
|
|
61
|
+
opacity: 0.6;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.connection-settings__actions {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
gap: 0.5rem;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* `data-applying`, not a class: the flag is this component's own runtime
|
|
71
|
+
state, not a prop, so a recipe prop could never be driven by it. State
|
|
72
|
+
attributes are what the library documents for exactly this. */
|
|
73
|
+
.connection-settings[data-applying="true"] .connection-settings__actions {
|
|
74
|
+
opacity: 0.6;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Component as __LayoutComponent } from "solid-js";
|
|
2
|
+
import "./ConnectionSettings.css";
|
|
3
|
+
import type { JSX } from "@solidjs/web";
|
|
4
|
+
import type { ConnectionSettingsStore } from "../../hooks/connection";
|
|
5
|
+
import type { UIBaseProps } from "../vocabulary";
|
|
6
|
+
/** One backend, as this panel presents it. `name` matches the store's endpoint. */
|
|
7
|
+
export type ConnectionSettingsEndpointLabel = {
|
|
8
|
+
name: string;
|
|
9
|
+
label: string;
|
|
10
|
+
/** Shown under the field. The place to say what the default is for. */
|
|
11
|
+
hint?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ConnectionSettingsLabels = {
|
|
15
|
+
/** The switch's own label. */
|
|
16
|
+
useCustom: string;
|
|
17
|
+
useCustomDescription?: string;
|
|
18
|
+
appPublicId?: string;
|
|
19
|
+
save: string;
|
|
20
|
+
reset: string;
|
|
21
|
+
/** Prefix for the read-only "this is where you are pointed" lines. */
|
|
22
|
+
current?: string;
|
|
23
|
+
};
|
|
24
|
+
export type ConnectionSettingsProps = Omit<JSX.FormHTMLAttributes<HTMLFormElement>, "onSubmit"> & UIBaseProps & {
|
|
25
|
+
/** From `createConnectionSettings`. The panel reads and writes it directly. */
|
|
26
|
+
store: ConnectionSettingsStore;
|
|
27
|
+
endpoints: readonly ConnectionSettingsEndpointLabel[];
|
|
28
|
+
labels: ConnectionSettingsLabels;
|
|
29
|
+
/** Omit to hide the app id field entirely. */
|
|
30
|
+
showAppPublicId?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Rendered inside the revealed region, after the endpoint fields.
|
|
33
|
+
*
|
|
34
|
+
* Every site has one field the others do not: an app id, a second backend,
|
|
35
|
+
* a network selector. Putting them here keeps them inside the same reveal
|
|
36
|
+
* instead of forcing a second copy of the panel.
|
|
37
|
+
*/
|
|
38
|
+
children?: JSX.Element;
|
|
39
|
+
/** Called after the store has applied. For a toast, or navigation. */
|
|
40
|
+
onSaved?: () => void;
|
|
41
|
+
/** Called when applying threw. The panel also shows the message itself. */
|
|
42
|
+
onSaveFailed?: (error: unknown) => void;
|
|
43
|
+
onResetDone?: () => void;
|
|
44
|
+
};
|
|
45
|
+
export declare const ConnectionSettingsLayout: __LayoutComponent<ConnectionSettingsProps>;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { claimElement, createComponent, insert, memo, mergeProps, spread, template } from "@solidjs/web";
|
|
2
|
+
import { defineComponent } from "solid-layouts/solid-2/application-boundary";
|
|
3
|
+
import "./ConnectionSettings.css";
|
|
4
|
+
import { For, Show, createMemo, createSignal, createUniqueId, omit } from "solid-js";
|
|
5
|
+
import button_0 from "../button/index.js";
|
|
6
|
+
import input from "../input/index.js";
|
|
7
|
+
import switch_0 from "../switch/index.js";
|
|
8
|
+
import { componentRecipe } from "./ConnectionSettings.recipe.js";
|
|
9
|
+
var _tmpl$ = /*#__PURE__*/ template("<p>"), _tmpl$2 = /*#__PURE__*/ template("<div><!><!>"), _tmpl$3 = /*#__PURE__*/ template("<div><label>"), _tmpl$4 = /*#__PURE__*/ template("<form><div><div><p></p></div></div><!><div></div><div><!><!>"), _tmpl$5 = /*#__PURE__*/ template("<div><label></label><!><!>"), _tmpl$6 = /*#__PURE__*/ template("<span><!>: <!>");
|
|
10
|
+
const __solidLayoutConnectionSettingsLayout = (_stable, p)=>{
|
|
11
|
+
const others = omit(p, "children", "class", "dataTheme", "onSubmit", "style", "store", "endpoints", "labels", "showAppPublicId", "onSaved", "onSaveFailed", "onResetDone");
|
|
12
|
+
const uid = createUniqueId();
|
|
13
|
+
const fieldId = (name)=>`connection-settings-${uid}-${name}`;
|
|
14
|
+
const [open, setOpen] = createSignal(p.endpoints.some((e)=>p.store.isOverridden(e.name)));
|
|
15
|
+
const [draft, setDraft] = createSignal({});
|
|
16
|
+
const [appIdDraft, setAppIdDraft] = createSignal(void 0);
|
|
17
|
+
const [failure, setFailure] = createSignal(void 0);
|
|
18
|
+
const fieldValue = (name)=>draft()[name] ?? p.store.state.urls[name] ?? "";
|
|
19
|
+
const appIdValue = ()=>appIdDraft() ?? p.store.state.appPublicId;
|
|
20
|
+
const resolvedUrls = createMemo(()=>p.store.urls);
|
|
21
|
+
const edit = (name, value)=>setDraft({
|
|
22
|
+
...draft(),
|
|
23
|
+
[name]: value
|
|
24
|
+
});
|
|
25
|
+
const setUseCustom = (next)=>setOpen(next);
|
|
26
|
+
let saving = false;
|
|
27
|
+
const save = async ()=>{
|
|
28
|
+
if (saving) return;
|
|
29
|
+
saving = true;
|
|
30
|
+
try {
|
|
31
|
+
await commit();
|
|
32
|
+
} finally{
|
|
33
|
+
saving = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const commit = async ()=>{
|
|
37
|
+
setFailure(void 0);
|
|
38
|
+
const values = new Map(p.endpoints.map((endpoint)=>[
|
|
39
|
+
endpoint.name,
|
|
40
|
+
fieldValue(endpoint.name)
|
|
41
|
+
]));
|
|
42
|
+
if (open()) for (const [name, value] of values){
|
|
43
|
+
const problem = p.store.validate(name, value);
|
|
44
|
+
if (problem) {
|
|
45
|
+
setFailure(problem);
|
|
46
|
+
p.onSaveFailed?.(new Error(problem));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const endpoint of p.endpoints){
|
|
51
|
+
const value = values.get(endpoint.name) ?? "";
|
|
52
|
+
const fallback = p.store.fallbacks[endpoint.name];
|
|
53
|
+
const overridden = open() && "" !== value && value !== fallback;
|
|
54
|
+
p.store.setOverride(endpoint.name, overridden);
|
|
55
|
+
if ("" !== value) p.store.setUrl(endpoint.name, value);
|
|
56
|
+
}
|
|
57
|
+
const id = appIdDraft();
|
|
58
|
+
if (void 0 !== id) p.store.setAppPublicId(id);
|
|
59
|
+
setDraft({});
|
|
60
|
+
setAppIdDraft(void 0);
|
|
61
|
+
try {
|
|
62
|
+
await p.store.apply();
|
|
63
|
+
p.onSaved?.();
|
|
64
|
+
} catch (error) {
|
|
65
|
+
setFailure(error instanceof Error ? error.message : String(error));
|
|
66
|
+
p.onSaveFailed?.(error);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const saveOnEnter = (event)=>{
|
|
70
|
+
if ("Enter" !== event.key || event.isComposing) return;
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
save();
|
|
73
|
+
};
|
|
74
|
+
const reset = async ()=>{
|
|
75
|
+
setFailure(void 0);
|
|
76
|
+
setDraft({});
|
|
77
|
+
setAppIdDraft(void 0);
|
|
78
|
+
p.store.reset();
|
|
79
|
+
setOpen(false);
|
|
80
|
+
try {
|
|
81
|
+
await p.store.apply();
|
|
82
|
+
p.onResetDone?.();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
setFailure(error instanceof Error ? error.message : String(error));
|
|
85
|
+
p.onSaveFailed?.(error);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var _el$ = _tmpl$4(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$14 = _el$2.nextSibling, _el$1 = _el$14.nextSibling, _el$11 = _el$1.nextSibling, _el$12 = _el$11.firstChild, _el$13 = _el$12.nextSibling;
|
|
89
|
+
claimElement(_el$);
|
|
90
|
+
spread(_el$, mergeProps(others, ()=>_stable.slot.root, {
|
|
91
|
+
get style () {
|
|
92
|
+
return p.style;
|
|
93
|
+
},
|
|
94
|
+
get ["data-theme"] () {
|
|
95
|
+
return p.dataTheme;
|
|
96
|
+
},
|
|
97
|
+
get ["data-open"] () {
|
|
98
|
+
return open() ? "true" : "false";
|
|
99
|
+
},
|
|
100
|
+
get ["data-applying"] () {
|
|
101
|
+
return p.store.isApplying ? "true" : "false";
|
|
102
|
+
},
|
|
103
|
+
onSubmit: (event)=>{
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
save();
|
|
106
|
+
}
|
|
107
|
+
}), true);
|
|
108
|
+
spread(_el$2, mergeProps(()=>_stable.slot.header), true);
|
|
109
|
+
spread(_el$4, mergeProps(()=>_stable.slot.title), true);
|
|
110
|
+
insert(_el$4, ()=>p.labels.useCustom);
|
|
111
|
+
insert(_el$3, createComponent(Show, {
|
|
112
|
+
get when () {
|
|
113
|
+
return p.labels.useCustomDescription;
|
|
114
|
+
},
|
|
115
|
+
get children () {
|
|
116
|
+
var _el$5 = _tmpl$();
|
|
117
|
+
spread(_el$5, mergeProps(()=>_stable.slot.description), true);
|
|
118
|
+
insert(_el$5, ()=>p.labels.useCustomDescription);
|
|
119
|
+
return _el$5;
|
|
120
|
+
}
|
|
121
|
+
}), null);
|
|
122
|
+
insert(_el$2, createComponent(switch_0, mergeProps(()=>_stable.slot.switch, {
|
|
123
|
+
get id () {
|
|
124
|
+
return fieldId("use-custom");
|
|
125
|
+
},
|
|
126
|
+
get ["aria-label"] () {
|
|
127
|
+
return p.labels.useCustom;
|
|
128
|
+
},
|
|
129
|
+
get checked () {
|
|
130
|
+
return open();
|
|
131
|
+
},
|
|
132
|
+
get disabled () {
|
|
133
|
+
return p.store.isApplying;
|
|
134
|
+
},
|
|
135
|
+
onChange: ()=>setUseCustom(!open())
|
|
136
|
+
})), null);
|
|
137
|
+
insert(_el$, createComponent(Show, {
|
|
138
|
+
get when () {
|
|
139
|
+
return open();
|
|
140
|
+
},
|
|
141
|
+
get children () {
|
|
142
|
+
var _el$6 = _tmpl$2(), _el$7 = _el$6.firstChild, _el$8 = _el$7.nextSibling;
|
|
143
|
+
spread(_el$6, mergeProps(()=>_stable.slot.fields), true);
|
|
144
|
+
insert(_el$6, createComponent(For, {
|
|
145
|
+
get each () {
|
|
146
|
+
return p.endpoints;
|
|
147
|
+
},
|
|
148
|
+
children: (endpoint)=>(()=>{
|
|
149
|
+
var _el$15 = _tmpl$5(), _el$16 = _el$15.firstChild, _el$18 = _el$16.nextSibling, _el$19 = _el$18.nextSibling;
|
|
150
|
+
spread(_el$15, mergeProps(()=>_stable.slot.field), true);
|
|
151
|
+
spread(_el$16, mergeProps(()=>_stable.slot.label, {
|
|
152
|
+
get ["for"] () {
|
|
153
|
+
return fieldId(endpoint.name);
|
|
154
|
+
}
|
|
155
|
+
}), true);
|
|
156
|
+
insert(_el$16, ()=>endpoint.label);
|
|
157
|
+
insert(_el$15, createComponent(input.Field, mergeProps(()=>_stable.slot.input, {
|
|
158
|
+
get id () {
|
|
159
|
+
return fieldId(endpoint.name);
|
|
160
|
+
},
|
|
161
|
+
get name () {
|
|
162
|
+
return endpoint.name;
|
|
163
|
+
},
|
|
164
|
+
type: "text",
|
|
165
|
+
onKeyDown: saveOnEnter,
|
|
166
|
+
get ["aria-label"] () {
|
|
167
|
+
return endpoint.label;
|
|
168
|
+
},
|
|
169
|
+
get placeholder () {
|
|
170
|
+
return endpoint.placeholder;
|
|
171
|
+
},
|
|
172
|
+
get value () {
|
|
173
|
+
return fieldValue(endpoint.name);
|
|
174
|
+
},
|
|
175
|
+
get disabled () {
|
|
176
|
+
return p.store.isApplying;
|
|
177
|
+
},
|
|
178
|
+
onInput: (event)=>edit(endpoint.name, event.currentTarget.value)
|
|
179
|
+
})), _el$18);
|
|
180
|
+
insert(_el$15, createComponent(Show, {
|
|
181
|
+
get when () {
|
|
182
|
+
return endpoint.hint;
|
|
183
|
+
},
|
|
184
|
+
get children () {
|
|
185
|
+
var _el$17 = _tmpl$();
|
|
186
|
+
spread(_el$17, mergeProps(()=>_stable.slot.hint), true);
|
|
187
|
+
insert(_el$17, ()=>endpoint.hint);
|
|
188
|
+
return _el$17;
|
|
189
|
+
}
|
|
190
|
+
}), _el$19);
|
|
191
|
+
return _el$15;
|
|
192
|
+
})()
|
|
193
|
+
}), _el$7);
|
|
194
|
+
insert(_el$6, ()=>_stable.children, _el$8);
|
|
195
|
+
return _el$6;
|
|
196
|
+
}
|
|
197
|
+
}), _el$14);
|
|
198
|
+
insert(_el$, createComponent(Show, {
|
|
199
|
+
get when () {
|
|
200
|
+
return memo(()=>!!p.showAppPublicId)() ? p.labels.appPublicId : p.showAppPublicId;
|
|
201
|
+
},
|
|
202
|
+
get children () {
|
|
203
|
+
var _el$9 = _tmpl$3(), _el$0 = _el$9.firstChild;
|
|
204
|
+
spread(_el$9, mergeProps(()=>_stable.slot.field), true);
|
|
205
|
+
spread(_el$0, mergeProps(()=>_stable.slot.label, {
|
|
206
|
+
get ["for"] () {
|
|
207
|
+
return fieldId("app-public-id");
|
|
208
|
+
}
|
|
209
|
+
}), true);
|
|
210
|
+
insert(_el$0, ()=>p.labels.appPublicId);
|
|
211
|
+
insert(_el$9, createComponent(input.Field, mergeProps(()=>_stable.slot.input, {
|
|
212
|
+
get id () {
|
|
213
|
+
return fieldId("app-public-id");
|
|
214
|
+
},
|
|
215
|
+
type: "text",
|
|
216
|
+
onKeyDown: saveOnEnter,
|
|
217
|
+
get ["aria-label"] () {
|
|
218
|
+
return p.labels.appPublicId;
|
|
219
|
+
},
|
|
220
|
+
get value () {
|
|
221
|
+
return appIdValue();
|
|
222
|
+
},
|
|
223
|
+
get disabled () {
|
|
224
|
+
return p.store.isApplying;
|
|
225
|
+
},
|
|
226
|
+
onInput: (event)=>setAppIdDraft(event.currentTarget.value)
|
|
227
|
+
})), null);
|
|
228
|
+
return _el$9;
|
|
229
|
+
}
|
|
230
|
+
}), _el$1);
|
|
231
|
+
spread(_el$1, mergeProps(()=>_stable.slot.current), true);
|
|
232
|
+
insert(_el$1, createComponent(For, {
|
|
233
|
+
get each () {
|
|
234
|
+
return p.endpoints;
|
|
235
|
+
},
|
|
236
|
+
children: (endpoint)=>(()=>{
|
|
237
|
+
var _el$20 = _tmpl$6(), _el$22 = _el$20.firstChild, _el$21 = _el$22.nextSibling, _el$23 = _el$21.nextSibling;
|
|
238
|
+
insert(_el$20, (()=>{
|
|
239
|
+
var _c$ = memo(()=>!!p.labels.current);
|
|
240
|
+
return ()=>_c$() ? `${p.labels.current} ` : "";
|
|
241
|
+
})(), _el$22);
|
|
242
|
+
insert(_el$20, ()=>endpoint.label, _el$21);
|
|
243
|
+
insert(_el$20, ()=>resolvedUrls()[endpoint.name], _el$23);
|
|
244
|
+
return _el$20;
|
|
245
|
+
})()
|
|
246
|
+
}));
|
|
247
|
+
insert(_el$, createComponent(Show, {
|
|
248
|
+
get when () {
|
|
249
|
+
return failure();
|
|
250
|
+
},
|
|
251
|
+
get children () {
|
|
252
|
+
var _el$10 = _tmpl$();
|
|
253
|
+
spread(_el$10, mergeProps(()=>_stable.slot.hint, {
|
|
254
|
+
role: "alert"
|
|
255
|
+
}), true);
|
|
256
|
+
insert(_el$10, failure);
|
|
257
|
+
return _el$10;
|
|
258
|
+
}
|
|
259
|
+
}), _el$11);
|
|
260
|
+
spread(_el$11, mergeProps(()=>_stable.slot.actions), true);
|
|
261
|
+
insert(_el$11, createComponent(button_0, {
|
|
262
|
+
type: "button",
|
|
263
|
+
flavor: "primary",
|
|
264
|
+
get disabled () {
|
|
265
|
+
return p.store.isApplying;
|
|
266
|
+
},
|
|
267
|
+
onClick: ()=>void save(),
|
|
268
|
+
get children () {
|
|
269
|
+
return p.labels.save;
|
|
270
|
+
}
|
|
271
|
+
}), _el$12);
|
|
272
|
+
insert(_el$11, createComponent(button_0, {
|
|
273
|
+
type: "button",
|
|
274
|
+
flavor: "secondary",
|
|
275
|
+
get disabled () {
|
|
276
|
+
return p.store.isApplying;
|
|
277
|
+
},
|
|
278
|
+
onClick: reset,
|
|
279
|
+
get children () {
|
|
280
|
+
return p.labels.reset;
|
|
281
|
+
}
|
|
282
|
+
}), _el$13);
|
|
283
|
+
return _el$;
|
|
284
|
+
};
|
|
285
|
+
const ConnectionSettingsLayout = defineComponent({
|
|
286
|
+
recipe: componentRecipe,
|
|
287
|
+
layout: __solidLayoutConnectionSettingsLayout,
|
|
288
|
+
embedded: true,
|
|
289
|
+
behaviour: [
|
|
290
|
+
"store",
|
|
291
|
+
"endpoints",
|
|
292
|
+
"labels",
|
|
293
|
+
"showAppPublicId",
|
|
294
|
+
"children",
|
|
295
|
+
"onSaved",
|
|
296
|
+
"onSaveFailed",
|
|
297
|
+
"onResetDone"
|
|
298
|
+
]
|
|
299
|
+
});
|
|
300
|
+
export { ConnectionSettingsLayout };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presentation lives here, not in the layout.
|
|
3
|
+
*
|
|
4
|
+
* This declared empty slots while `ConnectionSettings.layout.tsx` kept a
|
|
5
|
+
* `CLASSES` table and assembled class strings by hand with `twMerge`. That is
|
|
6
|
+
* the shape `solid-layouts-lint` calls a "legacy component-shaped Layout", and
|
|
7
|
+
* it was the only unbaselined warning in the repository -- new debt in a new
|
|
8
|
+
* component, which is exactly the debt `warningsAsErrors` exists to stop.
|
|
9
|
+
*
|
|
10
|
+
* `open` and `applying` are recipe props rather than conditional classes in the
|
|
11
|
+
* component, so the compiler owns the whole class string.
|
|
12
|
+
*/
|
|
13
|
+
export declare const componentRecipe: import("solid-layouts/solid-2").Recipe<{
|
|
14
|
+
readonly component: "connection-settings";
|
|
15
|
+
readonly element: "form";
|
|
16
|
+
readonly slots: {
|
|
17
|
+
readonly root: {
|
|
18
|
+
readonly base: "connection-settings";
|
|
19
|
+
};
|
|
20
|
+
readonly header: {
|
|
21
|
+
readonly base: "connection-settings__header";
|
|
22
|
+
};
|
|
23
|
+
readonly title: {
|
|
24
|
+
readonly base: "connection-settings__title";
|
|
25
|
+
};
|
|
26
|
+
readonly description: {
|
|
27
|
+
readonly base: "connection-settings__description";
|
|
28
|
+
};
|
|
29
|
+
readonly switch: {
|
|
30
|
+
readonly base: "connection-settings__switch";
|
|
31
|
+
};
|
|
32
|
+
readonly fields: {
|
|
33
|
+
readonly base: "connection-settings__fields";
|
|
34
|
+
};
|
|
35
|
+
readonly field: {
|
|
36
|
+
readonly base: "connection-settings__field";
|
|
37
|
+
};
|
|
38
|
+
readonly label: {
|
|
39
|
+
readonly base: "connection-settings__label";
|
|
40
|
+
};
|
|
41
|
+
readonly input: {
|
|
42
|
+
readonly base: "connection-settings__input";
|
|
43
|
+
};
|
|
44
|
+
readonly hint: {
|
|
45
|
+
readonly base: "connection-settings__hint";
|
|
46
|
+
};
|
|
47
|
+
readonly current: {
|
|
48
|
+
readonly base: "connection-settings__current";
|
|
49
|
+
};
|
|
50
|
+
readonly actions: {
|
|
51
|
+
readonly base: "connection-settings__actions";
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}>;
|