@jointhedots/input 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,42 @@
1
+ # @jointhedots/input
2
+
3
+ Champs de saisie Join.The.Dots : `InputData`, piloté par un schéma JSON
4
+ (string, enum, textarea, nombre, booléen), et `TextInputSchema`, le
5
+ constructeur du schéma d'un champ texte typé. Le tooling d'un champ suit le
6
+ modèle d'items de @jointhedots/layout (`ToolingProps`), et le déroulant d'une
7
+ énumération est un menu flottant de lignes d'items.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pnpm add @jointhedots/input
13
+ ```
14
+
15
+ Peer dependency : `react` ≥ 18.2.0. Dépend de `@jointhedots/core` pour le
16
+ type `JSONSchema`, de `@jointhedots/icon` pour les glyphes et de
17
+ `@jointhedots/layout` pour le modèle d'items et les menus flottants.
18
+
19
+ ## Usage
20
+
21
+ ```tsx
22
+ import { InputData, TextInputSchema } from "@jointhedots/input"
23
+
24
+ <InputData
25
+ value={value}
26
+ schema={{ type: "string", enum: ["small", "medium"] }}
27
+ icon="utility:settings"
28
+ tooling={[{ name: "Reset", icon: "bi:arrow-clockwise", onActivate: reset }]}
29
+ onChange={setValue}
30
+ />
31
+
32
+ <InputData
33
+ label="API token"
34
+ value={token}
35
+ schema={TextInputSchema("paste your token", "password")}
36
+ onChange={setToken}
37
+ />
38
+ ```
39
+
40
+ Les styles du package (gabarits `jtd-field*`, `jtd-input`, `jtd-select`)
41
+ sont injectés automatiquement au chargement du module — aucun stylesheet
42
+ à gérer.
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+ import { IconSize } from '../../icon/src/index.ts';
3
+ import { JSONSchema } from '@jointhedots/core';
4
+ import { ToolingProps } from '../../layout/src/index.ts';
5
+ type InputProps = {
6
+ label?: React.ReactNode;
7
+ icon?: string;
8
+ tooling?: ToolingProps[];
9
+ size?: keyof typeof IconSize;
10
+ value: any;
11
+ schema: JSONSchema;
12
+ onChange: (value: any) => void;
13
+ };
14
+ export declare const InputData: React.FC<InputProps>;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ import { HTMLInputTypeAttribute } from 'react';
2
+ import { JSONSchema } from '@jointhedots/core';
3
+ export declare function TextInputSchema(placeholder: string | number, type: HTMLInputTypeAttribute): JSONSchema;
@@ -0,0 +1,2 @@
1
+ declare const css: string;
2
+ export default css;
@@ -0,0 +1,2 @@
1
+ export * from './InputData';
2
+ export * from './TextInputSchema';
package/dist/index.js ADDED
@@ -0,0 +1,99 @@
1
+ import "react";
2
+ import e from "@jointhedots/icon";
3
+ import { DrawToolingWidgets as t, Menu as n, openContextualMenu as r } from "@jointhedots/layout";
4
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
5
+ //#region packages/input/src/inject-styles.ts
6
+ function s(e, t) {
7
+ if (typeof document > "u" || document.getElementById(t)) return;
8
+ let n = document.createElement("style");
9
+ n.id = t, n.textContent = e, document.head.appendChild(n);
10
+ }
11
+ //#endregion
12
+ //#region packages/input/src/generated/styles.ts
13
+ var c = ".jtd-field{display:flex;flex-direction:column;gap:4px;min-width:0}.jtd-field-label{color:var(--jtd-muted);font-size:12px}.jtd-field-control{display:flex;align-items:center;gap:6px;min-height:32px;padding:3px 10px;background-color:var(--jtd-surface);border:1px solid var(--jtd-border);border-radius:5px;transition:border-color 120ms ease}.jtd-field-control:focus-within{border-color:var(--jtd-primary)}.jtd-field-icon{display:flex;flex:none;color:var(--jtd-muted)}.jtd-input{flex:1;min-width:0;align-self:stretch;padding:0;border:none;background:none;outline:none;font:inherit;color:var(--jtd-foreground)}.jtd-input::placeholder{color:var(--jtd-muted)}.jtd-input:disabled{opacity:.45}textarea.jtd-input{align-self:auto;min-height:60px;padding:5px 0;resize:vertical}.jtd-checkbox{width:16px;height:16px;margin:8px 0;accent-color:var(--jtd-primary);cursor:pointer}.jtd-checkbox:focus-visible{outline:2px solid var(--jtd-primary);outline-offset:2px}.jtd-field-tooling{display:flex;flex:none;gap:2px}.jtd-select{display:flex;align-items:center;justify-content:space-between;gap:6px;cursor:pointer;text-align:left}.jtd-select-caret{flex:none;color:var(--jtd-muted)}.jtd-field--xs{font-size:12px;gap:2px}.jtd-field--xs>.jtd-field-label{font-size:10px}.jtd-field--xs>.jtd-field-control{min-height:18px;padding:1px 6px;gap:3px;border-radius:4px}.jtd-field--xs .jtd-checkbox{width:12px;height:12px;margin:2px 0}.jtd-field--sm{font-size:13px}.jtd-field--sm>.jtd-field-control{min-height:24px;padding:2px 9px}.jtd-field--sm .jtd-checkbox{width:14px;height:14px;margin:4px 0}.jtd-field--lg{font-size:15px}.jtd-field--lg>.jtd-field-control{min-height:40px;padding:5px 12px}.jtd-field--lg .jtd-checkbox{width:18px;height:18px;margin:10px 0}", l = ({ value: s, onChange: c, schema: l, icon: u, label: d, tooling: f, size: p = "md" }) => {
14
+ let m = p === "md" ? "jtd-field" : `jtd-field jtd-field--${p}`, h = (e) => {
15
+ let t = l.type, n = e.target.value;
16
+ (t === "number" || t === "integer") && (n = Number(n)), c(n);
17
+ }, g = (e) => {
18
+ e.stopPropagation(), r(e, (e) => /* @__PURE__ */ a(i, { children: l.enum.map((t) => /* @__PURE__ */ a(n.Item, {
19
+ name: t,
20
+ icon: t === s ? "bi:check-lg" : "blank",
21
+ onClick: () => e(t)
22
+ }, t)) }), { position: "down-left" }).then((e) => {
23
+ e !== void 0 && c(e);
24
+ });
25
+ };
26
+ return l.type === "boolean" ? /* @__PURE__ */ o("div", {
27
+ className: m,
28
+ children: [d ? /* @__PURE__ */ a("span", {
29
+ className: "jtd-field-label",
30
+ children: d
31
+ }) : null, /* @__PURE__ */ a("input", {
32
+ type: "checkbox",
33
+ className: "jtd-checkbox",
34
+ checked: s,
35
+ onChange: (e) => c(e.target.checked)
36
+ })]
37
+ }) : /* @__PURE__ */ o("div", {
38
+ className: m,
39
+ children: [d ? /* @__PURE__ */ a("span", {
40
+ className: "jtd-field-label",
41
+ children: d
42
+ }) : null, /* @__PURE__ */ o("div", {
43
+ className: "jtd-field-control",
44
+ children: [
45
+ u ? /* @__PURE__ */ a(e, {
46
+ className: "jtd-field-icon",
47
+ name: u
48
+ }) : null,
49
+ (() => {
50
+ let t = l.type;
51
+ if (t === "string" && l.enum) return /* @__PURE__ */ o("button", {
52
+ type: "button",
53
+ className: "jtd-input jtd-select",
54
+ onClick: g,
55
+ children: [/* @__PURE__ */ a("span", {
56
+ className: "jtd-select-value",
57
+ children: s
58
+ }), /* @__PURE__ */ a(e, {
59
+ className: "jtd-select-caret",
60
+ name: "bi:chevron-down"
61
+ })]
62
+ });
63
+ if (t === "string" && l.format === "textarea") return /* @__PURE__ */ a("textarea", {
64
+ className: "jtd-input",
65
+ value: s,
66
+ placeholder: l.default,
67
+ onChange: h
68
+ });
69
+ let n = t === "number" || t === "integer" ? "number" : t === "string" && l.format ? l.format : "text";
70
+ return /* @__PURE__ */ a("input", {
71
+ className: "jtd-input",
72
+ type: n,
73
+ value: s,
74
+ placeholder: l.default,
75
+ onChange: h
76
+ });
77
+ })(),
78
+ f && f.length ? /* @__PURE__ */ a("div", {
79
+ className: "jtd-field-tooling",
80
+ children: t(f)
81
+ }) : null
82
+ ]
83
+ })]
84
+ });
85
+ };
86
+ //#endregion
87
+ //#region packages/input/src/TextInputSchema.ts
88
+ function u(e, t) {
89
+ return {
90
+ type: "string",
91
+ format: t,
92
+ default: e
93
+ };
94
+ }
95
+ //#endregion
96
+ //#region packages/input/src/index.ts
97
+ s(c, "jtd-input-styles");
98
+ //#endregion
99
+ export { l as InputData, u as TextInputSchema };
@@ -0,0 +1 @@
1
+ export declare function injectStyles(css: string, id: string): void;
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@jointhedots/input",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Join.The.Dots inputs — schema-driven InputData and the TextInputSchema builder",
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/core": "^2.1.0",
19
+ "@jointhedots/icon": "^0.1.1",
20
+ "@jointhedots/layout": "^0.1.0"
21
+ },
22
+ "peerDependencies": {
23
+ "react": ">=18.2.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/react": "^19.2.0",
27
+ "react": "^19.2.0",
28
+ "typescript": "~5.9.3",
29
+ "vite": "^8.2.2",
30
+ "vite-plugin-dts": "^5.0.3"
31
+ },
32
+ "scripts": {
33
+ "build": "vite build"
34
+ }
35
+ }