ikoneme-lib 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/README.md +252 -0
- package/dist/Ikon.d.ts +13 -0
- package/dist/IkonEditor.d.ts +9 -0
- package/dist/IkonZoomView.d.ts +6 -0
- package/dist/Ikoneme.d.ts +32 -0
- package/dist/ikonDb.d.ts +13 -0
- package/dist/ikonSchema.d.ts +101 -0
- package/dist/ikoneme-lib.cjs +41 -0
- package/dist/ikoneme-lib.cjs.map +1 -0
- package/dist/ikoneme-lib.js +1884 -0
- package/dist/ikoneme-lib.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/theme.d.ts +11 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# ikoneme-lib
|
|
2
|
+
|
|
3
|
+
React components to render and edit **ikonemes** — ordered sequences of **ikons**
|
|
4
|
+
("rich icons" / "super icons") — using the same rich JSON payload produced by
|
|
5
|
+
the KomunIKON NLP pipeline and consumed by [ikonchat](../ikonchat).
|
|
6
|
+
|
|
7
|
+
This package has no server-side logic of its own: it is a pure rendering/editing
|
|
8
|
+
layer over the ikon JSON payload. The goal is for ikonchat (and any other
|
|
9
|
+
messaging UI) to depend on this library instead of carrying its own copy of the
|
|
10
|
+
rich-icon rendering code.
|
|
11
|
+
|
|
12
|
+
## Concepts
|
|
13
|
+
|
|
14
|
+
- **Ikon** — a single rich icon: a 6x6 grid of zones (`context`, `reference`,
|
|
15
|
+
`role`, `modes`, `root`, `tenses`) plus a grammatical `border`.
|
|
16
|
+
- **Ikoneme** — an ordered list of ikons, e.g. one per word/concept extracted
|
|
17
|
+
from a sentence. This is what you render in a chat bubble.
|
|
18
|
+
|
|
19
|
+
### JSON payload
|
|
20
|
+
|
|
21
|
+
An ikoneme is a plain array of ikon objects:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
"context": { "name": "Male", "url": "https://.../KomunIKON_Male.svg" },
|
|
27
|
+
"reference": {
|
|
28
|
+
"left": null,
|
|
29
|
+
"right": { "name": "Two", "url": "https://.../KomunIKON_Two.svg" }
|
|
30
|
+
},
|
|
31
|
+
"role": { "name": "agent", "url": "https://.../KomunIKON_agent.svg" },
|
|
32
|
+
"modes": { "name": "Exclam", "url": "https://.../KomunIKON_Exclam.svg" },
|
|
33
|
+
"root": { "name": "Love/Passion", "url": "https://.../ZFcaar88AP.png" },
|
|
34
|
+
"rootName": "Love/Passion",
|
|
35
|
+
"tenses": { "name": "as", "url": "https://.../KomunIKON_Verbal_Tense_as.svg" },
|
|
36
|
+
"border": "verb"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This is **exactly** the shape ikonchat stores per message (`message.richIcons`).
|
|
42
|
+
Any extra fields (e.g. a `metadata` block from the NLP pipeline) are preserved
|
|
43
|
+
untouched by `normalizeIkon`/`normalizeIkoneme`.
|
|
44
|
+
|
|
45
|
+
It also maps directly onto the NLP "Rich Icon Output Specification" vocabulary:
|
|
46
|
+
|
|
47
|
+
| This library / ikonchat | NLP spec |
|
|
48
|
+
| ------------------------------------- | ------------- |
|
|
49
|
+
| `context` | `gender` |
|
|
50
|
+
| `modes` | `mode` |
|
|
51
|
+
| `tenses` | `time-tenses` |
|
|
52
|
+
| `reference`, `role`, `root`, `border` | same name |
|
|
53
|
+
|
|
54
|
+
## Components
|
|
55
|
+
|
|
56
|
+
### `<Ikoneme>`
|
|
57
|
+
|
|
58
|
+
The main component. Renders a row of ikons for one message.
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
import { Ikoneme } from 'ikoneme-lib'
|
|
62
|
+
|
|
63
|
+
// Read-only, for a chat/messaging timeline
|
|
64
|
+
<Ikoneme ikons={message.richIcons} mode="view" size={64} />
|
|
65
|
+
|
|
66
|
+
// Editable: adds hover/tap edit + delete buttons on each ikon and opens
|
|
67
|
+
// the full ikon editor. `onChange` receives the updated ikoneme array.
|
|
68
|
+
<Ikoneme
|
|
69
|
+
ikons={message.richIcons}
|
|
70
|
+
mode="edit"
|
|
71
|
+
size={64}
|
|
72
|
+
onChange={(nextIkons) => updateMessage(message.id, nextIkons)}
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Props:
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Default | Notes |
|
|
79
|
+
| -------------------- | -------------------------------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `ikons` | `Array<Ikon>` | `[]` | The ikoneme payload. |
|
|
81
|
+
| `mode` | `'view' \| 'edit'` | `'view'` | `'edit'` shows per-ikon edit/delete controls and the editor modal. |
|
|
82
|
+
| `size` | `number` | `64` | Pixel size of each ikon. |
|
|
83
|
+
| `gap` | `number` | `6` | Pixel gap between ikons. |
|
|
84
|
+
| `onChange` | `(nextIkons) => void` | — | Called after an edit is saved or an ikon is deleted. Required for edit/delete to do anything — the component is otherwise controlled. |
|
|
85
|
+
| `onIkonClick` | `(ikon, index) => void` | — | Click handler in `view` mode only (e.g. show original source text). Fires independently of `zoom`. |
|
|
86
|
+
| `zoom` | `boolean` | `true` | `true`: clicking any ikon (in either mode) opens a large read-only view of it. `false`: the click is ignored for zoom purposes (`onIkonClick` still fires as usual). |
|
|
87
|
+
| `zoomSize` | `number` | `320` | Pixel size of the ikon inside the zoomed view (clamped to fit the viewport). |
|
|
88
|
+
| `searchRoot` | `(query) => Promise<{id?,name,url}[]>` | IkonDB (public) | Overrides the root-icon search backend used by the editor. Default: `defaultSearchRoot`, which searches the public [IkonDB](https://ikondb.iigap.com/api/docs) icon database (full list fetched once and cached for an hour; matched client-side by name). On select, the editor fetches that icon's fuller media set (`svg`/`thumb`/`preview`) via `GET /api/ikons/{id}`. |
|
|
89
|
+
| `theme` | `object` | — | Override any `--ikoneme-*` CSS custom property (see Theming). |
|
|
90
|
+
| `className`, `style` | | | Passed to the wrapper element. |
|
|
91
|
+
|
|
92
|
+
### `<Ikon>` and `<IkonEditor>`
|
|
93
|
+
|
|
94
|
+
Lower-level building blocks, exported for advanced use:
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
import { Ikon, IkonEditor } from 'ikoneme-lib'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- `<Ikon ikon={...} size={64} onClick={...} />` — renders a single ikon. The
|
|
101
|
+
grammatical border's thickness scales with `size` (roughly `size / 40`, min
|
|
102
|
+
2px) so it stays legible both tiny in a chat bubble and large in a zoomed view.
|
|
103
|
+
- `<IkonEditor ikon={...} onSave={...} onClose={...} searchRoot={...} />` —
|
|
104
|
+
the full-screen zone editor for one ikon.
|
|
105
|
+
- `<IkonZoomView ikon={...} size={320} onClose={...} />` — the read-only
|
|
106
|
+
"lightbox" view `<Ikoneme zoom>` opens on click; exported in case you want
|
|
107
|
+
to trigger it yourself.
|
|
108
|
+
|
|
109
|
+
### Schema utilities
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
import {
|
|
113
|
+
ZONE_CONFIG,
|
|
114
|
+
BORDER_CONFIG,
|
|
115
|
+
createDefaultIkon,
|
|
116
|
+
normalizeIkon,
|
|
117
|
+
normalizeIkoneme,
|
|
118
|
+
generateIkonemeFromText
|
|
119
|
+
} from 'ikoneme-lib'
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- `normalizeIkoneme(ikons)` — upgrades any legacy/URL-only stored payloads to
|
|
123
|
+
the `{ name, url }` shape. Run this on data loaded from storage/an API
|
|
124
|
+
before rendering.
|
|
125
|
+
- `generateIkonemeFromText(text)` — deterministic placeholder generator
|
|
126
|
+
(hash-based), useful for demos/tests until real NLP output is wired in.
|
|
127
|
+
|
|
128
|
+
### IkonDB helpers
|
|
129
|
+
|
|
130
|
+
The public [IkonDB](https://ikondb.iigap.com/api/docs) client backing the
|
|
131
|
+
default root search, exported for reuse:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
import { searchIkons, getIkonDetails, getIkonList, IKONDB_BASE_URL } from 'ikoneme-lib'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- `searchIkons(query, { limit })` — `{ id, name, url }[]`, matched by name
|
|
138
|
+
against the full list (fetched once, cached for an hour).
|
|
139
|
+
- `getIkonDetails(id)` — `{ id, name, url, origin, preview, thumb, svg }` for one
|
|
140
|
+
icon (cached per id), or `null` if it does not exist.
|
|
141
|
+
- `getIkonList()` — the whole cached list.
|
|
142
|
+
- `clearIkonDbCache()` — drops the in-memory caches.
|
|
143
|
+
|
|
144
|
+
Icons whose IkonDB record has no image are omitted from search results.
|
|
145
|
+
|
|
146
|
+
## Theming
|
|
147
|
+
|
|
148
|
+
Components read colors from `--ikoneme-*` CSS custom properties and ship with
|
|
149
|
+
sensible dark-mode defaults, so nothing else is required to use them. To match
|
|
150
|
+
your app's palette, pass a `theme` override:
|
|
151
|
+
|
|
152
|
+
```jsx
|
|
153
|
+
<Ikoneme
|
|
154
|
+
ikons={ikons}
|
|
155
|
+
theme={{
|
|
156
|
+
'--ikoneme-primary': '#00a884',
|
|
157
|
+
'--ikoneme-background': '#0c0e12',
|
|
158
|
+
'--ikoneme-panel-bg': '#181b20',
|
|
159
|
+
'--ikoneme-surface': '#080a0e',
|
|
160
|
+
'--ikoneme-border': '#2a2e36',
|
|
161
|
+
'--ikoneme-text-primary': '#e9edef',
|
|
162
|
+
'--ikoneme-text-secondary': '#8696a0',
|
|
163
|
+
'--ikoneme-hover': '#2a2e36'
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Building
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm install
|
|
172
|
+
npm run build # outputs dist/ikoneme-lib.js (ESM) and dist/ikoneme-lib.cjs (CJS)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Using this library in another project (local, no registry)
|
|
176
|
+
|
|
177
|
+
This package is not published to npm/a registry. Pick one of the following to
|
|
178
|
+
consume it locally.
|
|
179
|
+
|
|
180
|
+
### Option A — `file:` dependency (recommended)
|
|
181
|
+
|
|
182
|
+
1. Build a tarball from this repo:
|
|
183
|
+
```bash
|
|
184
|
+
cd ikoneme-lib
|
|
185
|
+
npm install
|
|
186
|
+
npm run build
|
|
187
|
+
npm pack # produces ikoneme-lib-<version>.tgz
|
|
188
|
+
```
|
|
189
|
+
2. In the consuming project (e.g. ikonchat), add it as a dependency pointing
|
|
190
|
+
at the tarball (adjust the relative path to wherever you placed it):
|
|
191
|
+
```bash
|
|
192
|
+
npm install ../ikoneme-lib/ikoneme-lib-0.1.0.tgz
|
|
193
|
+
```
|
|
194
|
+
This writes a `"ikoneme-lib": "file:../ikoneme-lib/ikoneme-lib-0.1.0.tgz"`
|
|
195
|
+
entry to the consumer's `package.json` and copies/extracts the packed
|
|
196
|
+
`dist/` into `node_modules` — no symlink, so it behaves like a real
|
|
197
|
+
registry install (safe for CI/Docker builds too, as long as the tarball
|
|
198
|
+
path is available at install time).
|
|
199
|
+
3. Re-run steps 1–2 whenever you change the library and want the consumer to
|
|
200
|
+
pick up the new build.
|
|
201
|
+
|
|
202
|
+
### Option B — `npm link` (fastest for active local development)
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
cd ikoneme-lib
|
|
206
|
+
npm install
|
|
207
|
+
npm run build
|
|
208
|
+
npm link
|
|
209
|
+
|
|
210
|
+
cd ../ikonchat
|
|
211
|
+
npm link ikoneme-lib
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
This symlinks `ikoneme-lib` into the consumer's `node_modules`, so rebuilding
|
|
215
|
+
the library (`npm run build`) is immediately visible to the consumer without
|
|
216
|
+
reinstalling. Undo with `npm unlink ikoneme-lib` in the consumer and
|
|
217
|
+
`npm unlink` in this repo.
|
|
218
|
+
|
|
219
|
+
### Option C — local npm registry (Verdaccio)
|
|
220
|
+
|
|
221
|
+
For multi-developer/team setups where `file:`/`link:` paths are inconvenient,
|
|
222
|
+
run a local registry and publish there instead of to the public npm registry:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
npx verdaccio # starts a registry on http://localhost:4873
|
|
226
|
+
npm publish --registry http://localhost:4873
|
|
227
|
+
# in the consumer:
|
|
228
|
+
npm install ikoneme-lib --registry http://localhost:4873
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Example app
|
|
232
|
+
|
|
233
|
+
`example/` is a minimal Vite + React app that installs this library via the
|
|
234
|
+
`file:` tarball approach (Option A) and renders an ikoneme in both `view` and
|
|
235
|
+
`edit` mode. Use it to sanity-check changes before wiring the library into
|
|
236
|
+
ikonchat:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
npm run build && npm pack --pack-destination ./example
|
|
240
|
+
cd example
|
|
241
|
+
npm install
|
|
242
|
+
npm run dev
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Next step
|
|
246
|
+
|
|
247
|
+
`ikonchat` currently has its own copies of this rendering/editing logic
|
|
248
|
+
(`app/components/RichIcon.jsx`, `RichIconEditor.jsx`,
|
|
249
|
+
`app/utils/richIconMapping.js`). The follow-up work is to delete those and
|
|
250
|
+
replace their usages (`ChatWindow.jsx`, etc.) with `<Ikoneme>` from this
|
|
251
|
+
package, keeping ikonchat's own responsibility limited to chat/business logic
|
|
252
|
+
(messages, contacts, backend sync) rather than ikon rendering.
|
package/dist/Ikon.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default Ikon;
|
|
2
|
+
declare function Ikon({ ikon, onClick, size, onZoneClick, selectedZone, isSelected, isPaired, onEdit, onDelete, hideActionOverlay }: {
|
|
3
|
+
ikon: any;
|
|
4
|
+
onClick: any;
|
|
5
|
+
size?: number;
|
|
6
|
+
onZoneClick: any;
|
|
7
|
+
selectedZone: any;
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
isPaired?: boolean;
|
|
10
|
+
onEdit: any;
|
|
11
|
+
onDelete: any;
|
|
12
|
+
hideActionOverlay?: boolean;
|
|
13
|
+
}): any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defaultSearchRoot } from './ikonDb';
|
|
2
|
+
export { defaultSearchRoot };
|
|
3
|
+
export default IkonEditor;
|
|
4
|
+
declare function IkonEditor({ ikon, onSave, onClose, searchRoot }: {
|
|
5
|
+
ikon: any;
|
|
6
|
+
onSave: any;
|
|
7
|
+
onClose: any;
|
|
8
|
+
searchRoot?: typeof defaultSearchRoot;
|
|
9
|
+
}): any;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default Ikoneme;
|
|
2
|
+
/**
|
|
3
|
+
* Renders an ikoneme — an ordered list of ikons — from its rich JSON payload,
|
|
4
|
+
* exactly as produced by the KomunIKON NLP pipeline / used in ikonchat:
|
|
5
|
+
*
|
|
6
|
+
* [{ context, reference: { left, right }, role, modes, root, rootName, tenses, border }, ...]
|
|
7
|
+
*
|
|
8
|
+
* Two modes:
|
|
9
|
+
* - "view" (default): read-only rendering, suitable for a chat/messaging timeline.
|
|
10
|
+
* - "edit": adds hover/tap edit & delete controls per ikon and opens the full
|
|
11
|
+
* ikon editor on edit, calling `onChange` with the updated ikoneme.
|
|
12
|
+
*
|
|
13
|
+
* Zoom: when `zoom` is true (default), clicking any ikon opens a large,
|
|
14
|
+
* read-only view of it — independent of `mode` and of `onIkonClick`. When
|
|
15
|
+
* `zoom` is false, clicking an ikon does nothing by itself (the click is
|
|
16
|
+
* ignored for zoom purposes; `onIkonClick`, if provided, still fires in
|
|
17
|
+
* "view" mode).
|
|
18
|
+
*/
|
|
19
|
+
declare function Ikoneme({ ikons, mode, size, gap, zoom, zoomSize, onChange, onIkonClick, searchRoot, theme, className, style }: {
|
|
20
|
+
ikons?: any[];
|
|
21
|
+
mode?: string;
|
|
22
|
+
size?: number;
|
|
23
|
+
gap?: number;
|
|
24
|
+
zoom?: boolean;
|
|
25
|
+
zoomSize?: number;
|
|
26
|
+
onChange: any;
|
|
27
|
+
onIkonClick: any;
|
|
28
|
+
searchRoot: any;
|
|
29
|
+
theme: any;
|
|
30
|
+
className: any;
|
|
31
|
+
style: any;
|
|
32
|
+
}): any;
|
package/dist/ikonDb.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function getIkonList({ baseUrl }?: {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
}): Promise<any>;
|
|
4
|
+
export function searchIkons(query: any, { baseUrl, limit }?: {
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
limit?: number;
|
|
7
|
+
}): Promise<any[]>;
|
|
8
|
+
export function getIkonDetails(id: any, { baseUrl }?: {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
}): Promise<any>;
|
|
11
|
+
export function defaultSearchRoot(query: any): Promise<any[]>;
|
|
12
|
+
export function clearIkonDbCache(): void;
|
|
13
|
+
export const IKONDB_BASE_URL: "https://ikondb.iigap.com";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export function getBorderConfig(borderId: any): {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
color: string;
|
|
5
|
+
plural: boolean;
|
|
6
|
+
};
|
|
7
|
+
export function getIconConfig(zone: any, url: any): any;
|
|
8
|
+
export function getIconUrlByIndex(zone: any, index: any): any;
|
|
9
|
+
export function getIconUrl(value: any): any;
|
|
10
|
+
export function getIconDisplayUrl(value: any): any;
|
|
11
|
+
export function createDefaultIkon(): {
|
|
12
|
+
context: {
|
|
13
|
+
name: any;
|
|
14
|
+
url: any;
|
|
15
|
+
};
|
|
16
|
+
reference: {
|
|
17
|
+
left: any;
|
|
18
|
+
right: any;
|
|
19
|
+
};
|
|
20
|
+
role: {
|
|
21
|
+
name: any;
|
|
22
|
+
url: any;
|
|
23
|
+
};
|
|
24
|
+
modes: {
|
|
25
|
+
name: any;
|
|
26
|
+
url: any;
|
|
27
|
+
};
|
|
28
|
+
root: {
|
|
29
|
+
name: any;
|
|
30
|
+
url: any;
|
|
31
|
+
};
|
|
32
|
+
rootName: any;
|
|
33
|
+
tenses: {
|
|
34
|
+
name: any;
|
|
35
|
+
url: any;
|
|
36
|
+
};
|
|
37
|
+
border: any;
|
|
38
|
+
};
|
|
39
|
+
export function normalizeIkon(icon: any): any;
|
|
40
|
+
export function normalizeIkoneme(ikons: any): any;
|
|
41
|
+
export function generateIkonemeFromText(text: any): {
|
|
42
|
+
context: {
|
|
43
|
+
name: any;
|
|
44
|
+
url: any;
|
|
45
|
+
};
|
|
46
|
+
reference: {
|
|
47
|
+
left: any;
|
|
48
|
+
right: any;
|
|
49
|
+
};
|
|
50
|
+
role: {
|
|
51
|
+
name: any;
|
|
52
|
+
url: any;
|
|
53
|
+
};
|
|
54
|
+
modes: {
|
|
55
|
+
name: any;
|
|
56
|
+
url: any;
|
|
57
|
+
};
|
|
58
|
+
root: {
|
|
59
|
+
name: any;
|
|
60
|
+
url: any;
|
|
61
|
+
};
|
|
62
|
+
rootName: any;
|
|
63
|
+
tenses: {
|
|
64
|
+
name: any;
|
|
65
|
+
url: any;
|
|
66
|
+
};
|
|
67
|
+
border: any;
|
|
68
|
+
}[];
|
|
69
|
+
export namespace ZONE_CONFIG {
|
|
70
|
+
let context: {
|
|
71
|
+
tooltip: string;
|
|
72
|
+
url: string;
|
|
73
|
+
}[];
|
|
74
|
+
let reference: {
|
|
75
|
+
tooltip: string;
|
|
76
|
+
url: string;
|
|
77
|
+
}[];
|
|
78
|
+
let role: {
|
|
79
|
+
tooltip: string;
|
|
80
|
+
url: string;
|
|
81
|
+
}[];
|
|
82
|
+
let modes: {
|
|
83
|
+
tooltip: string;
|
|
84
|
+
url: string;
|
|
85
|
+
}[];
|
|
86
|
+
let root: {
|
|
87
|
+
tooltip: string;
|
|
88
|
+
url: string;
|
|
89
|
+
}[];
|
|
90
|
+
let tenses: {
|
|
91
|
+
tooltip: string;
|
|
92
|
+
url: string;
|
|
93
|
+
}[];
|
|
94
|
+
}
|
|
95
|
+
export const BORDER_CONFIG: {
|
|
96
|
+
id: string;
|
|
97
|
+
label: string;
|
|
98
|
+
color: string;
|
|
99
|
+
plural: boolean;
|
|
100
|
+
}[];
|
|
101
|
+
export const BORDER_IDS: string[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),S=require("react");/**
|
|
2
|
+
* @license lucide-react v0.294.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/var je={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
7
|
+
* @license lucide-react v0.294.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Ie=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),W=(e,n)=>{const s=S.forwardRef(({color:r="currentColor",size:i=24,strokeWidth:p=2,absoluteStrokeWidth:c,className:w="",children:f,..._},T)=>S.createElement("svg",{ref:T,...je,width:i,height:i,stroke:r,strokeWidth:c?Number(p)*24/Number(i):p,className:["lucide",`lucide-${Ie(e)}`,w].join(" "),..._},[...n.map(([j,b])=>S.createElement(j,b)),...Array.isArray(f)?f:[f]]));return s.displayName=`${e}`,s};/**
|
|
12
|
+
* @license lucide-react v0.294.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Se=W("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
17
|
+
* @license lucide-react v0.294.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const _e=W("Pen",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}]]);/**
|
|
22
|
+
* @license lucide-react v0.294.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Ne=W("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
27
|
+
* @license lucide-react v0.294.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Te=W("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
32
|
+
* @license lucide-react v0.294.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Ke=W("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),g={context:[{tooltip:"Male",url:"https://text2ikon.komunikon.com/gender-assets/KomunIKON_Male.svg"},{tooltip:"Female",url:"https://text2ikon.komunikon.com/gender-assets/KomunIKON_Female.svg"},{tooltip:"Non Binary",url:"https://text2ikon.komunikon.com/gender-assets/KomunIKON_Non-Binary.png"}],reference:[{tooltip:"Asterisk",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_asterisk.svg"},{tooltip:"Zero",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Zero.svg"},{tooltip:"One",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_One.svg"},{tooltip:"Two",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Two.svg"},{tooltip:"Three",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Three.svg"},{tooltip:"Four",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Four.svg"},{tooltip:"Five",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Five.svg"},{tooltip:"Six",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Six.svg"},{tooltip:"Seven",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Seven.svg"},{tooltip:"Eight",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Eight.svg"},{tooltip:"Nine",url:"https://text2ikon.komunikon.com/reference-assets/KomunIKON_Nine.svg"}],role:[{tooltip:"agent",url:"https://text2ikon.komunikon.com/case-assets/KomunIKON_agent.svg"},{tooltip:"patient",url:"https://text2ikon.komunikon.com/case-assets/KomunIKON_patient.svg"},{tooltip:"reflexive",url:"https://text2ikon.komunikon.com/case-assets/KomunIKON_reflexive.svg"},{tooltip:"recipricol",url:"https://text2ikon.komunikon.com/_next/image?url=%2Fcase-assets%2Frecipricol.jpg&w=48&q=75"}],modes:[{tooltip:"Exclam",url:"https://text2ikon.komunikon.com/mode-assets/KomunIKON_Exclam.svg"},{tooltip:"Which",url:"https://text2ikon.komunikon.com/mode-assets/KomunIKON_Which.svg"}],root:[{tooltip:"Love/Passion",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2FZFcaar88AP.png&w=128&q=75"},{tooltip:"Star/Excellence",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2FM0ADaSXzWe.png&w=128&q=75"},{tooltip:"Value/Precious",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2F6ghAUKbdIs.png&w=128&q=75"},{tooltip:"Fire/Hot",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2Fzq0n4vHSQW.png&w=128&q=75"},{tooltip:"Water/Fluid",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2FDVhDIm6KqB.png&w=128&q=75"},{tooltip:"Flower/Beauty",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2FUnpCfhHsUa.png&w=128&q=75"},{tooltip:"Leaf/Nature",url:"https://text2ikon.komunikon.com/_next/image?url=https%3A%2F%2Fikondb.komunikon.com%2Fuploads%2Fimages%2Ficons%2F5Ex6my6BI7.png&w=128&q=75"}],tenses:[{tooltip:"adas",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_adas.svg"},{tooltip:"adis",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_adis.svg"},{tooltip:"ados",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_ados.svg"},{tooltip:"antas",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_antas.svg"},{tooltip:"antis",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_antis.svg"},{tooltip:"antos",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_antos.svg"},{tooltip:"as",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_as.svg"},{tooltip:"intas",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_intas.svg"},{tooltip:"intis",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_intis.svg"},{tooltip:"intis2",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_intis2.svg"},{tooltip:"intos",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_intos.svg"},{tooltip:"intos2",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_intos2.svg"},{tooltip:"is",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_is.svg"},{tooltip:"ontas",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_ontas.svg"},{tooltip:"ontis",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_ontis.svg"},{tooltip:"ontis2",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_ontis2.svg"},{tooltip:"ontos",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_ontos.svg"},{tooltip:"ontos2",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_ontos2.svg"},{tooltip:"os",url:"https://text2ikon.komunikon.com/time-assets/KomunIKON_Verbal_Tense_os.svg"}]},B=[{id:"name",label:"Name",color:"#60a5fa",plural:!1},{id:"verb",label:"Verb",color:"#f87171",plural:!1},{id:"adjective",label:"Adjective",color:"#4ade80",plural:!1},{id:"adverb",label:"Adverb",color:"#fb923c",plural:!1},{id:"conjunction",label:"Conjunction",color:"#a78bfa",plural:!1},{id:"neutral",label:"Neutral",color:"#94a3b8",plural:!1},{id:"name_plural",label:"Name (plural)",color:"#60a5fa",plural:!0},{id:"verb_plural",label:"Verb (plural)",color:"#f87171",plural:!0},{id:"adjective_plural",label:"Adjective (plural)",color:"#4ade80",plural:!0},{id:"adverb_plural",label:"Adverb (plural)",color:"#fb923c",plural:!0},{id:"conjunction_plural",label:"Conjunction (plural)",color:"#a78bfa",plural:!0},{id:"neutral_plural",label:"Neutral (plural)",color:"#94a3b8",plural:!0}],ne=B.map(e=>e.id),Re=new Set(ne);function re(e){return B.find(n=>n.id===e)??null}function K(e,n){var s;return(s=g[e])==null?void 0:s.find(r=>r.url===n)}function Ce(e,n){var s,r;return(r=(s=g[e])==null?void 0:s[n])==null?void 0:r.url}function N(e){return e==null?null:typeof e=="object"&&"url"in e?e.url:e}function ie(e){return e==null?null:typeof e=="object"?e.svg||e.url||null:e}function k(e){return{name:e.tooltip,url:e.url}}function P(){return{context:k(g.context[0]),reference:{left:null,right:null},role:k(g.role[0]),modes:k(g.modes[0]),root:k(g.root[0]),rootName:null,tenses:k(g.tenses[0]),border:null}}function se(e){var f,_,T,j,b,m,I;if(!e)return e;const n=e.reference||{left:null,right:null},s=typeof e.context=="string"?K("context",e.context):null,r=typeof e.role=="string"?K("role",e.role):null,i=typeof e.modes=="string"?K("modes",e.modes):null,p=typeof e.root=="string"?K("root",e.root):null,c=typeof e.tenses=="string"?K("tenses",e.tenses):null,w=e.border!=null&&Re.has(e.border)?e.border:null;return{...e,context:typeof e.context=="object"&&((f=e.context)==null?void 0:f.url)!=null?e.context:s?k(s):{name:"",url:e.context||""},reference:{left:n.left==null?null:typeof n.left=="object"&&((_=n.left)==null?void 0:_.url)!=null?n.left:K("reference",n.left)?k(K("reference",n.left)):{name:"",url:n.left},right:n.right==null?null:typeof n.right=="object"&&((T=n.right)==null?void 0:T.url)!=null?n.right:K("reference",n.right)?k(K("reference",n.right)):{name:"",url:n.right}},role:typeof e.role=="object"&&((j=e.role)==null?void 0:j.url)!=null?e.role:r?k(r):{name:"",url:e.role||""},modes:typeof e.modes=="object"&&((b=e.modes)==null?void 0:b.url)!=null?e.modes:i?k(i):{name:"",url:e.modes||""},root:typeof e.root=="object"&&((m=e.root)==null?void 0:m.url)!=null?{...e.root,name:e.rootName??e.root.name}:p?{name:e.rootName??p.tooltip,url:p.url}:{name:e.rootName??"",url:e.root||""},tenses:typeof e.tenses=="object"&&((I=e.tenses)==null?void 0:I.url)!=null?e.tenses:c?k(c):{name:"",url:e.tenses||""},border:w}}function Ee(e){return(e||[]).map(se)}function $e(e){let n=0;for(let s=0;s<e.length;s++){const r=e.charCodeAt(s);n=(n<<5)-n+r,n=n&n}return Math.abs(n)}class Fe{constructor(n){this.seed=n}next(){const r=Math.pow(2,32);return this.seed=(1664525*this.seed+1013904223)%r,this.seed/r}nextInt(n,s){return Math.floor(this.next()*(s-n))+n}}function Me(e){const n=e.toLowerCase().split(/\s+/).filter(Boolean),s=[];for(const r of n){const i={...P()},p=$e(r),c=new Fe(p);i.context=k(g.context[c.nextInt(0,g.context.length)]);const w=c.next()>.5,f=c.nextInt(1,g.reference.length);i.reference={left:w?k(g.reference[0]):null,right:k(g.reference[f])},i.role=k(g.role[c.nextInt(0,g.role.length)]),i.modes=k(g.modes[c.nextInt(0,g.modes.length)]),i.root=k(g.root[c.nextInt(0,g.root.length)]),i.tenses=k(g.tenses[c.nextInt(0,g.tenses.length)]);const _=B.filter(T=>!T.plural);i.border=_[c.nextInt(0,_.length)].id,s.push(i)}return s.length>0?s:[P()]}const q={maxWidth:"100%",maxHeight:"100%",width:"100%",height:"100%",objectFit:"contain",display:"block",boxSizing:"border-box"},oe=e=>({display:"flex",alignItems:"center",justifyContent:"center",minWidth:0,minHeight:0,overflow:"hidden",boxSizing:"border-box",padding:`${e}px`});function Oe(e=768){const[n,s]=S.useState(()=>typeof window<"u"&&window.innerWidth<e);return S.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),i=()=>s(r.matches);return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),n}function H({ikon:e,onClick:n,size:s=64,onZoneClick:r,selectedZone:i,isSelected:p=!1,isPaired:c=!1,onEdit:w,onDelete:f,hideActionOverlay:_=!1}){var ee,te;const[T,j]=S.useState(!1),b=Oe(),m=e!=null&&e.border?re(e.border):null,I=(a,C)=>{r?(C.stopPropagation(),r(a)):n&&n(C)},R=a=>{r&&(a.currentTarget.style.filter="brightness(1.3)")},y=a=>{r&&(a.currentTarget.style.filter="brightness(1)")},E=(a,C)=>{const L=i===a;return{boxSizing:"border-box",...C,cursor:r||n?"pointer":"default",transition:"all 0.2s, filter 0.2s",border:L?"2px solid var(--ikoneme-primary)":C.border||"none",boxShadow:L?"0 0 8px var(--ikoneme-primary)":"none",position:"relative"}},$=(a,C)=>{const L=ie(C);if(!L)return null;const U=K(a,N(C)),ve=C&&typeof C=="object"&&C.name||(U==null?void 0:U.tooltip)||a;return t.jsx("img",{src:L,alt:ve,style:q,onError:we=>{we.target.style.display="none"}})},o=!_&&!r&&(w||f),l=b?28:24,u=4,d=3*l+2*u,x=o?d:s,h=b||T,v=x,F=Math.max(2,Math.round(v/40)),xe=Math.max(2,Math.round(v/44)),M=Math.max(2,Math.round(v/72)),ge=Math.max(2,Math.round(v/40)),G=1.18,Z=`minmax(0, ${G}fr) repeat(4, minmax(0, ${.95}fr)) minmax(0, ${G}fr)`,he="minmax(0, 0.6fr) minmax(0, 1.4fr) minmax(0, 1.4fr) minmax(0, 0.6fr)",fe=m?{border:`${F}px solid ${m.color}`}:{border:p&&!c?"2px solid rgba(0, 168, 132, 0.8)":"1px solid rgba(255, 255, 255, 0.1)"},X=m!=null&&m.plural?{boxShadow:[`inset -${F}px 0 0 ${m.color}`,`inset -${F*2}px 0 0 ${m.color}`,`inset -${F*3}px 0 0 ${m.color}`,`inset 0 -${F}px 0 ${m.color}`,`inset 0 -${F*2}px 0 ${m.color}`,`inset 0 -${F*3}px 0 ${m.color}`].join(", ")}:{},ke=p&&!c?"rgba(0, 168, 132, 0.15)":"white",Q=m&&!m.plural?X.boxShadow:null,Y=[p&&!c?"0 0 12px rgba(0, 168, 132, 0.4)":null,i==="border"?"0 0 0 3px var(--ikoneme-primary)":null,Q].filter(Boolean).join(", "),be=["0 0 10px rgba(0, 168, 132, 0.5)",Q].filter(Boolean).join(", "),J=t.jsxs(t.Fragment,{children:[t.jsxs("div",{onClick:r?()=>r("border"):n?a=>n(a):void 0,style:{width:`${v}px`,height:`${v}px`,boxSizing:"border-box",display:"grid",padding:`${xe}px`,gridTemplateColumns:Z,gridTemplateRows:Z,cursor:n||r?"pointer":"default",borderRadius:"4px",overflow:"hidden",flexShrink:0,transition:"transform 0.2s, box-shadow 0.2s, border 0.2s",background:ke,boxShadow:Y,...fe},onMouseEnter:a=>{n&&!r&&!c&&(a.currentTarget.style.transform="scale(1.05)",p||(a.currentTarget.style.boxShadow=be))},onMouseLeave:a=>{n&&!r&&!c&&(a.currentTarget.style.transform="scale(1)",p||(a.currentTarget.style.boxShadow=Y))},children:[t.jsx("div",{onClick:a=>I("context",a),onMouseEnter:R,onMouseLeave:y,style:E("context",{gridColumn:"1 / 2",gridRow:"1 / 2",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(100, 50, 150, 0.1)",borderRight:"1px solid rgba(0, 0, 0, 0.14)",borderBottom:"1px solid rgba(0, 0, 0, 0.14)",minWidth:0,minHeight:0,overflow:"hidden",padding:`${M}px`}),className:"ikoneme-zone",children:$("context",e.context)}),t.jsxs("div",{onClick:a=>I("reference",a),onMouseEnter:R,onMouseLeave:y,style:E("reference",{gridColumn:"2 / 6",gridRow:"1 / 2",display:"grid",gridTemplateColumns:he,gridTemplateRows:"minmax(0, 1fr)",background:"rgba(50, 100, 200, 0.1)",borderRight:"1px solid rgba(0, 0, 0, 0.14)",borderBottom:"1px solid rgba(0, 0, 0, 0.14)",minWidth:0,minHeight:0,overflow:"hidden"}),className:"ikoneme-zone",children:[t.jsx("div",{style:{minWidth:0,minHeight:0,overflow:"hidden",borderRight:"1px solid rgba(0, 0, 0, 0.14)"}}),t.jsx("div",{style:{...oe(M),borderRight:"1px solid rgba(0, 0, 0, 0.14)"},children:N((ee=e.reference)==null?void 0:ee.left)&&t.jsx("img",{src:N(e.reference.left),alt:"Asterisk",style:q,onError:a=>{a.target.style.display="none"}})}),t.jsx("div",{style:{...oe(M),borderRight:"1px solid rgba(0, 0, 0, 0.14)"},children:N((te=e.reference)==null?void 0:te.right)&&t.jsx("img",{src:N(e.reference.right),alt:"Number",style:q,onError:a=>{a.target.style.display="none"}})}),t.jsx("div",{style:{minWidth:0,minHeight:0,overflow:"hidden"}})]}),t.jsx("div",{onClick:a=>I("role",a),onMouseEnter:R,onMouseLeave:y,style:E("role",{gridColumn:"6 / 7",gridRow:"1 / 2",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(200, 50, 50, 0.1)",borderBottom:"1px solid rgba(0, 0, 0, 0.14)",minWidth:0,minHeight:0,overflow:"hidden",padding:`${M}px`}),className:"ikoneme-zone",children:$("role",e.role)}),t.jsx("div",{onClick:a=>I("modes",a),onMouseEnter:R,onMouseLeave:y,style:E("modes",{gridColumn:"1 / 2",gridRow:"2 / 6",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(50, 150, 100, 0.1)",borderRight:"1px solid rgba(0, 0, 0, 0.14)",borderBottom:"1px solid rgba(0, 0, 0, 0.14)",minWidth:0,minHeight:0,overflow:"hidden",padding:`${M}px`}),className:"ikoneme-zone",children:$("modes",e.modes)}),t.jsx("div",{onClick:a=>I("root",a),onMouseEnter:R,onMouseLeave:y,style:E("root",{gridColumn:"2 / 6",gridRow:"2 / 6",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(150, 150, 50, 0.1)",borderRight:"1px solid rgba(0, 0, 0, 0.14)",borderBottom:"1px solid rgba(0, 0, 0, 0.14)",minWidth:0,minHeight:0,overflow:"hidden",padding:`${ge}px`}),className:"ikoneme-zone",children:$("root",e.root)}),t.jsx("div",{onClick:a=>{r&&(a.stopPropagation(),r("border"))},style:{gridColumn:"6 / 7",gridRow:"2 / 6",background:"rgba(0, 0, 0, 0.05)",borderBottom:"1px solid rgba(0, 0, 0, 0.14)",minWidth:0,minHeight:0,overflow:"hidden",boxSizing:"border-box",cursor:r?"pointer":"default"}}),t.jsx("div",{onClick:a=>I("tenses",a),onMouseEnter:R,onMouseLeave:y,style:E("tenses",{gridColumn:"1 / 7",gridRow:"6 / 7",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(100, 100, 200, 0.1)",minWidth:0,minHeight:0,overflow:"hidden",padding:`${M}px`}),className:"ikoneme-zone",children:$("tenses",e.tenses)})]}),(m==null?void 0:m.plural)&&t.jsx("div",{"aria-hidden":!0,style:{position:"absolute",top:0,left:0,right:0,bottom:0,width:`${v}px`,height:`${v}px`,borderRadius:"4px",pointerEvents:"none",...X}})]}),ye=t.jsx("div",{style:{minHeight:`${l}px`,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},"aria-hidden":!h,children:t.jsxs("div",{style:{display:"flex",gap:`${u}px`,flexWrap:"nowrap",width:`${d}px`,justifyContent:"center",opacity:h?1:0,pointerEvents:h?"auto":"none",transition:"opacity 0.15s ease"},children:[w&&t.jsx("button",{onClick:a=>{a.stopPropagation(),w()},style:{width:`${l}px`,height:`${l}px`,borderRadius:"6px",border:"none",background:"rgba(0, 168, 132, 0.95)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.3)"},onMouseEnter:a=>a.currentTarget.style.background="rgba(0, 168, 132, 1)",onMouseLeave:a=>a.currentTarget.style.background="rgba(0, 168, 132, 0.95)",title:"Edit",children:t.jsx(_e,{size:b?16:14,color:"white"})}),f&&t.jsx("button",{onClick:a=>{a.stopPropagation(),f()},style:{width:`${l}px`,height:`${l}px`,borderRadius:"6px",border:"none",background:"rgba(220, 38, 38, 0.95)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.3)"},onMouseEnter:a=>a.currentTarget.style.background="rgba(220, 38, 38, 1)",onMouseLeave:a=>a.currentTarget.style.background="rgba(220, 38, 38, 0.95)",title:"Delete",children:t.jsx(Te,{size:b?16:14,color:"white"})})]})});return o?t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:`${d}px`,flexShrink:0,gap:"6px"},onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),children:[t.jsx("div",{style:{position:"relative",width:`${v}px`,height:`${v}px`},children:J}),ye]}):t.jsx("div",{style:{position:"relative",width:`${s}px`,height:`${s}px`,flexShrink:0},onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),children:J})}const V="https://ikondb.iigap.com",Be=60*60*1e3;let z=null,O=null;const A=new Map;function Le(e){return!e||Array.isArray(e)?null:e.origin||e.preview||e.thumb||e.svg||null}function ze(e){if(!e||Array.isArray(e))return{};const{origin:n=null,preview:s=null,thumb:r=null,svg:i=null}=e;return{origin:n,preview:s,thumb:r,svg:i}}async function Ae(e){const n=await fetch(`${e}/api/ikons`);if(!n.ok)throw new Error(`IkonDB GET /api/ikons -> ${n.status}`);const s=await n.json();return(Array.isArray(s==null?void 0:s.data)?s.data:[]).map(i=>({id:i.id,name:i.description||"",url:Le(i.media)})).filter(i=>i.url)}async function le({baseUrl:e=V}={}){return z&&Date.now()-z.at<Be?z.list:O||(O=Ae(e).then(n=>(z={at:Date.now(),list:n},n)).finally(()=>{O=null}),O)}async function ae(e,{baseUrl:n=V,limit:s=20}={}){const r=(e||"").trim().toLowerCase();if(!r)return[];const i=await le({baseUrl:n}),p=[];for(const c of i)if(c.name.toLowerCase().includes(r)&&(p.push(c),p.length>=s))break;return p}async function ce(e,{baseUrl:n=V}={}){if(e==null)return null;if(A.has(e))return A.get(e);const s=await fetch(`${n}/api/ikons/${encodeURIComponent(e)}`);if(!s.ok)throw new Error(`IkonDB GET /api/ikons/${e} -> ${s.status}`);const r=await s.json();if((r==null?void 0:r.status)!=="success"||!(r!=null&&r.data))return A.set(e,null),null;const i=ze(r.data.media),p={id:r.data.id,name:r.data.description||"",url:i.origin||i.preview||i.thumb||i.svg||null,...i};return A.set(e,p),p}async function de(e){try{return await ae(e)}catch{return[]}}function We(){z=null,O=null,A.clear()}const D={context:{name:"Context",description:"Northwest - Contextual information"},reference:{name:"Reference",description:"North - Reference point"},role:{name:"Role",description:"Northeast - Role indicator"},modes:{name:"Modes",description:"West - Mode settings"},root:{name:"Root",description:"Center - Core meaning"},tenses:{name:"Tenses",description:"South - Time/tense indicator"},border:{name:"Border",description:"Grammatical category — singular (one border) or plural (stacked borders)"}},De=1,He=300,Ve=10,Ue=5;function ue({ikon:e,onSave:n,onClose:s,searchRoot:r=de}){const[i,p]=S.useState({...e,reference:e.reference?{...e.reference}:{left:null,right:null},rootName:e.rootName??null}),[c,w]=S.useState("root"),[f,_]=S.useState(""),[T,j]=S.useState([]),[b,m]=S.useState(!1),I=(o,l)=>{const u=K(o==="reference"?"reference":o,l),d=u?{name:u.tooltip,url:u.url}:{name:"",url:l};if(o==="reference"){const x=g.reference[0].url;p(l===x?h=>{var v;return{...h,reference:{...h.reference,left:N((v=h.reference)==null?void 0:v.left)===x?null:{name:g.reference[0].tooltip,url:x}}}}:h=>{var v;return{...h,reference:{...h.reference,right:N((v=h.reference)==null?void 0:v.right)===l?null:d}}})}else p(x=>({...x,[o]:N(x[o])===l?null:d}))},R=o=>{w(o)},y=o=>{p(l=>({...l,border:o==null||l.border===o?null:o}))};S.useEffect(()=>{if(c!=="root"||f.length<De){j([]);return}const o=setTimeout(async()=>{m(!0);try{const l=await r(f.trim());j((l||[]).slice(0,Ve))}catch{j([])}finally{m(!1)}},He);return()=>clearTimeout(o)},[c,f,r]);const E=S.useCallback(async o=>{if(p(l=>({...l,root:{id:o.id??null,name:o.name,url:o.url},rootName:o.name})),o.id!=null)try{const l=await ce(o.id);if(!l)return;p(u=>{var d;return((d=u.root)==null?void 0:d.id)!==o.id?u:{...u,root:{id:l.id,name:o.name,url:l.origin||o.url,svg:l.svg||void 0,thumb:l.thumb||void 0,preview:l.preview||void 0},rootName:o.name}})}catch{}},[]),$=()=>{n(i),s()};return t.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"var(--ikoneme-background)",display:"flex",flexDirection:"column",zIndex:1e3,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"16px 20px",background:"var(--ikoneme-panel-bg)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[t.jsx("button",{onClick:s,style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center"},title:"Back",children:t.jsx(Se,{color:"var(--ikoneme-text-primary)",size:24})}),t.jsx("h2",{style:{color:"var(--ikoneme-text-primary)",fontSize:"clamp(18px, 4vw, 20px)",fontWeight:"600",margin:0},children:"Edit Ikon"})]}),t.jsx("button",{onClick:$,style:{padding:"10px 24px",background:"var(--ikoneme-primary)",border:"none",borderRadius:"8px",color:"white",cursor:"pointer",fontSize:"clamp(13px, 3vw, 14px)",fontWeight:"500",transition:"background 0.2s",whiteSpace:"nowrap"},onMouseEnter:o=>o.currentTarget.style.background="var(--ikoneme-primary-dark)",onMouseLeave:o=>o.currentTarget.style.background="var(--ikoneme-primary)",children:"Save"})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px",maxWidth:"800px",width:"100%",margin:"0 auto",WebkitOverflowScrolling:"touch"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"24px",gap:"12px"},children:[t.jsx("p",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"clamp(12px, 3vw, 13px)",textAlign:"center"},children:"Click on a zone or the border area to edit it"}),t.jsx(H,{ikon:i,size:280,onZoneClick:R,selectedZone:c}),t.jsx("div",{style:{color:"var(--ikoneme-text-primary)",fontSize:"clamp(14px, 3.5vw, 16px)",fontWeight:"500",textAlign:"center",padding:"8px 16px",background:"var(--ikoneme-primary)",borderRadius:"20px"},children:D[c].name})]}),t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("h3",{style:{color:"var(--ikoneme-text-primary)",fontSize:"clamp(14px, 3.5vw, 16px)",marginBottom:"8px",fontWeight:"500"},children:c==="border"?"Select Border Type":"Choose Icon for: "+D[c].name}),c==="border"?t.jsxs("p",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"clamp(11px, 2.5vw, 12px)",marginBottom:"12px"},children:[D.border.description,". Click the same border again to clear."]}):c==="reference"?t.jsxs("p",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"clamp(11px, 2.5vw, 12px)",marginBottom:"12px"},children:["Click ",t.jsx("strong",{children:"Asterisk"})," to toggle left cell. Click any ",t.jsx("strong",{children:"number"})," ","to toggle right cell."]}):c==="root"?t.jsx("p",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"clamp(11px, 2.5vw, 12px)",marginBottom:"12px"},children:"Search for an icon below. The icon's name is stored with the ikon."}):t.jsxs("p",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"clamp(11px, 2.5vw, 12px)",marginBottom:"12px"},children:[D[c].description,". Click the same icon again to clear."]}),c==="border"?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginBottom:"12px"},children:t.jsx("button",{onClick:()=>y(null),style:{width:"100%",padding:"10px 14px",background:i.border==null?"var(--ikoneme-primary)":"var(--ikoneme-surface)",border:`2px solid ${i.border==null?"var(--ikoneme-primary-dark)":"var(--ikoneme-border)"}`,borderRadius:"8px",color:i.border==null?"white":"var(--ikoneme-text-primary)",fontSize:"14px",cursor:"pointer",textAlign:"left",fontWeight:i.border==null?"600":"400",transition:"all 0.2s"},children:"No border"})}),t.jsx("div",{style:{marginBottom:"8px"},children:t.jsx("span",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"12px",fontWeight:"600"},children:"Singular"})}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"10px",marginBottom:"16px"},children:B.filter(o=>!o.plural).map(o=>{const l=i.border===o.id;return t.jsxs("button",{onClick:()=>y(o.id),title:o.label,style:{padding:"8px",background:l?"var(--ikoneme-primary)":"var(--ikoneme-surface)",border:`2px solid ${l?"var(--ikoneme-primary-dark)":"var(--ikoneme-border)"}`,borderRadius:"8px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",transition:"all 0.2s",position:"relative"},onMouseEnter:d=>{l||(d.currentTarget.style.background="var(--ikoneme-hover)")},onMouseLeave:d=>{l||(d.currentTarget.style.background="var(--ikoneme-surface)")},children:[t.jsx("div",{style:{border:`5px solid ${o.color}`,borderRadius:"4px",width:"64px",height:"64px",flexShrink:0}}),t.jsx("span",{style:{fontSize:"11px",color:l?"white":"var(--ikoneme-text-primary)",fontWeight:l?"600":"400"},children:o.label}),t.jsx("div",{className:"ikon-tooltip",style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,0.95)",color:"white",padding:"6px 10px",borderRadius:"6px",fontSize:"11px",whiteSpace:"nowrap",opacity:0,pointerEvents:"none",transition:"opacity 0.2s",marginBottom:"8px",zIndex:100},children:o.label})]},o.id)})}),t.jsx("div",{style:{marginBottom:"8px"},children:t.jsx("span",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"12px",fontWeight:"600"},children:"Plural"})}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"10px"},children:B.filter(o=>o.plural).map(o=>{const l=i.border===o.id,u=5,d={boxShadow:[`inset -${u}px 0 0 ${o.color}`,`inset -${u*2}px 0 0 ${o.color}`,`inset -${u*3}px 0 0 ${o.color}`,`inset 0 -${u}px 0 ${o.color}`,`inset 0 -${u*2}px 0 ${o.color}`,`inset 0 -${u*3}px 0 ${o.color}`].join(", ")};return t.jsxs("button",{onClick:()=>y(o.id),title:o.label,style:{padding:"8px",background:l?"var(--ikoneme-primary)":"var(--ikoneme-surface)",border:`2px solid ${l?"var(--ikoneme-primary-dark)":"var(--ikoneme-border)"}`,borderRadius:"8px",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",transition:"all 0.2s",position:"relative"},onMouseEnter:x=>{l||(x.currentTarget.style.background="var(--ikoneme-hover)")},onMouseLeave:x=>{l||(x.currentTarget.style.background="var(--ikoneme-surface)")},children:[t.jsx("div",{style:{border:`${u}px solid ${o.color}`,borderRadius:"4px",width:"64px",height:"64px",flexShrink:0,...d}}),t.jsx("span",{style:{fontSize:"11px",color:l?"white":"var(--ikoneme-text-primary)",fontWeight:l?"600":"400"},children:o.label}),t.jsx("div",{className:"ikon-tooltip",style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,0.95)",color:"white",padding:"6px 10px",borderRadius:"6px",fontSize:"11px",whiteSpace:"nowrap",opacity:0,pointerEvents:"none",transition:"opacity 0.2s",marginBottom:"8px",zIndex:100},children:o.label})]},o.id)})})]}):c==="root"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px",padding:"10px 12px",background:"var(--ikoneme-surface)",borderRadius:"8px",border:"1px solid var(--ikoneme-border)"},children:[t.jsx(Ne,{size:18,color:"var(--ikoneme-text-secondary)"}),t.jsx("input",{type:"text",value:f,onChange:o=>_(o.target.value),placeholder:"Search icons...",style:{flex:1,border:"none",background:"transparent",color:"var(--ikoneme-text-primary)",fontSize:"14px",outline:"none"}})]}),b&&t.jsx("p",{style:{color:"var(--ikoneme-text-secondary)",fontSize:"13px",marginBottom:"12px"},children:"Searching…"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${Ue}, 1fr)`,gap:"10px"},children:T.map((o,l)=>{const u=N(i.root)===o.url;return t.jsxs("button",{onClick:()=>E(o),title:o.name,style:{padding:"12px",background:u?"var(--ikoneme-primary)":"var(--ikoneme-surface)",border:"2px solid",borderColor:u?"var(--ikoneme-primary-dark)":"var(--ikoneme-border)",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",aspectRatio:"1",position:"relative",minHeight:"70px",minWidth:"70px"},onMouseEnter:d=>{d.currentTarget.style.transform="scale(1.05)",u||(d.currentTarget.style.background="var(--ikoneme-hover)")},onMouseLeave:d=>{d.currentTarget.style.transform="scale(1)",u||(d.currentTarget.style.background="var(--ikoneme-surface)")},children:[t.jsx("div",{style:{width:"100%",height:"100%",background:"white",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",padding:"4px"},children:t.jsx("img",{src:o.url,alt:o.name,style:{maxWidth:"100%",maxHeight:"100%",width:"100%",height:"100%",objectFit:"contain"},onError:d=>{d.target.style.display="none"}})}),t.jsx("div",{className:"ikon-tooltip",style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",background:"rgba(0, 0, 0, 0.95)",color:"white",padding:"6px 10px",borderRadius:"6px",fontSize:"11px",whiteSpace:"nowrap",opacity:0,pointerEvents:"none",transition:"opacity 0.2s",marginBottom:"8px",zIndex:100},children:o.name})]},`${o.url}-${l}`)})})]}):t.jsx("div",{style:{display:"grid",gridTemplateColumns:g[c].length<=3?"repeat(3, 1fr)":"repeat(auto-fit, minmax(90px, 1fr))",gap:"10px"},children:g[c].map((o,l)=>{var d,x;let u=!1;if(c==="reference"){const h=g.reference[0].url;o.url===h?u=N((d=i.reference)==null?void 0:d.left)===h:u=N((x=i.reference)==null?void 0:x.right)===o.url}else u=N(i[c])===o.url;return t.jsxs("button",{onClick:()=>I(c,o.url),title:o.tooltip,style:{padding:"12px",background:u?"var(--ikoneme-primary)":"var(--ikoneme-surface)",border:"2px solid",borderColor:u?"var(--ikoneme-primary-dark)":"var(--ikoneme-border)",borderRadius:"8px",cursor:"pointer",transition:"all 0.2s",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",aspectRatio:"1",position:"relative",minHeight:"70px",minWidth:"70px"},onMouseEnter:h=>{h.currentTarget.style.transform="scale(1.05)",u||(h.currentTarget.style.background="var(--ikoneme-hover)")},onMouseLeave:h=>{h.currentTarget.style.transform="scale(1)",u||(h.currentTarget.style.background="var(--ikoneme-surface)")},children:[t.jsx("div",{style:{width:"100%",height:"100%",background:"white",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",padding:"4px"},children:t.jsx("img",{src:o.url,alt:o.tooltip,style:{maxWidth:"100%",maxHeight:"100%",width:"100%",height:"100%",objectFit:"contain"}})}),t.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",background:"rgba(0, 0, 0, 0.95)",color:"white",padding:"6px 10px",borderRadius:"6px",fontSize:"11px",whiteSpace:"nowrap",opacity:0,pointerEvents:"none",transition:"opacity 0.2s",marginBottom:"8px",zIndex:100},className:"ikon-tooltip",children:o.tooltip})]},l)})})]}),t.jsx("style",{children:`
|
|
37
|
+
button:hover .ikon-tooltip {
|
|
38
|
+
opacity: 1 !important;
|
|
39
|
+
}
|
|
40
|
+
`})]})]})}function pe({ikon:e,size:n=320,onClose:s}){const r=typeof window<"u"?Math.max(120,Math.min(n,window.innerWidth-48,window.innerHeight-156)):n;return t.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Zoomed ikon",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px"},children:t.jsxs("div",{onClick:i=>i.stopPropagation(),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"32px",maxWidth:"100%"},children:[t.jsx(H,{ikon:e,size:r}),t.jsx("button",{onClick:s,style:{width:"40px",height:"40px",borderRadius:"50%",border:"none",background:"var(--ikoneme-panel-bg)",color:"var(--ikoneme-text-primary)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},title:"Close","aria-label":"Close",children:t.jsx(Ke,{size:20})})]})})}const me={"--ikoneme-primary":"#00a884","--ikoneme-primary-dark":"#008069","--ikoneme-background":"#0c0e12","--ikoneme-panel-bg":"#181b20","--ikoneme-surface":"#080a0e","--ikoneme-border":"#2a2e36","--ikoneme-text-primary":"#e9edef","--ikoneme-text-secondary":"#8696a0","--ikoneme-hover":"#2a2e36"};function qe({ikons:e=[],mode:n="view",size:s=64,gap:r=6,zoom:i=!0,zoomSize:p=320,onChange:c,onIkonClick:w,searchRoot:f,theme:_,className:T,style:j}){const[b,m]=S.useState(null),[I,R]=S.useState(null),y=n==="edit",E=d=>{c&&c(e.filter((x,h)=>h!==d))},$=d=>{b!=null&&c&&c(e.map((x,h)=>h===b?d:x)),m(null)},o=(d,x)=>{!y&&w&&w(d,x),i&&R(x)},l={...me,..._},u=i||!y&&!!w;return t.jsxs("div",{className:["ikoneme",T].filter(Boolean).join(" "),style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:`${r}px`,...l,...j},children:[e.map((d,x)=>t.jsx(H,{ikon:d,size:s,onClick:u?()=>o(d,x):void 0,onEdit:y?()=>m(x):void 0,onDelete:y&&c?()=>E(x):void 0},x)),y&&b!=null&&e[b]&&t.jsx("div",{style:l,children:t.jsx(ue,{ikon:e[b],searchRoot:f,onSave:$,onClose:()=>m(null)})}),i&&I!=null&&e[I]&&t.jsx("div",{style:l,children:t.jsx(pe,{ikon:e[I],size:p,onClose:()=>R(null)})})]})}exports.BORDER_CONFIG=B;exports.BORDER_IDS=ne;exports.DEFAULT_THEME=me;exports.IKONDB_BASE_URL=V;exports.Ikon=H;exports.IkonEditor=ue;exports.IkonZoomView=pe;exports.Ikoneme=qe;exports.ZONE_CONFIG=g;exports.clearIkonDbCache=We;exports.createDefaultIkon=P;exports.defaultSearchRoot=de;exports.generateIkonemeFromText=Me;exports.getBorderConfig=re;exports.getIconConfig=K;exports.getIconDisplayUrl=ie;exports.getIconUrl=N;exports.getIconUrlByIndex=Ce;exports.getIkonDetails=ce;exports.getIkonList=le;exports.normalizeIkon=se;exports.normalizeIkoneme=Ee;exports.searchIkons=ae;
|
|
41
|
+
//# sourceMappingURL=ikoneme-lib.cjs.map
|