@jointhedots/button 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Join.The.Dots contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @jointhedots/button
2
+
3
+ Boutons Join.The.Dots : `Button` (label, icône, variante,
4
+ tooltip) et `ButtonIcon` (icône seule, survol alternatif, pastilles colorées).
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ pnpm add @jointhedots/button
10
+ ```
11
+
12
+ Peer dependency : `react` ≥ 18.2.0. Le package dépend de
13
+ `@jointhedots/icon` pour les glyphes et consomme les tokens `--jtd-*` de
14
+ `@jointhedots/theme`.
15
+
16
+ ## Usage
17
+
18
+ ```tsx
19
+ import { Button, ButtonIcon } from "@jointhedots/button"
20
+ import "@jointhedots/icon/bootstrap"
21
+
22
+ <Button label="Save" icon="bi:save" variant="primary" onClick={...} />
23
+ <ButtonIcon icon="bi:trash" variant="primary" title="Delete" />
24
+ <ButtonIcon icon="bi:star" hoveredIcon="bi:star-fill" size="lg" />
25
+ ```
26
+
27
+ Les styles du package (gabarits `jtd-button*`, `jtd-tooltip`) sont injectés
28
+ automatiquement au chargement du module — aucun stylesheet à gérer.
@@ -0,0 +1,50 @@
1
+ import { default as React } from 'react';
2
+ import { IconSize } from '../../icon/src/index.ts';
3
+ interface ButtonProps {
4
+ assistiveText?: string;
5
+ className?: string | object | any[];
6
+ disabled?: boolean;
7
+ hint?: boolean;
8
+ icon?: string;
9
+ iconPosition?: 'left' | 'right';
10
+ iconSize?: 'xs' | 'sm' | 'md' | 'lg';
11
+ iconVariant?: 'bare' | 'container' | 'border' | 'border-filled' | 'primary' | 'more' | 'global-header';
12
+ id?: string;
13
+ inverse?: boolean;
14
+ label?: string | React.ReactNode;
15
+ onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
16
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>, data: {}) => void;
17
+ onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
18
+ onKeyDown?: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
19
+ onKeyPress?: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
20
+ onKeyUp?: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
21
+ onMouseDown?: (event: React.MouseEvent<HTMLButtonElement>) => void;
22
+ onMouseEnter?: (event: React.MouseEvent<HTMLButtonElement>) => void;
23
+ onMouseLeave?: (event: React.MouseEvent<HTMLButtonElement>) => void;
24
+ onMouseUp?: (event: React.MouseEvent<HTMLButtonElement>) => void;
25
+ onRequestFocus?: (component: HTMLButtonElement) => void;
26
+ buttonRef?: (component: HTMLButtonElement | null) => void;
27
+ requestFocus?: boolean;
28
+ responsive?: boolean;
29
+ tabIndex?: string;
30
+ type?: 'reset' | 'submit' | 'button';
31
+ title?: string;
32
+ tooltip?: React.ReactNode;
33
+ variant?: 'base' | 'link' | 'neutral' | 'primary' | 'outline-primary' | 'error' | 'text-error' | 'success' | 'warning' | 'icon';
34
+ style?: React.CSSProperties;
35
+ children?: React.ReactNode;
36
+ }
37
+ export declare function Button(inProps: ButtonProps): React.JSX.Element;
38
+ export type ButtonIconProps = {
39
+ icon: string;
40
+ hoveredIcon?: string;
41
+ size?: IconSize | string;
42
+ title?: string;
43
+ inversed?: boolean;
44
+ variant?: "primary" | "neutral" | "watermark";
45
+ className?: string;
46
+ style?: React.CSSProperties;
47
+ onClick?: React.MouseEventHandler;
48
+ };
49
+ export declare function ButtonIcon(props: ButtonIconProps): React.JSX.Element;
50
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const css: string;
2
+ export default css;
@@ -0,0 +1 @@
1
+ export declare function getHtmlProps(props: any): {};
@@ -0,0 +1,2 @@
1
+ export * from './Button';
2
+ export { Button as default } from './Button';
package/dist/index.js ADDED
@@ -0,0 +1,166 @@
1
+ import e from "react";
2
+ import { Icon as t, IconSize as n } from "@jointhedots/icon";
3
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ //#region \0rolldown/runtime.js
5
+ var a = Object.create, o = Object.defineProperty, s = Object.getOwnPropertyDescriptor, c = Object.getOwnPropertyNames, l = Object.getPrototypeOf, u = Object.prototype.hasOwnProperty, d = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), f = (e, t, n, r) => {
6
+ if (t && typeof t == "object" || typeof t == "function") for (var i = c(t), a = 0, l = i.length, d; a < l; a++) d = i[a], !u.call(e, d) && d !== n && o(e, d, {
7
+ get: ((e) => t[e]).bind(null, d),
8
+ enumerable: !(r = s(t, d)) || r.enumerable
9
+ });
10
+ return e;
11
+ }, p = (e, t, n) => (n = e == null ? {} : a(l(e)), f(t || !e || !e.__esModule || !u.call(e, "default") ? o(n, "default", {
12
+ value: e,
13
+ enumerable: !0
14
+ }) : n, e));
15
+ //#endregion
16
+ //#region packages/button/src/inject-styles.ts
17
+ function m(e, t) {
18
+ if (typeof document > "u" || document.getElementById(t)) return;
19
+ let n = document.createElement("style");
20
+ n.id = t, n.textContent = e, document.head.appendChild(n);
21
+ }
22
+ //#endregion
23
+ //#region packages/button/src/generated/styles.ts
24
+ var h = ".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-xs{width:20px;height:20px}.jtd-button.jtd-button--icon.jtd-button--icon-sm{width:24px;height:24px}.jtd-button.jtd-button--icon.jtd-button--icon-lg{width:40px;height:40px}.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-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)}", g = /* @__PURE__ */ p((/* @__PURE__ */ d(((e, t) => {
25
+ (function() {
26
+ var e = {}.hasOwnProperty;
27
+ function n() {
28
+ for (var e = "", t = 0; t < arguments.length; t++) {
29
+ var n = arguments[t];
30
+ n && (e = i(e, r(n)));
31
+ }
32
+ return e;
33
+ }
34
+ function r(t) {
35
+ if (typeof t == "string" || typeof t == "number") return t;
36
+ if (typeof t != "object") return "";
37
+ if (Array.isArray(t)) return n.apply(null, t);
38
+ if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) return t.toString();
39
+ var r = "";
40
+ for (var a in t) e.call(t, a) && t[a] && (r = i(r, a));
41
+ return r;
42
+ }
43
+ function i(e, t) {
44
+ return t ? e ? e + " " + t : e + t : e;
45
+ }
46
+ t !== void 0 && t.exports ? (n.default = n, t.exports = n) : typeof define == "function" && typeof define.amd == "object" && define.amd ? define("classnames", [], function() {
47
+ return n;
48
+ }) : window.classNames = n;
49
+ })();
50
+ })))(), 1), _ = /* @__PURE__ */ new Set([
51
+ "form",
52
+ "formAction",
53
+ "formEncType",
54
+ "formMethod",
55
+ "formNoValidate",
56
+ "formTarget"
57
+ ]);
58
+ function v(e) {
59
+ return Object.keys(e).reduce((t, n) => ((_.has(n) || n.startsWith("aria-") || n.startsWith("data-")) && (t[n] = e[n]), t), {});
60
+ }
61
+ //#endregion
62
+ //#region packages/button/src/Button.tsx
63
+ var y = {
64
+ disabled: !1,
65
+ hint: !1,
66
+ responsive: !1,
67
+ type: "button",
68
+ variant: "neutral"
69
+ };
70
+ function b(e) {
71
+ let n = {
72
+ ...y,
73
+ ...e
74
+ }, a = () => {
75
+ let e = n.variant === "icon", { iconVariant: t } = n, r = t === "border";
76
+ return t === "global-header" && (t = "container"), (0, g.default)("jtd-button", {
77
+ "jtd-button--link": n.variant === "link",
78
+ [`jtd-button--${n.variant}`]: !e && n.variant !== "base" && n.variant !== "link" && !n.inverse && !t,
79
+ "jtd-button--inverse": n.inverse && !e,
80
+ "jtd-button--icon": e,
81
+ [`jtd-button--icon-${t}`]: e && t && t !== "bare",
82
+ "jtd-button--icon-inverse": n.inverse && e && !r,
83
+ "jtd-button--icon-border-inverse": n.inverse && e && r,
84
+ [`jtd-button--icon-${n.iconSize}`]: e && t && n.iconSize && n.iconSize !== "md"
85
+ }, n.className);
86
+ }, o = (e) => {
87
+ n.onClick && n.onClick(e, {});
88
+ }, s = (e) => {
89
+ let i = !n.iconSize || n.iconVariant ? null : n.iconSize;
90
+ return /* @__PURE__ */ r(t, {
91
+ name: e,
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", {
96
+ "aria-label": l,
97
+ className: a(),
98
+ disabled: n.disabled,
99
+ id: n.id,
100
+ onBlur: n.onBlur,
101
+ onClick: o,
102
+ onFocus: n.onFocus,
103
+ onKeyDown: n.onKeyDown,
104
+ onKeyPress: n.onKeyPress,
105
+ onKeyUp: n.onKeyUp,
106
+ onMouseDown: n.onMouseDown,
107
+ onMouseEnter: n.onMouseEnter,
108
+ onMouseLeave: n.onMouseLeave,
109
+ onMouseUp: n.onMouseUp,
110
+ ref: (e) => {
111
+ n.buttonRef && n.buttonRef(e), e && n.requestFocus && n.onRequestFocus && n.onRequestFocus(e);
112
+ },
113
+ title: n.title,
114
+ type: n.type || "button",
115
+ style: n.style,
116
+ ...v(n),
117
+ children: [
118
+ n.iconPosition === "right" ? c() : null,
119
+ n.icon ? s(n.icon || "") : null,
120
+ n.iconPosition === "left" || !n.iconPosition ? c() : null,
121
+ n.children
122
+ ]
123
+ });
124
+ return n.tooltip ? /* @__PURE__ */ i("span", {
125
+ className: "jtd-tooltip",
126
+ children: [u(), /* @__PURE__ */ r("span", {
127
+ className: "jtd-tooltip__content",
128
+ role: "tooltip",
129
+ children: n.tooltip
130
+ })]
131
+ }) : u();
132
+ }
133
+ function x(i) {
134
+ let { icon: a, hoveredIcon: o, size: s, inversed: c, variant: l, className: u, style: d, ...f } = i, p = l ? `jtd-button-icon ${l}` : "jtd-button-icon", m = u ? p + " " + u : p, h = s ? {
135
+ ...d,
136
+ fontSize: s && (n[s] || s)
137
+ } : d;
138
+ if (o) {
139
+ let [n, i] = e.useState(!1);
140
+ return /* @__PURE__ */ r("div", {
141
+ ...f,
142
+ className: m,
143
+ style: h,
144
+ onMouseEnter: () => i(!0),
145
+ onMouseLeave: () => i(!1),
146
+ children: /* @__PURE__ */ r(t, {
147
+ name: n ? o : a,
148
+ inverse: c
149
+ })
150
+ });
151
+ }
152
+ return /* @__PURE__ */ r("div", {
153
+ ...f,
154
+ className: m,
155
+ style: h,
156
+ children: /* @__PURE__ */ r(t, {
157
+ name: a,
158
+ inverse: c
159
+ })
160
+ });
161
+ }
162
+ //#endregion
163
+ //#region packages/button/src/index.ts
164
+ m(h, "jtd-button-styles");
165
+ //#endregion
166
+ export { b as Button, b as default, x as ButtonIcon };
@@ -0,0 +1 @@
1
+ export declare function injectStyles(css: string, id: string): void;
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@jointhedots/button",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Join.The.Dots buttons — Button with variants and icon-only ButtonIcon",
7
+ "sideEffects": true,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "@jointhedots/icon": "^0.1.1",
19
+ "classnames": "^2.5.1"
20
+ },
21
+ "peerDependencies": {
22
+ "react": ">=18.2.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/react": "^19.2.0",
26
+ "react": "^19.2.0",
27
+ "typescript": "~5.9.3",
28
+ "vite": "^8.2.2",
29
+ "vite-plugin-dts": "^5.0.3"
30
+ },
31
+ "scripts": {
32
+ "build": "vite build"
33
+ }
34
+ }