@jointhedots/button 0.1.0 → 0.1.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/README.md +6 -1
- package/dist/Button.d.ts +1 -1
- package/dist/index.js +82 -85
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @jointhedots/button
|
|
2
2
|
|
|
3
|
-
Boutons Join.The.Dots : `Button` (label, icône, variante,
|
|
3
|
+
Boutons Join.The.Dots : `Button` (label, icône, variante, taille,
|
|
4
4
|
tooltip) et `ButtonIcon` (icône seule, survol alternatif, pastilles colorées).
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
@@ -20,9 +20,14 @@ import { Button, ButtonIcon } from "@jointhedots/button"
|
|
|
20
20
|
import "@jointhedots/icon/bootstrap"
|
|
21
21
|
|
|
22
22
|
<Button label="Save" icon="bi:save" variant="primary" onClick={...} />
|
|
23
|
+
<Button label="Save" icon="bi:save" variant="primary" size="sm" />
|
|
23
24
|
<ButtonIcon icon="bi:trash" variant="primary" title="Delete" />
|
|
24
25
|
<ButtonIcon icon="bi:star" hoveredIcon="bi:star-fill" size="lg" />
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
`size` (`xs`/`sm`/`md`/`lg`) partage les métriques des champs
|
|
29
|
+
d'@jointhedots/input : un bouton aligné sur un champ de même taille partage
|
|
30
|
+
sa hauteur.
|
|
31
|
+
|
|
27
32
|
Les styles du package (gabarits `jtd-button*`, `jtd-tooltip`) sont injectés
|
|
28
33
|
automatiquement au chargement du module — aucun stylesheet à gérer.
|
package/dist/Button.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ interface ButtonProps {
|
|
|
7
7
|
hint?: boolean;
|
|
8
8
|
icon?: string;
|
|
9
9
|
iconPosition?: 'left' | 'right';
|
|
10
|
-
iconSize?: 'xs' | 'sm' | 'md' | 'lg';
|
|
11
10
|
iconVariant?: 'bare' | 'container' | 'border' | 'border-filled' | 'primary' | 'more' | 'global-header';
|
|
12
11
|
id?: string;
|
|
13
12
|
inverse?: boolean;
|
|
@@ -26,6 +25,7 @@ interface ButtonProps {
|
|
|
26
25
|
buttonRef?: (component: HTMLButtonElement | null) => void;
|
|
27
26
|
requestFocus?: boolean;
|
|
28
27
|
responsive?: boolean;
|
|
28
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
29
29
|
tabIndex?: string;
|
|
30
30
|
type?: 'reset' | 'submit' | 'button';
|
|
31
31
|
title?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import e from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as
|
|
2
|
+
import { FadeIcon as t, Icon as n, IconSize as r } from "@jointhedots/icon";
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
|
-
var
|
|
6
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i =
|
|
7
|
-
get: ((e) => t[e]).bind(null,
|
|
8
|
-
enumerable: !(r =
|
|
5
|
+
var o = Object.create, s = Object.defineProperty, c = Object.getOwnPropertyDescriptor, l = Object.getOwnPropertyNames, u = Object.getPrototypeOf, d = Object.prototype.hasOwnProperty, f = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), p = (e, t, n, r) => {
|
|
6
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = l(t), a = 0, o = i.length, u; a < o; a++) u = i[a], !d.call(e, u) && u !== n && s(e, u, {
|
|
7
|
+
get: ((e) => t[e]).bind(null, u),
|
|
8
|
+
enumerable: !(r = c(t, u)) || r.enumerable
|
|
9
9
|
});
|
|
10
10
|
return e;
|
|
11
|
-
},
|
|
11
|
+
}, m = (e, t, n) => (n = e == null ? {} : o(u(e)), p(t || !e || !e.__esModule || !d.call(e, "default") ? s(n, "default", {
|
|
12
12
|
value: e,
|
|
13
13
|
enumerable: !0
|
|
14
14
|
}) : n, e));
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region packages/button/src/inject-styles.ts
|
|
17
|
-
function
|
|
17
|
+
function h(e, t) {
|
|
18
18
|
if (typeof document > "u" || document.getElementById(t)) return;
|
|
19
19
|
let n = document.createElement("style");
|
|
20
20
|
n.id = t, n.textContent = e, document.head.appendChild(n);
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region packages/button/src/generated/styles.ts
|
|
24
|
-
var
|
|
24
|
+
var g = ".jtd-button{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:32px;padding:0 14px;font:inherit;font-size:14px;background-color:rgba(0,0,0,0);border:1px solid rgba(0,0,0,0);border-radius:5px;cursor:pointer;user-select:none;white-space:nowrap;transition:background-color 120ms ease,border-color 120ms ease,color 120ms ease}.jtd-button:disabled{opacity:.45;pointer-events:none}.jtd-button:focus-visible{outline:2px solid var(--jtd-primary);outline-offset:2px}.jtd-button.jtd-button--neutral{background-color:var(--jtd-surface);color:var(--jtd-surface-foreground);border-color:var(--jtd-border)}.jtd-button.jtd-button--neutral:hover{background-color:var(--jtd-hover)}.jtd-button.jtd-button--primary{background-color:var(--jtd-primary);color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--primary:hover{background-color:color-mix(in srgb, var(--jtd-primary), white 14%)}.jtd-button.jtd-button--outline-primary{color:var(--jtd-primary);border-color:var(--jtd-primary)}.jtd-button.jtd-button--outline-primary:hover{background-color:color-mix(in srgb, var(--jtd-primary), transparent 90%)}.jtd-button.jtd-button--error{background-color:var(--jtd-error);color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--error:hover{background-color:color-mix(in srgb, var(--jtd-error), white 14%)}.jtd-button.jtd-button--text-error{color:var(--jtd-error)}.jtd-button.jtd-button--text-error:hover{background-color:color-mix(in srgb, var(--jtd-error), transparent 88%)}.jtd-button.jtd-button--warning{background-color:var(--jtd-warning);color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--warning:hover{background-color:color-mix(in srgb, var(--jtd-warning), white 14%)}.jtd-button.jtd-button--success{background-color:var(--jtd-success);color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--success:hover{background-color:color-mix(in srgb, var(--jtd-success), white 14%)}.jtd-button.jtd-button--link{height:auto;padding:0;border:none;background:none;color:var(--jtd-primary)}.jtd-button.jtd-button--link:hover{text-decoration:underline}.jtd-button.jtd-button--inverse{color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--inverse:hover{background-color:color-mix(in srgb, var(--jtd-on-emphasis), transparent 84%)}.jtd-button.jtd-button--icon{width:32px;height:32px;padding:0;color:var(--jtd-foreground);background-color:rgba(0,0,0,0)}.jtd-button.jtd-button--icon:hover{background-color:var(--jtd-hover)}.jtd-button.jtd-button--icon:active{transform:scale(0.95)}.jtd-button.jtd-button--icon.jtd-button--icon-container{background-color:color-mix(in srgb, var(--jtd-foreground), transparent 88%)}.jtd-button.jtd-button--icon.jtd-button--icon-container:hover{background-color:color-mix(in srgb, var(--jtd-foreground), transparent 80%)}.jtd-button.jtd-button--icon.jtd-button--icon-border{border-color:var(--jtd-border)}.jtd-button.jtd-button--icon.jtd-button--icon-border:hover{background-color:var(--jtd-hover)}.jtd-button.jtd-button--icon.jtd-button--icon-border-filled{background-color:var(--jtd-surface);color:var(--jtd-surface-foreground);border-color:var(--jtd-border)}.jtd-button.jtd-button--icon.jtd-button--icon-border-filled:hover{background-color:var(--jtd-hover)}.jtd-button.jtd-button--icon.jtd-button--icon-primary{background-color:var(--jtd-primary);color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--icon.jtd-button--icon-primary:hover{background-color:color-mix(in srgb, var(--jtd-primary), white 14%)}.jtd-button.jtd-button--icon.jtd-button--icon-inverse{color:var(--jtd-on-emphasis)}.jtd-button.jtd-button--icon.jtd-button--icon-inverse:hover{background-color:color-mix(in srgb, var(--jtd-on-emphasis), transparent 84%)}.jtd-button.jtd-button--icon.jtd-button--icon-border-inverse{color:var(--jtd-on-emphasis);border-color:color-mix(in srgb, var(--jtd-on-emphasis), transparent 50%)}.jtd-button.jtd-button--icon.jtd-button--icon-border-inverse:hover{background-color:color-mix(in srgb, var(--jtd-on-emphasis), transparent 84%)}.jtd-button.jtd-button--xs{height:18px;padding:0 8px;gap:3px;font-size:12px;border-radius:4px}.jtd-button.jtd-button--xs.jtd-button--icon{width:18px;height:18px;padding:0}.jtd-button.jtd-button--xs.jtd-button--link{height:auto;padding:0}.jtd-button.jtd-button--sm{height:24px;padding:0 11px;gap:5px;font-size:13px}.jtd-button.jtd-button--sm.jtd-button--icon{width:24px;height:24px;padding:0}.jtd-button.jtd-button--sm.jtd-button--link{height:auto;padding:0}.jtd-button.jtd-button--lg{height:40px;padding:0 16px;gap:8px;font-size:15px}.jtd-button.jtd-button--lg.jtd-button--icon{width:40px;height:40px;padding:0}.jtd-button.jtd-button--lg.jtd-button--link{height:auto;padding:0}.jtd-tooltip{position:relative;display:inline-flex}.jtd-tooltip::before{content:\"\";position:absolute;bottom:calc(100% + 4px);left:50%;width:10px;height:10px;border:1px solid var(--jtd-border);background-color:var(--jtd-surface);transform:translateX(-50%) rotate(45deg);opacity:0;transition:opacity 120ms ease,visibility 0s linear 120ms;pointer-events:none}.jtd-tooltip .jtd-tooltip__content{position:absolute;bottom:calc(100% + 9px);left:50%;transform:translateX(-50%);z-index:10000001;max-width:300px;padding:6px 10px;background-color:var(--jtd-surface);color:var(--jtd-surface-foreground);border:1px solid var(--jtd-border);border-radius:6px;box-shadow:0 4px 12px rgba(0,0,0,.25);font-size:12px;white-space:normal;visibility:hidden;opacity:0;transition:opacity 120ms ease,visibility 0s linear 120ms;pointer-events:none}.jtd-tooltip:hover::before,.jtd-tooltip:focus-within::before,.jtd-tooltip:hover .jtd-tooltip__content,.jtd-tooltip:focus-within .jtd-tooltip__content{visibility:visible;opacity:1;transition:opacity 120ms ease 350ms,visibility 0s linear 470ms}.jtd-button-icon{display:flex;justify-content:center;align-items:center;width:1.8em;height:1.8em;min-width:1.8em;min-height:1.8em;max-width:1.8em;max-height:1.8em;color:var(--jtd-foreground);border-radius:100%;cursor:pointer;transition:background-color 150ms ease,transform 120ms ease-in-out}.jtd-button-icon:hover{background-color:var(--jtd-hover)}.jtd-button-icon:active{transform:scale(0.95)}.jtd-button-icon:focus-visible{outline:2px solid var(--jtd-primary);outline-offset:2px}.jtd-button-icon.primary{background-color:var(--jtd-primary);color:var(--jtd-on-emphasis)}.jtd-button-icon.primary:hover{background-color:color-mix(in srgb, var(--jtd-primary), white 14%)}.jtd-button-icon.neutral{border:solid thin var(--jtd-border);color:var(--jtd-foreground)}.jtd-button-icon.neutral:hover{background-color:var(--jtd-hover)}.jtd-button-icon.watermark{color:var(--jtd-muted)}.jtd-button-icon.watermark:hover{background-color:var(--jtd-hover);color:var(--jtd-foreground)}", _ = /* @__PURE__ */ m((/* @__PURE__ */ f(((e, t) => {
|
|
25
25
|
(function() {
|
|
26
26
|
var e = {}.hasOwnProperty;
|
|
27
27
|
function n() {
|
|
@@ -47,7 +47,7 @@ var h = ".jtd-button{display:inline-flex;align-items:center;justify-content:cent
|
|
|
47
47
|
return n;
|
|
48
48
|
}) : window.classNames = n;
|
|
49
49
|
})();
|
|
50
|
-
})))(), 1),
|
|
50
|
+
})))(), 1), v = /* @__PURE__ */ new Set([
|
|
51
51
|
"form",
|
|
52
52
|
"formAction",
|
|
53
53
|
"formEncType",
|
|
@@ -55,112 +55,109 @@ var h = ".jtd-button{display:inline-flex;align-items:center;justify-content:cent
|
|
|
55
55
|
"formNoValidate",
|
|
56
56
|
"formTarget"
|
|
57
57
|
]);
|
|
58
|
-
function
|
|
59
|
-
return Object.keys(e).reduce((t, n) => ((
|
|
58
|
+
function y(e) {
|
|
59
|
+
return Object.keys(e).reduce((t, n) => ((v.has(n) || n.startsWith("aria-") || n.startsWith("data-")) && (t[n] = e[n]), t), {});
|
|
60
60
|
}
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region packages/button/src/Button.tsx
|
|
63
|
-
var
|
|
63
|
+
var b = {
|
|
64
64
|
disabled: !1,
|
|
65
65
|
hint: !1,
|
|
66
66
|
responsive: !1,
|
|
67
|
+
size: "md",
|
|
67
68
|
type: "button",
|
|
68
69
|
variant: "neutral"
|
|
69
70
|
};
|
|
70
|
-
function
|
|
71
|
-
let
|
|
72
|
-
...
|
|
71
|
+
function x(e) {
|
|
72
|
+
let t = {
|
|
73
|
+
...b,
|
|
73
74
|
...e
|
|
74
|
-
},
|
|
75
|
-
let e =
|
|
76
|
-
return
|
|
77
|
-
"jtd-button--link":
|
|
78
|
-
[`jtd-button--${
|
|
79
|
-
"jtd-button--inverse":
|
|
75
|
+
}, r = () => {
|
|
76
|
+
let e = t.variant === "icon", { iconVariant: n } = t, r = n === "border";
|
|
77
|
+
return n === "global-header" && (n = "container"), (0, _.default)("jtd-button", {
|
|
78
|
+
"jtd-button--link": t.variant === "link",
|
|
79
|
+
[`jtd-button--${t.variant}`]: !e && t.variant !== "base" && t.variant !== "link" && !t.inverse && !n,
|
|
80
|
+
"jtd-button--inverse": t.inverse && !e,
|
|
80
81
|
"jtd-button--icon": e,
|
|
81
|
-
[`jtd-button--icon-${
|
|
82
|
-
"jtd-button--icon-inverse":
|
|
83
|
-
"jtd-button--icon-border-inverse":
|
|
84
|
-
[`jtd-button
|
|
85
|
-
},
|
|
82
|
+
[`jtd-button--icon-${n}`]: e && n && n !== "bare",
|
|
83
|
+
"jtd-button--icon-inverse": t.inverse && e && !r,
|
|
84
|
+
"jtd-button--icon-border-inverse": t.inverse && e && r,
|
|
85
|
+
[`jtd-button--${t.size}`]: t.size !== "md"
|
|
86
|
+
}, t.className);
|
|
86
87
|
}, o = (e) => {
|
|
87
|
-
|
|
88
|
-
}, s = (e) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
inverse: n.inverse,
|
|
93
|
-
size: i
|
|
94
|
-
});
|
|
95
|
-
}, c = () => n.icon && n.assistiveText ? null : n.label, l = n.assistiveText || (n.variant === "icon" && typeof n.label == "string" ? n.label : void 0), u = () => /* @__PURE__ */ i("button", {
|
|
88
|
+
t.onClick && t.onClick(e, {});
|
|
89
|
+
}, s = (e) => /* @__PURE__ */ i(n, {
|
|
90
|
+
name: e,
|
|
91
|
+
inverse: t.inverse
|
|
92
|
+
}), c = () => t.icon && t.assistiveText ? null : t.label, l = t.assistiveText || (t.variant === "icon" && typeof t.label == "string" ? t.label : void 0), u = () => /* @__PURE__ */ a("button", {
|
|
96
93
|
"aria-label": l,
|
|
97
|
-
className:
|
|
98
|
-
disabled:
|
|
99
|
-
id:
|
|
100
|
-
onBlur:
|
|
94
|
+
className: r(),
|
|
95
|
+
disabled: t.disabled,
|
|
96
|
+
id: t.id,
|
|
97
|
+
onBlur: t.onBlur,
|
|
101
98
|
onClick: o,
|
|
102
|
-
onFocus:
|
|
103
|
-
onKeyDown:
|
|
104
|
-
onKeyPress:
|
|
105
|
-
onKeyUp:
|
|
106
|
-
onMouseDown:
|
|
107
|
-
onMouseEnter:
|
|
108
|
-
onMouseLeave:
|
|
109
|
-
onMouseUp:
|
|
99
|
+
onFocus: t.onFocus,
|
|
100
|
+
onKeyDown: t.onKeyDown,
|
|
101
|
+
onKeyPress: t.onKeyPress,
|
|
102
|
+
onKeyUp: t.onKeyUp,
|
|
103
|
+
onMouseDown: t.onMouseDown,
|
|
104
|
+
onMouseEnter: t.onMouseEnter,
|
|
105
|
+
onMouseLeave: t.onMouseLeave,
|
|
106
|
+
onMouseUp: t.onMouseUp,
|
|
110
107
|
ref: (e) => {
|
|
111
|
-
|
|
108
|
+
t.buttonRef && t.buttonRef(e), e && t.requestFocus && t.onRequestFocus && t.onRequestFocus(e);
|
|
112
109
|
},
|
|
113
|
-
title:
|
|
114
|
-
type:
|
|
115
|
-
style:
|
|
116
|
-
...
|
|
110
|
+
title: t.title,
|
|
111
|
+
type: t.type || "button",
|
|
112
|
+
style: t.style,
|
|
113
|
+
...y(t),
|
|
117
114
|
children: [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
t.iconPosition === "right" ? c() : null,
|
|
116
|
+
t.icon ? s(t.icon || "") : null,
|
|
117
|
+
t.iconPosition === "left" || !t.iconPosition ? c() : null,
|
|
118
|
+
t.children
|
|
122
119
|
]
|
|
123
120
|
});
|
|
124
|
-
return
|
|
121
|
+
return t.tooltip ? /* @__PURE__ */ a("span", {
|
|
125
122
|
className: "jtd-tooltip",
|
|
126
|
-
children: [u(), /* @__PURE__ */
|
|
123
|
+
children: [u(), /* @__PURE__ */ i("span", {
|
|
127
124
|
className: "jtd-tooltip__content",
|
|
128
125
|
role: "tooltip",
|
|
129
|
-
children:
|
|
126
|
+
children: t.tooltip
|
|
130
127
|
})]
|
|
131
128
|
}) : u();
|
|
132
129
|
}
|
|
133
|
-
function
|
|
134
|
-
let { icon:
|
|
135
|
-
...
|
|
136
|
-
fontSize:
|
|
137
|
-
} :
|
|
138
|
-
if (
|
|
139
|
-
let [n,
|
|
140
|
-
return /* @__PURE__ */
|
|
141
|
-
...
|
|
142
|
-
className:
|
|
143
|
-
style:
|
|
144
|
-
onMouseEnter: () =>
|
|
145
|
-
onMouseLeave: () =>
|
|
146
|
-
children: /* @__PURE__ */
|
|
147
|
-
name: n ?
|
|
148
|
-
inverse:
|
|
130
|
+
function S(a) {
|
|
131
|
+
let { icon: o, hoveredIcon: s, size: c, inversed: l, variant: u, className: d, style: f, ...p } = a, m = u ? `jtd-button-icon ${u}` : "jtd-button-icon", h = d ? m + " " + d : m, g = c ? {
|
|
132
|
+
...f,
|
|
133
|
+
fontSize: c && (r[c] || c)
|
|
134
|
+
} : f;
|
|
135
|
+
if (s) {
|
|
136
|
+
let [n, r] = e.useState(!1);
|
|
137
|
+
return /* @__PURE__ */ i("div", {
|
|
138
|
+
...p,
|
|
139
|
+
className: h,
|
|
140
|
+
style: g,
|
|
141
|
+
onMouseEnter: () => r(!0),
|
|
142
|
+
onMouseLeave: () => r(!1),
|
|
143
|
+
children: /* @__PURE__ */ i(t, {
|
|
144
|
+
name: n ? s : o,
|
|
145
|
+
inverse: l
|
|
149
146
|
})
|
|
150
147
|
});
|
|
151
148
|
}
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
...
|
|
154
|
-
className:
|
|
155
|
-
style:
|
|
156
|
-
children: /* @__PURE__ */
|
|
157
|
-
name:
|
|
158
|
-
inverse:
|
|
149
|
+
return /* @__PURE__ */ i("div", {
|
|
150
|
+
...p,
|
|
151
|
+
className: h,
|
|
152
|
+
style: g,
|
|
153
|
+
children: /* @__PURE__ */ i(n, {
|
|
154
|
+
name: o,
|
|
155
|
+
inverse: l
|
|
159
156
|
})
|
|
160
157
|
});
|
|
161
158
|
}
|
|
162
159
|
//#endregion
|
|
163
160
|
//#region packages/button/src/index.ts
|
|
164
|
-
|
|
161
|
+
h(g, "jtd-button-styles");
|
|
165
162
|
//#endregion
|
|
166
|
-
export {
|
|
163
|
+
export { x as Button, x as default, S as ButtonIcon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jointhedots/button",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Join.The.Dots buttons — Button with variants and icon-only ButtonIcon",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@jointhedots/icon": "^0.1.
|
|
18
|
+
"@jointhedots/icon": "^0.1.3",
|
|
19
19
|
"classnames": "^2.5.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|