@pathscale/ui 2.4.0 → 2.5.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/button/Button.generated.d.ts +16 -0
- package/dist/components/button/Button.generated.js +76 -61
- package/dist/components/button/Button.interactions.d.ts +28 -0
- package/dist/components/button/Button.interactions.js +4 -0
- package/dist/layouts.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,22 @@ export type ButtonProps = Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, "col
|
|
|
11
11
|
width?: Width | "square";
|
|
12
12
|
radius?: Radius;
|
|
13
13
|
type?: "button" | "submit" | "reset";
|
|
14
|
+
/**
|
|
15
|
+
* Renders an anchor instead of a button, and navigates.
|
|
16
|
+
*
|
|
17
|
+
* A link that looks like a button is the single most common thing every
|
|
18
|
+
* app in the fleet was reaching outside the library for, because `Button`
|
|
19
|
+
* was a `<button>` and `Link`'s variants are underline treatments rather
|
|
20
|
+
* than fills. Both spellings existed and neither was this one, so call
|
|
21
|
+
* sites wrote the raw classes instead.
|
|
22
|
+
*
|
|
23
|
+
* It is a real anchor: middle-click, right-click, open-in-new-tab and
|
|
24
|
+
* "copy link address" all work, which is exactly what a `<button>` with an
|
|
25
|
+
* onClick handler takes away.
|
|
26
|
+
*/
|
|
27
|
+
href?: string;
|
|
28
|
+
target?: JSX.AnchorHTMLAttributes<HTMLAnchorElement>["target"];
|
|
29
|
+
rel?: string;
|
|
14
30
|
children?: JSX.Element;
|
|
15
31
|
};
|
|
16
32
|
export declare const ButtonLayout: __LayoutComponent<ButtonProps>;
|
|
@@ -1,71 +1,86 @@
|
|
|
1
|
-
import { createComponent, insert, mergeProps, spread, template } from "solid-js/web";
|
|
1
|
+
import { Dynamic, createComponent, insert, memo, mergeProps, spread, template } from "solid-js/web";
|
|
2
2
|
import { defineComponent } from "solid-layouts/application-boundary";
|
|
3
3
|
import "./Button.css";
|
|
4
4
|
import { Show } from "solid-js";
|
|
5
5
|
import { button as external_Button_recipe_js_button } from "./Button.recipe.js";
|
|
6
|
-
|
|
6
|
+
import { buttonElement, buttonHref, buttonRel } from "./Button.interactions.js";
|
|
7
|
+
var _tmpl$ = /*#__PURE__*/ template("<span>");
|
|
7
8
|
const __solidLayoutButtonLayout = (_stable, p)=>{
|
|
8
9
|
const loading = ()=>"loading" === p.state;
|
|
9
10
|
const inert = ()=>loading() || "disabled" === p.state || Boolean(p.disabled);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
11
|
+
const element = ()=>buttonElement(p.href);
|
|
12
|
+
return createComponent(Dynamic, mergeProps({
|
|
13
|
+
get component () {
|
|
14
|
+
return element();
|
|
15
|
+
}
|
|
16
|
+
}, ()=>_stable.slot.root, {
|
|
17
|
+
get type () {
|
|
18
|
+
return memo(()=>"a" === element())() ? void 0 : p.type ?? "button";
|
|
19
|
+
},
|
|
20
|
+
get href () {
|
|
21
|
+
return buttonHref(p.href, inert());
|
|
22
|
+
},
|
|
23
|
+
get target () {
|
|
24
|
+
return memo(()=>"a" === element())() ? p.target : void 0;
|
|
25
|
+
},
|
|
26
|
+
get rel () {
|
|
27
|
+
return memo(()=>"a" === element())() ? buttonRel(p.rel, p.target) : void 0;
|
|
28
|
+
},
|
|
29
|
+
get disabled () {
|
|
30
|
+
return memo(()=>"a" === element())() ? void 0 : inert();
|
|
31
|
+
},
|
|
32
|
+
get ["aria-disabled"] () {
|
|
33
|
+
return inert() ? "true" : "false";
|
|
34
|
+
},
|
|
35
|
+
get ["aria-busy"] () {
|
|
36
|
+
return loading() ? "true" : void 0;
|
|
37
|
+
},
|
|
38
|
+
get ["data-state"] () {
|
|
39
|
+
return p.state ?? "default";
|
|
40
|
+
},
|
|
41
|
+
get ["data-flavor"] () {
|
|
42
|
+
return p.flavor ?? "primary";
|
|
43
|
+
},
|
|
44
|
+
get children () {
|
|
45
|
+
return [
|
|
46
|
+
createComponent(Show, {
|
|
47
|
+
get when () {
|
|
48
|
+
return loading();
|
|
49
|
+
},
|
|
50
|
+
get children () {
|
|
51
|
+
var _el$ = _tmpl$();
|
|
52
|
+
spread(_el$, mergeProps(()=>_stable.slot.spinner, {
|
|
53
|
+
"aria-hidden": "true"
|
|
54
|
+
}), false, false);
|
|
55
|
+
return _el$;
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
createComponent(Show, {
|
|
59
|
+
get when () {
|
|
60
|
+
return p.startIcon;
|
|
61
|
+
},
|
|
62
|
+
get children () {
|
|
63
|
+
var _el$2 = _tmpl$();
|
|
64
|
+
spread(_el$2, mergeProps(()=>_stable.slot.startIcon), false, true);
|
|
65
|
+
insert(_el$2, ()=>p.startIcon);
|
|
66
|
+
return _el$2;
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
memo(()=>_stable.children),
|
|
70
|
+
createComponent(Show, {
|
|
71
|
+
get when () {
|
|
72
|
+
return p.endIcon;
|
|
73
|
+
},
|
|
74
|
+
get children () {
|
|
75
|
+
var _el$3 = _tmpl$();
|
|
76
|
+
spread(_el$3, mergeProps(()=>_stable.slot.endIcon), false, true);
|
|
77
|
+
insert(_el$3, ()=>p.endIcon);
|
|
78
|
+
return _el$3;
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
69
84
|
};
|
|
70
85
|
const ButtonLayout = defineComponent({
|
|
71
86
|
recipe: external_Button_recipe_js_button,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `href` decides, as three functions.
|
|
3
|
+
*
|
|
4
|
+
* A `.layout.tsx` binds free identifiers to props, so anything with a rule in
|
|
5
|
+
* it belongs beside the markup rather than inside it. These are also the parts
|
|
6
|
+
* worth testing, and the repository's tests are pure: there is no DOM in the
|
|
7
|
+
* suite, by choice.
|
|
8
|
+
*/
|
|
9
|
+
/** An anchor when there is somewhere to go, a button otherwise. */
|
|
10
|
+
export declare const buttonElement: (href: string | undefined) => "a" | "button";
|
|
11
|
+
/**
|
|
12
|
+
* The destination, unless the control is inert.
|
|
13
|
+
*
|
|
14
|
+
* There is no `disabled` on an anchor. Keeping the `href` and refusing the
|
|
15
|
+
* click leaves it focusable, activatable by Enter, and still offering "open in
|
|
16
|
+
* new tab" from the context menu - a disabled control that is not disabled.
|
|
17
|
+
* Removing the attribute is what makes it inert; `aria-disabled` is how it is
|
|
18
|
+
* announced.
|
|
19
|
+
*/
|
|
20
|
+
export declare const buttonHref: (href: string | undefined, inert: boolean) => string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* `rel` for a link, defaulted for new tabs.
|
|
23
|
+
*
|
|
24
|
+
* A `target="_blank"` without `noopener` hands the opening document to the
|
|
25
|
+
* destination. Defaulted rather than forced, so a caller who means `me` or
|
|
26
|
+
* `nofollow` still gets it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const buttonRel: (rel: string | undefined, target: string | undefined) => string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const buttonElement = (href)=>"string" == typeof href ? "a" : "button";
|
|
2
|
+
const buttonHref = (href, inert)=>"string" != typeof href || inert ? void 0 : href;
|
|
3
|
+
const buttonRel = (rel, target)=>rel ?? ("_blank" === target ? "noopener noreferrer" : void 0);
|
|
4
|
+
export { buttonElement, buttonHref, buttonRel };
|