@uyghurcommunity/ui 0.0.0-stage → 0.4.1
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 +21 -0
- package/README.md +221 -2
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/assets/flags/east-turkistan.svg +1 -0
- package/assets/icon-catalog.json +1514 -0
- package/assets/icons/almond.svg +1 -0
- package/assets/icons/ancient-ruins.svg +1 -0
- package/assets/icons/apricot.svg +1 -0
- package/assets/icons/archway.svg +1 -0
- package/assets/icons/arrow-down.svg +1 -0
- package/assets/icons/arrow-left.svg +1 -0
- package/assets/icons/arrow-right.svg +1 -0
- package/assets/icons/arrow-up.svg +1 -0
- package/assets/icons/atlas.svg +1 -0
- package/assets/icons/aywan.svg +1 -0
- package/assets/icons/book.svg +1 -0
- package/assets/icons/boots.svg +1 -0
- package/assets/icons/calendar.svg +1 -0
- package/assets/icons/calligraphy.svg +1 -0
- package/assets/icons/camel.svg +1 -0
- package/assets/icons/carpet.svg +1 -0
- package/assets/icons/carved-door.svg +1 -0
- package/assets/icons/ceramic-vase.svg +1 -0
- package/assets/icons/chapan.svg +1 -0
- package/assets/icons/check-circle.svg +1 -0
- package/assets/icons/check.svg +1 -0
- package/assets/icons/chevron-down.svg +1 -0
- package/assets/icons/chevron-left.svg +1 -0
- package/assets/icons/chevron-right.svg +1 -0
- package/assets/icons/chevron-up.svg +1 -0
- package/assets/icons/city-gate.svg +1 -0
- package/assets/icons/close.svg +1 -0
- package/assets/icons/code.svg +1 -0
- package/assets/icons/color/almond.svg +1 -0
- package/assets/icons/color/ancient-ruins.svg +1 -0
- package/assets/icons/color/apricot.svg +1 -0
- package/assets/icons/color/archway.svg +1 -0
- package/assets/icons/color/atlas.svg +1 -0
- package/assets/icons/color/aywan.svg +1 -0
- package/assets/icons/color/boots.svg +1 -0
- package/assets/icons/color/calligraphy.svg +1 -0
- package/assets/icons/color/camel.svg +1 -0
- package/assets/icons/color/carpet.svg +1 -0
- package/assets/icons/color/carved-door.svg +1 -0
- package/assets/icons/color/ceramic-vase.svg +1 -0
- package/assets/icons/color/chapan.svg +1 -0
- package/assets/icons/color/city-gate.svg +1 -0
- package/assets/icons/color/cotton.svg +1 -0
- package/assets/icons/color/crescent.svg +1 -0
- package/assets/icons/color/dap.svg +1 -0
- package/assets/icons/color/doppa-top.svg +1 -0
- package/assets/icons/color/doppa.svg +1 -0
- package/assets/icons/color/dove.svg +1 -0
- package/assets/icons/color/dutar.svg +1 -0
- package/assets/icons/color/embroidery.svg +1 -0
- package/assets/icons/color/floral-rosette.svg +1 -0
- package/assets/icons/color/flower.svg +1 -0
- package/assets/icons/color/fur-hat.svg +1 -0
- package/assets/icons/color/ghijek.svg +1 -0
- package/assets/icons/color/grapes.svg +1 -0
- package/assets/icons/color/horse.svg +1 -0
- package/assets/icons/color/jewelry.svg +1 -0
- package/assets/icons/color/laghman.svg +1 -0
- package/assets/icons/color/landscape.svg +1 -0
- package/assets/icons/color/lattice-window.svg +1 -0
- package/assets/icons/color/loom.svg +1 -0
- package/assets/icons/color/madrasa.svg +1 -0
- package/assets/icons/color/mausoleum.svg +1 -0
- package/assets/icons/color/melon.svg +1 -0
- package/assets/icons/color/mens-coat.svg +1 -0
- package/assets/icons/color/minaret.svg +1 -0
- package/assets/icons/color/mosque.svg +1 -0
- package/assets/icons/color/nan-stack.svg +1 -0
- package/assets/icons/color/nan.svg +1 -0
- package/assets/icons/color/ornamental-border.svg +1 -0
- package/assets/icons/color/polo.svg +1 -0
- package/assets/icons/color/pomegranate.svg +1 -0
- package/assets/icons/color/rawap.svg +1 -0
- package/assets/icons/color/samsa.svg +1 -0
- package/assets/icons/color/sash.svg +1 -0
- package/assets/icons/color/satar.svg +1 -0
- package/assets/icons/color/spindle.svg +1 -0
- package/assets/icons/color/star-eight.svg +1 -0
- package/assets/icons/color/surnai.svg +1 -0
- package/assets/icons/color/tambur.svg +1 -0
- package/assets/icons/color/tea-bowl.svg +1 -0
- package/assets/icons/color/tea-set.svg +1 -0
- package/assets/icons/color/teapot.svg +1 -0
- package/assets/icons/color/traditional-house.svg +1 -0
- package/assets/icons/color/traditional-shoes.svg +1 -0
- package/assets/icons/color/tree-of-life.svg +1 -0
- package/assets/icons/color/unity.svg +1 -0
- package/assets/icons/color/uyghur-medallion.svg +1 -0
- package/assets/icons/color/womens-dress.svg +1 -0
- package/assets/icons/color/womens-headdress.svg +1 -0
- package/assets/icons/color/yurt.svg +1 -0
- package/assets/icons/copy.svg +1 -0
- package/assets/icons/cotton.svg +1 -0
- package/assets/icons/crescent.svg +1 -0
- package/assets/icons/dap.svg +1 -0
- package/assets/icons/direction-ltr.svg +1 -0
- package/assets/icons/direction-rtl.svg +1 -0
- package/assets/icons/doppa-top.svg +1 -0
- package/assets/icons/doppa.svg +1 -0
- package/assets/icons/dove.svg +1 -0
- package/assets/icons/download.svg +1 -0
- package/assets/icons/dutar.svg +1 -0
- package/assets/icons/edit.svg +1 -0
- package/assets/icons/embroidery.svg +1 -0
- package/assets/icons/external-link.svg +1 -0
- package/assets/icons/floral-rosette.svg +1 -0
- package/assets/icons/flower.svg +1 -0
- package/assets/icons/fur-hat.svg +1 -0
- package/assets/icons/ghijek.svg +1 -0
- package/assets/icons/globe.svg +1 -0
- package/assets/icons/grapes.svg +1 -0
- package/assets/icons/heart.svg +1 -0
- package/assets/icons/home.svg +1 -0
- package/assets/icons/horse.svg +1 -0
- package/assets/icons/image.svg +1 -0
- package/assets/icons/info.svg +1 -0
- package/assets/icons/jewelry.svg +1 -0
- package/assets/icons/keyboard.svg +1 -0
- package/assets/icons/laghman.svg +1 -0
- package/assets/icons/landscape.svg +1 -0
- package/assets/icons/language.svg +1 -0
- package/assets/icons/lattice-window.svg +1 -0
- package/assets/icons/link.svg +1 -0
- package/assets/icons/loom.svg +1 -0
- package/assets/icons/madrasa.svg +1 -0
- package/assets/icons/mail.svg +1 -0
- package/assets/icons/mausoleum.svg +1 -0
- package/assets/icons/melon.svg +1 -0
- package/assets/icons/mens-coat.svg +1 -0
- package/assets/icons/menu.svg +1 -0
- package/assets/icons/minaret.svg +1 -0
- package/assets/icons/minus.svg +1 -0
- package/assets/icons/moon.svg +1 -0
- package/assets/icons/mosque.svg +1 -0
- package/assets/icons/nan-stack.svg +1 -0
- package/assets/icons/nan.svg +1 -0
- package/assets/icons/ornamental-border.svg +1 -0
- package/assets/icons/palette.svg +1 -0
- package/assets/icons/pause.svg +1 -0
- package/assets/icons/play.svg +1 -0
- package/assets/icons/plus.svg +1 -0
- package/assets/icons/polo.svg +1 -0
- package/assets/icons/pomegranate.svg +1 -0
- package/assets/icons/rawap.svg +1 -0
- package/assets/icons/redo.svg +1 -0
- package/assets/icons/samsa.svg +1 -0
- package/assets/icons/sash.svg +1 -0
- package/assets/icons/satar.svg +1 -0
- package/assets/icons/search.svg +1 -0
- package/assets/icons/settings.svg +1 -0
- package/assets/icons/spindle.svg +1 -0
- package/assets/icons/star-eight.svg +1 -0
- package/assets/icons/star.svg +1 -0
- package/assets/icons/sun.svg +1 -0
- package/assets/icons/surnai.svg +1 -0
- package/assets/icons/tambur.svg +1 -0
- package/assets/icons/tea-bowl.svg +1 -0
- package/assets/icons/tea-set.svg +1 -0
- package/assets/icons/teapot.svg +1 -0
- package/assets/icons/traditional-house.svg +1 -0
- package/assets/icons/traditional-shoes.svg +1 -0
- package/assets/icons/trash.svg +1 -0
- package/assets/icons/tree-of-life.svg +1 -0
- package/assets/icons/undo.svg +1 -0
- package/assets/icons/unity.svg +1 -0
- package/assets/icons/upload.svg +1 -0
- package/assets/icons/user.svg +1 -0
- package/assets/icons/users.svg +1 -0
- package/assets/icons/uyghur-medallion.svg +1 -0
- package/assets/icons/warning.svg +1 -0
- package/assets/icons/womens-dress.svg +1 -0
- package/assets/icons/womens-headdress.svg +1 -0
- package/assets/icons/yurt.svg +1 -0
- package/assets/maps/README.md +27 -0
- package/assets/maps/east-turkistan-filled.svg +1 -0
- package/assets/maps/east-turkistan-outline.svg +1 -0
- package/assets/maps/east-turkistan.metadata.json +64 -0
- package/assets/maps/east-turkistan.source.geojson +1 -0
- package/package.json +93 -4
- package/src/application.css +4 -0
- package/src/application.d.ts +7 -0
- package/src/application.js +120 -0
- package/src/blocks.css +1 -0
- package/src/font.css +8 -0
- package/src/heritage-color.js +30 -0
- package/src/icon-labels.js +98 -0
- package/src/icons.d.ts +13 -0
- package/src/icons.js +102 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +202 -0
- package/src/interactions.css +15 -0
- package/src/interactions.d.ts +10 -0
- package/src/interactions.js +183 -0
- package/src/map-data.js +68 -0
- package/src/maps.d.ts +11 -0
- package/src/maps.js +17 -0
- package/src/reference-clothing.js +51 -0
- package/src/reference-places.js +43 -0
- package/src/styles.css +20 -0
- package/src/themes.d.ts +7 -0
- package/src/themes.js +36 -0
- package/src/traditional-drawings.js +42 -0
- package/src/vendor/README.md +17 -0
- package/src/vendor/keyboard/LICENSE +21 -0
- package/src/vendor/keyboard/index.js +248 -0
- package/src/vendor/keyboard/style.js +22 -0
- package/src/vendor/text/LICENSE +21 -0
- package/src/vendor/text/index.js +275 -0
- package/src/writing.d.ts +17 -0
- package/src/writing.js +115 -0
package/package.json
CHANGED
|
@@ -1,6 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uyghurcommunity/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Uyghur RTL components, writing tools, cultural themes, native application controls, SVG assets and optional motion.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "UyghurCommunity",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"import": "./src/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./icons": {
|
|
17
|
+
"types": "./src/icons.d.ts",
|
|
18
|
+
"import": "./src/icons.js"
|
|
19
|
+
},
|
|
20
|
+
"./styles.css": "./src/styles.css",
|
|
21
|
+
"./font.css": "./src/font.css",
|
|
22
|
+
"./icons/*": "./assets/icons/*.svg",
|
|
23
|
+
"./icons/color/*": "./assets/icons/color/*.svg",
|
|
24
|
+
"./catalog.json": "./assets/icon-catalog.json",
|
|
25
|
+
"./flags/east-turkistan.svg": "./assets/flags/east-turkistan.svg",
|
|
26
|
+
"./maps": {
|
|
27
|
+
"types": "./src/maps.d.ts",
|
|
28
|
+
"import": "./src/maps.js"
|
|
29
|
+
},
|
|
30
|
+
"./maps/east-turkistan-outline.svg": "./assets/maps/east-turkistan-outline.svg",
|
|
31
|
+
"./maps/east-turkistan-filled.svg": "./assets/maps/east-turkistan-filled.svg",
|
|
32
|
+
"./maps/metadata.json": "./assets/maps/east-turkistan.metadata.json",
|
|
33
|
+
"./maps/source.geojson": "./assets/maps/east-turkistan.source.geojson",
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
"./writing": {
|
|
36
|
+
"types": "./src/writing.d.ts",
|
|
37
|
+
"import": "./src/writing.js"
|
|
38
|
+
},
|
|
39
|
+
"./application": {
|
|
40
|
+
"types": "./src/application.d.ts",
|
|
41
|
+
"import": "./src/application.js"
|
|
42
|
+
},
|
|
43
|
+
"./application.css": "./src/application.css",
|
|
44
|
+
"./interactions": {
|
|
45
|
+
"types": "./src/interactions.d.ts",
|
|
46
|
+
"import": "./src/interactions.js"
|
|
47
|
+
},
|
|
48
|
+
"./interactions.css": "./src/interactions.css",
|
|
49
|
+
"./themes": {
|
|
50
|
+
"types": "./src/themes.d.ts",
|
|
51
|
+
"import": "./src/themes.js"
|
|
52
|
+
},
|
|
53
|
+
"./blocks.css": "./src/blocks.css"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"src",
|
|
57
|
+
"assets/icons",
|
|
58
|
+
"assets/flags",
|
|
59
|
+
"assets/maps",
|
|
60
|
+
"assets/icon-catalog.json",
|
|
61
|
+
"README.md",
|
|
62
|
+
"LICENSE",
|
|
63
|
+
"THIRD_PARTY_NOTICES.md"
|
|
64
|
+
],
|
|
65
|
+
"sideEffects": [
|
|
66
|
+
"**/*.css"
|
|
67
|
+
],
|
|
68
|
+
"scripts": {
|
|
69
|
+
"test": "node --test",
|
|
70
|
+
"check": "node scripts/check.mjs && node scripts/check-docs.mjs",
|
|
71
|
+
"build:icons": "node scripts/build-icons.mjs",
|
|
72
|
+
"build:map": "node scripts/build-map.mjs",
|
|
73
|
+
"build:docs": "node scripts/build-docs.mjs",
|
|
74
|
+
"prepack": "npm run check && npm test",
|
|
75
|
+
"build:registry": "node scripts/build-registry.mjs",
|
|
76
|
+
"build:react-example": "node scripts/build-react-example.mjs"
|
|
77
|
+
},
|
|
78
|
+
"repository": {
|
|
79
|
+
"type": "git",
|
|
80
|
+
"url": "https://github.com/UyghurCommunity/uyghur-ui.git"
|
|
81
|
+
},
|
|
82
|
+
"homepage": "https://uyghurcommunity.github.io/uyghur-ui/",
|
|
83
|
+
"keywords": [
|
|
84
|
+
"uyghur",
|
|
85
|
+
"rtl",
|
|
86
|
+
"components",
|
|
87
|
+
"icons",
|
|
88
|
+
"svg",
|
|
89
|
+
"accessibility",
|
|
90
|
+
"east-turkistan"
|
|
91
|
+
],
|
|
92
|
+
"publishConfig": {
|
|
93
|
+
"access": "public"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* Application patterns remain scoped to the Uyghur UI container. */
|
|
2
|
+
.ug-ui .ug-menu-wrap{position:relative;min-width:0}.ug-ui .ug-table{width:100%;border-collapse:collapse;text-align:start}.ug-ui [data-ug-option][data-ug-active=true]{background:var(--ug-soft);color:var(--ug-blue)}
|
|
3
|
+
.ug-ui .ug-combobox,.ug-ui .ug-dropdown{position:relative;min-width:0}.ug-ui [data-ug-combobox-list],.ug-ui [data-ug-menu]{border:1px solid var(--ug-line);border-radius:var(--ug-radius);background:var(--ug-surface);padding:6px;box-shadow:0 12px 30px #10212d20;max-height:280px;overflow:auto;z-index:5}.ug-ui [data-ug-combobox-list]{margin-top:6px}.ug-ui [data-ug-menu]{position:absolute;inset-inline-start:0;min-width:190px;margin-top:7px}.ug-ui [data-ug-option],.ug-ui [data-ug-menu-item]{display:flex;align-items:center;gap:10px;width:100%;text-align:start;border:0;border-radius:6px;padding:8px 12px;background:transparent;color:var(--ug-text);font:inherit;cursor:pointer}.ug-ui [data-ug-option]:hover,.ug-ui [data-ug-option][aria-selected=true],.ug-ui [data-ug-menu-item]:focus{background:var(--ug-soft);color:var(--ug-blue)}.ug-ui [data-ug-option]:disabled,.ug-ui [data-ug-menu-item][aria-disabled=true]{opacity:.5;cursor:default}.ug-ui [data-ug-writing-preview]{border:1px solid var(--ug-line);border-radius:var(--ug-radius);padding:18px;min-height:100px;white-space:pre-wrap;overflow-wrap:anywhere;unicode-bidi:plaintext;background:var(--ug-surface);line-height:2.2}.ug-ui [data-ug-cleanup-preview]{white-space:pre-wrap;overflow-wrap:anywhere;border:1px dashed var(--ug-line);padding:14px;background:var(--ug-bg);font:13px/2 "ALKATIP Basma",ui-monospace,monospace}.ug-ui [data-ug-keyboard]{margin-block:12px;max-width:100%;overflow:auto}.ug-ui [data-ug-drawer]{position:fixed;inset-block:0;inset-inline-start:auto;inset-inline-end:0;margin:0;min-height:100dvh;max-height:100dvh;width:min(420px,calc(100% - 24px));border-radius:0;padding:28px}.ug-ui .ug-table-scroll{max-width:100%;overflow:auto}.ug-ui .ug-data-table{width:100%;border-collapse:collapse;text-align:start}.ug-ui .ug-data-table th,.ug-ui .ug-data-table td{padding:12px 15px;border-bottom:1px solid var(--ug-line);text-align:start;white-space:nowrap}.ug-ui .ug-data-table th{font-weight:normal;color:var(--ug-muted);background:var(--ug-bg)}.ug-ui [data-ug-sort]{font:inherit;border:0;background:transparent;color:inherit;cursor:pointer;text-align:start;padding:2px}.ug-ui :is([aria-sort=none],[aria-sort=ascending],[aria-sort=descending]) [data-ug-sort]:after{content:"";display:inline-block;inline-size:.9em;block-size:.9em;margin-inline-start:.35em;vertical-align:-.1em;background-color:currentColor;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}.ug-ui [aria-sort=none] [data-ug-sort]:after{opacity:.45;-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(6 1) scale(.5)' stroke-width='4'%3E%3Cpath d='m5 15 7-7 7 7'/%3E%3C/g%3E%3Cg transform='translate(6 11) scale(.5)' stroke-width='4'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(6 1) scale(.5)' stroke-width='4'%3E%3Cpath d='m5 15 7-7 7 7'/%3E%3C/g%3E%3Cg transform='translate(6 11) scale(.5)' stroke-width='4'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/g%3E%3C/svg%3E")}.ug-ui [aria-sort=ascending] [data-ug-sort]:after{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5m-6 6 6-6 6 6'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5m-6 6 6-6 6 6'/%3E%3C/svg%3E")}.ug-ui [aria-sort=descending] [data-ug-sort]:after{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14m-6-6 6 6 6-6'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14m-6-6 6 6 6-6'/%3E%3C/svg%3E")}.ug-ui .ug-table-pagination{display:flex;align-items:center;gap:12px;justify-content:space-between;flex-wrap:wrap;margin-top:16px}.ug-ui [data-ug-table-status],.ug-ui [data-ug-writing-status]{color:var(--ug-muted);font-size:.85em}.ug-ui [data-ug-writing-input][aria-invalid=true]{border-color:var(--ug-danger)}
|
|
4
|
+
@media(max-width:600px){.ug-ui [data-ug-drawer]{padding:22px}.ug-ui .ug-data-table th,.ug-ui .ug-data-table td{padding:10px}.ug-ui [data-ug-keyboard] .ug-keyboard__key{padding-inline:2px;font-size:18px}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ComboboxController { open(): void; close(): void; getValue(): string; select(value: string): boolean; destroy(): void }
|
|
2
|
+
export declare function bindCombobox(root: HTMLElement, options?: { onChange?: (value: string) => void }): ComboboxController;
|
|
3
|
+
export interface DropdownController { open(last?: boolean): void; close(focus?: boolean): void; toggle(): void; destroy(): void }
|
|
4
|
+
export declare function bindDropdown(root: HTMLElement): DropdownController;
|
|
5
|
+
export declare function bindDrawer(root: HTMLElement, options?: { initialFocus?: HTMLElement; dismissOutside?: boolean }): { open(): void; close(value?: string): void; destroy(): void };
|
|
6
|
+
export interface DataTableState { readonly page: number; readonly pageCount: number; readonly pageSize: number; readonly total: number; readonly filtered: number; readonly sort: { readonly column: number; readonly direction: 'ascending' | 'descending' } | null }
|
|
7
|
+
export declare function bindDataTable(root: HTMLElement, options?: { pageSize?: number }): { getState(): DataTableState; setPage(page: number): void; refresh(): void; destroy(): void };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { bindDialog } from './index.js';
|
|
2
|
+
let generatedID = 0;
|
|
3
|
+
const remember = (node, attributes) => attributes.map((name) => [node, name, node.getAttribute(name)]);
|
|
4
|
+
const restore = (attributes) => attributes.forEach(([node, name, value]) => value === null ? node.removeAttribute(name) : node.setAttribute(name, value));
|
|
5
|
+
function identify(node, prefix) { if (!node.id) { do { node.id = `${prefix}-${++generatedID}`; } while (node.ownerDocument.getElementById(node.id) && node.ownerDocument.getElementById(node.id) !== node); } return node.id; }
|
|
6
|
+
const normalize = (text) => text.normalize('NFKC').toLocaleLowerCase().replace(/\s+/g, ' ').trim();
|
|
7
|
+
const enabled = (node) => !node.disabled && node.getAttribute('aria-disabled') !== 'true';
|
|
8
|
+
|
|
9
|
+
/** A local, editable filter with listbox selection. Labels are always plain text. */
|
|
10
|
+
export function bindCombobox(root, { onChange } = {}) {
|
|
11
|
+
if (onChange !== undefined && typeof onChange !== 'function') throw new TypeError('onChange must be a function');
|
|
12
|
+
const input = root?.querySelector?.('[data-ug-combobox-input]'), list = root?.querySelector?.('[data-ug-combobox-list]');
|
|
13
|
+
const options = list ? [...list.querySelectorAll('button[data-ug-option]')] : [];
|
|
14
|
+
if (!input || !list || !options.length || options.some((option) => typeof option.dataset.value !== 'string')) throw new TypeError('Combobox needs an input, list and valued options');
|
|
15
|
+
const doc = root.ownerDocument, status = root.querySelector('[data-ug-combobox-status]');
|
|
16
|
+
const saved = [...remember(input, ['role', 'aria-expanded', 'aria-controls', 'aria-haspopup', 'aria-autocomplete', 'aria-activedescendant']), ...remember(list, ['id', 'role', 'aria-label']), ...options.flatMap((option) => remember(option, ['id', 'role', 'aria-selected', 'tabindex', 'data-ug-active']))];
|
|
17
|
+
const hidden = options.map((option) => option.hidden), originalListHidden = list.hidden;
|
|
18
|
+
input.setAttribute('role', 'combobox'); input.setAttribute('aria-autocomplete', 'list'); input.setAttribute('aria-haspopup', 'listbox'); input.setAttribute('aria-controls', identify(list, 'ug-combobox')); list.setAttribute('role', 'listbox'); if (!list.getAttribute('aria-label') && !list.getAttribute('aria-labelledby')) list.setAttribute('aria-label', 'تاللاشلار');
|
|
19
|
+
options.forEach((option) => { identify(option, 'ug-option'); option.setAttribute('role', 'option'); option.setAttribute('tabindex', '-1'); });
|
|
20
|
+
let destroyed = false, expanded = false, composing = false, active = -1, matches = [];
|
|
21
|
+
let selected = options.find((option) => option.dataset.value === input.value || option.textContent.trim() === input.value) ?? null;
|
|
22
|
+
const alive = () => { if (destroyed) throw new Error('Combobox has been destroyed'); };
|
|
23
|
+
function activeOption(index) { active = matches.length ? (index + matches.length) % matches.length : -1; options.forEach((option) => option.setAttribute('data-ug-active', String(expanded && matches[active] === option))); if (expanded && active >= 0) input.setAttribute('aria-activedescendant', matches[active].id); else input.removeAttribute('aria-activedescendant'); }
|
|
24
|
+
function render() {
|
|
25
|
+
const query = selected && input.value === selected.textContent.trim() ? '' : normalize(input.value); matches = [];
|
|
26
|
+
options.forEach((option, index) => { option.hidden = hidden[index] || !normalize(`${option.textContent} ${option.dataset.value}`).includes(query); option.setAttribute('aria-selected', String(option === selected)); if (!option.hidden && enabled(option)) matches.push(option); });
|
|
27
|
+
list.hidden = !expanded; input.setAttribute('aria-expanded', String(expanded)); activeOption(matches.indexOf(selected) >= 0 ? matches.indexOf(selected) : 0);
|
|
28
|
+
if (status) status.textContent = matches.length ? `${matches.length} تاللاش` : 'ماس تاللاش تېپىلمىدى.';
|
|
29
|
+
}
|
|
30
|
+
function open() { alive(); expanded = true; render(); }
|
|
31
|
+
function close() { if (destroyed) return; expanded = false; list.hidden = true; input.setAttribute('aria-expanded', 'false'); input.removeAttribute('aria-activedescendant'); active = -1; options.forEach((option) => option.setAttribute('data-ug-active', 'false')); }
|
|
32
|
+
function choose(option, focus = false) { if (!enabled(option)) return false; const previous = selected; selected = option; input.value = option.textContent.trim(); options.forEach((item) => item.setAttribute('aria-selected', String(item === option))); close(); if (focus) input.focus(); if (previous !== option) onChange?.(option.dataset.value); return true; }
|
|
33
|
+
function changed() { if (composing) return; const previous = selected; selected = null; open(); if (previous) onChange?.(''); }
|
|
34
|
+
function keyed(event) {
|
|
35
|
+
if (destroyed || composing || event.isComposing || event.defaultPrevented) return;
|
|
36
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { event.preventDefault(); if (!expanded) { open(); if (event.key === 'ArrowUp') activeOption(matches.length - 1); } else activeOption(active + (event.key === 'ArrowDown' ? 1 : -1)); }
|
|
37
|
+
else if (event.key === 'Enter' && expanded) { event.preventDefault(); if (active >= 0) choose(matches[active], true); else close(); }
|
|
38
|
+
else if (event.key === 'Escape' && expanded) { event.preventDefault(); close(); }
|
|
39
|
+
}
|
|
40
|
+
const clickedInput = () => open(), begin = () => { composing = true; }, end = () => { composing = false; changed(); };
|
|
41
|
+
const clicked = (event) => { const option = options.find((item) => item === event.target || item.contains(event.target)); if (option) { event.preventDefault(); choose(option, true); } };
|
|
42
|
+
const outside = (event) => { if (!root.contains(event.target)) close(); }, focusout = (event) => { if (!root.contains(event.relatedTarget)) close(); };
|
|
43
|
+
input.addEventListener('input', changed); input.addEventListener('keydown', keyed); input.addEventListener('click', clickedInput); input.addEventListener('compositionstart', begin); input.addEventListener('compositionend', end); list.addEventListener('click', clicked); doc.addEventListener('pointerdown', outside); root.addEventListener('focusout', focusout);
|
|
44
|
+
render();
|
|
45
|
+
return { open, close, getValue() { alive(); return selected?.dataset.value ?? ''; }, select(value) { alive(); const option = options.find((item) => item.dataset.value === value); if (!option) throw new RangeError('Unknown combobox value'); return choose(option); }, destroy() { if (destroyed) return; close(); destroyed = true; input.removeEventListener('input', changed); input.removeEventListener('keydown', keyed); input.removeEventListener('click', clickedInput); input.removeEventListener('compositionstart', begin); input.removeEventListener('compositionend', end); list.removeEventListener('click', clicked); doc.removeEventListener('pointerdown', outside); root.removeEventListener('focusout', focusout); restore(saved); options.forEach((option, index) => { option.hidden = hidden[index]; }); list.hidden = originalListHidden; } };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A native-button action menu with roving keyboard focus and outside dismissal. */
|
|
49
|
+
export function bindDropdown(root) {
|
|
50
|
+
const trigger = root?.querySelector?.('[data-ug-menu-trigger]'), panel = root?.querySelector?.('[data-ug-menu]');
|
|
51
|
+
const items = panel ? [...new Set(panel.querySelectorAll('button, [data-ug-menu-item]'))] : [];
|
|
52
|
+
if (!trigger || !panel || !items.length) throw new TypeError('Dropdown needs a trigger, menu and items');
|
|
53
|
+
const doc = root.ownerDocument, hidden = panel.hidden;
|
|
54
|
+
const saved = [...remember(trigger, ['aria-haspopup', 'aria-expanded', 'aria-controls']), ...remember(panel, ['role', 'id']), ...items.flatMap((item) => remember(item, ['role', 'tabindex']))];
|
|
55
|
+
trigger.setAttribute('aria-haspopup', 'menu'); trigger.setAttribute('aria-controls', identify(panel, 'ug-menu')); panel.setAttribute('role', 'menu'); items.forEach((item) => { item.setAttribute('role', 'menuitem'); item.setAttribute('tabindex', '-1'); });
|
|
56
|
+
let destroyed = false, expanded = false;
|
|
57
|
+
const choices = () => items.filter((item) => enabled(item) && !item.hidden);
|
|
58
|
+
function close(focus = panel.contains(doc.activeElement)) { if (destroyed) return; panel.hidden = true; expanded = false; trigger.setAttribute('aria-expanded', 'false'); if (focus) trigger.focus(); }
|
|
59
|
+
function open(last = false) { if (destroyed) throw new Error('Dropdown has been destroyed'); panel.hidden = false; expanded = true; trigger.setAttribute('aria-expanded', 'true'); const available = choices(); (last ? available.at(-1) : available[0])?.focus(); }
|
|
60
|
+
function toggle() { if (expanded) close(true); else open(); }
|
|
61
|
+
function triggerClick(event) { event.preventDefault(); toggle(); }
|
|
62
|
+
function triggerKey(event) { if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { event.preventDefault(); open(event.key === 'ArrowUp'); } else if (event.key === 'Escape' && expanded) { event.preventDefault(); close(true); } }
|
|
63
|
+
function panelKey(event) {
|
|
64
|
+
if (event.defaultPrevented || event.isComposing) return;
|
|
65
|
+
if (event.key === 'Escape') { event.preventDefault(); close(true); return; }
|
|
66
|
+
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) return;
|
|
67
|
+
const available = choices(); if (!available.length) return; event.preventDefault();
|
|
68
|
+
const current = available.findIndex((item) => item === event.target || item.contains(event.target));
|
|
69
|
+
const next = event.key === 'Home' ? 0 : event.key === 'End' ? available.length - 1 : (current + (event.key === 'ArrowDown' ? 1 : -1) + available.length) % available.length;
|
|
70
|
+
available[next].focus();
|
|
71
|
+
}
|
|
72
|
+
function action(event) { const item = items.find((node) => node === event.target || node.contains(event.target)); if (!item) return; if (!enabled(item)) { event.preventDefault(); return; } close(true); }
|
|
73
|
+
const outside = (event) => { if (!root.contains(event.target)) close(panel.contains(doc.activeElement)); }, focusout = (event) => { if (!root.contains(event.relatedTarget)) close(false); };
|
|
74
|
+
trigger.addEventListener('click', triggerClick); trigger.addEventListener('keydown', triggerKey); panel.addEventListener('keydown', panelKey); panel.addEventListener('click', action); doc.addEventListener('pointerdown', outside); root.addEventListener('focusout', focusout); close();
|
|
75
|
+
return { open, close, toggle, destroy() { if (destroyed) return; if (panel.contains(doc.activeElement)) trigger.focus(); close(); destroyed = true; trigger.removeEventListener('click', triggerClick); trigger.removeEventListener('keydown', triggerKey); panel.removeEventListener('keydown', panelKey); panel.removeEventListener('click', action); doc.removeEventListener('pointerdown', outside); root.removeEventListener('focusout', focusout); restore(saved); panel.hidden = hidden; } };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Use the package's native dialog behavior for a labelled drawer. */
|
|
79
|
+
export function bindDrawer(root, { initialFocus, dismissOutside = true } = {}) {
|
|
80
|
+
const trigger = root?.querySelector?.('[data-ug-drawer-trigger]'), dialog = root?.querySelector?.('[data-ug-drawer]');
|
|
81
|
+
if (!trigger || !dialog) throw new TypeError('Drawer needs a trigger and a native dialog');
|
|
82
|
+
return bindDialog(dialog, { trigger, initialFocus: initialFocus ?? dialog.querySelector('[autofocus]'), dismissOutside });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Sort, filter and paginate existing local table rows without recreating their markup. */
|
|
86
|
+
export function bindDataTable(root, { pageSize = 5 } = {}) {
|
|
87
|
+
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100) throw new RangeError('pageSize must be an integer from 1 to 100');
|
|
88
|
+
const table = root?.querySelector?.('table'), body = table?.querySelector('tbody'), search = root?.querySelector?.('[data-ug-table-search]');
|
|
89
|
+
const previous = root?.querySelector?.('[data-ug-table-prev]'), next = root?.querySelector?.('[data-ug-table-next]'), status = root?.querySelector?.('[data-ug-table-status]');
|
|
90
|
+
if (!table || !body || !search || !previous || !next || !status) throw new TypeError('Data table controls are incomplete');
|
|
91
|
+
const rows = [...body.querySelectorAll('tr')], sortButtons = [...table.querySelectorAll('button[data-ug-sort]')];
|
|
92
|
+
const columns = Math.max(0, ...rows.map((row) => row.cells.length));
|
|
93
|
+
if (sortButtons.some((button) => !/^\d+$/.test(button.dataset.ugSort) || Number(button.dataset.ugSort) >= columns && rows.length)) throw new TypeError('Sort columns must refer to table cells');
|
|
94
|
+
const originalHidden = rows.map((row) => row.hidden), oldPrevious = previous.disabled, oldNext = next.disabled;
|
|
95
|
+
const headings = [...new Set(sortButtons.map((button) => button.closest('th')).filter(Boolean))], saved = headings.flatMap((heading) => remember(heading, ['aria-sort']));
|
|
96
|
+
const collator = new Intl.Collator('ug', { numeric: true, sensitivity: 'base' });
|
|
97
|
+
let destroyed = false, composing = false, page = 1, filtered = [], pageCount = 1, sort = null;
|
|
98
|
+
const alive = () => { if (destroyed) throw new Error('Data table has been destroyed'); };
|
|
99
|
+
function number(text) { const raw = text.trim().replace(/[٠-٩۰-۹]/g, (digit) => String(digit.charCodeAt(0) - (digit >= '۰' ? 1776 : 1632))).replace(/[,٬]/g, '').replace(/٫/g, '.'); return raw && Number.isFinite(Number(raw)) ? Number(raw) : null; }
|
|
100
|
+
function render() {
|
|
101
|
+
if (destroyed) return;
|
|
102
|
+
const ordered = rows.map((row, index) => ({ row, index }));
|
|
103
|
+
if (sort) ordered.sort((a, b) => { const left = a.row.cells[sort.column]?.textContent.trim() ?? '', right = b.row.cells[sort.column]?.textContent.trim() ?? '', x = number(left), y = number(right); const comparison = x !== null && y !== null ? x - y : collator.compare(left, right); return comparison * (sort.direction === 'ascending' ? 1 : -1) || a.index - b.index; });
|
|
104
|
+
const terms = normalize(search.value).split(' ').filter(Boolean);
|
|
105
|
+
filtered = ordered.filter(({ row, index }) => !originalHidden[index] && terms.every((term) => normalize(row.textContent).includes(term))).map(({ row }) => row);
|
|
106
|
+
pageCount = Math.max(1, Math.ceil(filtered.length / pageSize)); page = Math.min(Math.max(1, page), pageCount);
|
|
107
|
+
const visible = new Set(filtered.slice((page - 1) * pageSize, page * pageSize));
|
|
108
|
+
ordered.forEach(({ row }) => { row.hidden = !visible.has(row); body.appendChild(row); });
|
|
109
|
+
previous.disabled = page <= 1; next.disabled = page >= pageCount;
|
|
110
|
+
headings.forEach((heading) => heading.setAttribute('aria-sort', 'none'));
|
|
111
|
+
if (sort) sortButtons.find((button) => Number(button.dataset.ugSort) === sort.column)?.closest('th')?.setAttribute('aria-sort', sort.direction);
|
|
112
|
+
status.textContent = filtered.length ? `${filtered.length} نەتىجە · ${page} / ${pageCount} بەت` : 'ماس نەتىجە تېپىلمىدى.';
|
|
113
|
+
}
|
|
114
|
+
function changed() { if (composing) return; page = 1; render(); }
|
|
115
|
+
const begin = () => { composing = true; }, end = () => { composing = false; changed(); };
|
|
116
|
+
const prevClick = () => { if (!previous.disabled) { page--; render(); } }, nextClick = () => { if (!next.disabled) { page++; render(); } };
|
|
117
|
+
const handlers = sortButtons.map((button) => { const callback = () => { const column = Number(button.dataset.ugSort); sort = { column, direction: sort?.column === column && sort.direction === 'ascending' ? 'descending' : 'ascending' }; page = 1; render(); }; button.addEventListener('click', callback); return [button, callback]; });
|
|
118
|
+
search.addEventListener('input', changed); search.addEventListener('compositionstart', begin); search.addEventListener('compositionend', end); previous.addEventListener('click', prevClick); next.addEventListener('click', nextClick); render();
|
|
119
|
+
return { getState() { alive(); return Object.freeze({ page, pageCount, pageSize, total: rows.length, filtered: filtered.length, sort: sort ? Object.freeze({ ...sort }) : null }); }, setPage(value) { alive(); if (!Number.isInteger(value) || value < 1) throw new RangeError('Page must be a positive integer'); page = Math.min(value, pageCount); render(); }, refresh() { alive(); render(); }, destroy() { if (destroyed) return; destroyed = true; search.removeEventListener('input', changed); search.removeEventListener('compositionstart', begin); search.removeEventListener('compositionend', end); previous.removeEventListener('click', prevClick); next.removeEventListener('click', nextClick); handlers.forEach(([button, callback]) => button.removeEventListener('click', callback)); rows.forEach((row, index) => { row.hidden = originalHidden[index]; body.appendChild(row); }); previous.disabled = oldPrevious; next.disabled = oldNext; restore(saved); } };
|
|
120
|
+
}
|
package/src/blocks.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ug-ui .ug-dashboard-block,.ug-ui .ug-editor-block{border:1px solid var(--ug-line);border-radius:var(--ug-radius);background:var(--ug-surface);overflow:hidden;min-width:0}.ug-ui .ug-dashboard-block{display:grid;grid-template-columns:155px minmax(0,1fr)}.ug-ui .ug-dashboard-sidebar{padding:22px 17px;background:var(--ug-soft);border-inline-end:1px solid var(--ug-line);min-width:0}.ug-ui .ug-dashboard-sidebar strong{font-size:18px;font-weight:normal}.ug-ui .ug-dashboard-sidebar nav{display:grid;gap:9px;margin-block:22px}.ug-ui .ug-dashboard-sidebar a{font-size:13px;color:var(--ug-text);text-decoration:none;padding:5px 8px;border-radius:6px}.ug-ui .ug-dashboard-sidebar a:hover{background:var(--ug-surface)}.ug-ui .ug-dashboard-sidebar small{font-size:10px;color:var(--ug-muted)}.ug-ui .ug-dashboard-content{padding:25px;min-width:0}.ug-ui .ug-dashboard-content h4,.ug-ui .ug-editor-block h4{font-weight:normal;font-size:26px;line-height:1.9;margin:10px 0}.ug-ui .ug-dashboard-content header p,.ug-ui .ug-editor-block header p{font-size:13px;color:var(--ug-muted)}.ug-ui .ug-dashboard-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-block:24px}.ug-ui .ug-dashboard-stats>div{border:1px solid var(--ug-line);border-radius:8px;padding:12px;display:grid;gap:3px}.ug-ui .ug-dashboard-stats bdi{font:26px/1.5 ui-monospace,monospace;color:var(--ug-blue)}.ug-ui .ug-dashboard-stats span{font-size:11px;color:var(--ug-muted)}.ug-ui .ug-editor-block{padding:25px}.ug-ui .ug-editor-block>header{border-bottom:1px solid var(--ug-line);padding-bottom:20px;margin-bottom:20px}.ug-ui .ug-editor-block>.ug-row{border-top:1px solid var(--ug-line);padding-top:20px;margin-top:20px}.ug-ui .ug-editor-block .ug-writing{border:0;padding:0}@media(max-width:650px){.ug-ui .ug-dashboard-block{grid-template-columns:1fr}.ug-ui .ug-dashboard-sidebar{border-inline-end:0;border-bottom:1px solid var(--ug-line)}.ug-ui .ug-dashboard-sidebar nav{display:flex;flex-wrap:wrap;margin-block:12px;gap:5px}.ug-ui .ug-dashboard-content,.ug-ui .ug-editor-block{padding:18px}.ug-ui .ug-dashboard-stats{gap:6px}.ug-ui .ug-dashboard-stats>div{padding:9px}.ug-ui .ug-dashboard-stats bdi{font-size:23px}}
|
package/src/font.css
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family:"ALKATIP Basma";
|
|
3
|
+
src:url("https://db.onlinewebfonts.com/t/3c16518f40da2fc2901f37666c0556a7.woff2") format("woff2"),
|
|
4
|
+
url("https://db.onlinewebfonts.com/t/3c16518f40da2fc2901f37666c0556a7.woff") format("woff"),
|
|
5
|
+
url("https://db.onlinewebfonts.com/t/3c16518f40da2fc2901f37666c0556a7.ttf") format("truetype");
|
|
6
|
+
font-weight:normal;font-style:normal;font-display:swap;
|
|
7
|
+
}
|
|
8
|
+
.alkatip-basma{font-family:"ALKATIP Basma",serif;direction:rtl;unicode-bidi:embed;line-height:2.2}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Original color underlays for the existing pictograms; outlines are rendered above them.
|
|
2
|
+
export const heritageUnderlays = Object.freeze({
|
|
3
|
+
doppa: '<path d="m3 10 9-6 9 6-2 9-7 3-7-3Z" fill="#3f7d6a"/><path d="m3 10 9 3 9-3-9-6Z" fill="#f4e4c8"/>',
|
|
4
|
+
almond: '<path d="M12 2C3 8 4 18 12 22c8-4 9-14 0-20Z" fill="#bc8d43"/>',
|
|
5
|
+
flower: '<path d="M12 11C5 8 7 2 12 4c5-2 7 4 0 7Zm1 1c3-7 9-5 7 0 2 5-4 7-7 0Zm-1 1c7 3 5 9 0 7-5 2-7-4 0-7Zm-1-1c-3 7-9 5-7 0-2-5 4-7 7 0Z" fill="#b54c3b"/>',
|
|
6
|
+
dutar: '<path d="M10.5 3h3v8.5c1.1 1.8 4 3.1 4 5.6a5.5 4 0 0 1-11 0c0-2.5 2.9-3.8 4-5.6Z" fill="#bc8d43"/>',
|
|
7
|
+
tambur: '<path d="M11 3h2v12c1.7.8 3 1.9 3 3.6a4 2.4 0 0 1-8 0c0-1.7 1.3-2.8 3-3.6Z" fill="#bc8d43"/>',
|
|
8
|
+
rawap: '<circle cx="12" cy="17" r="4" fill="#bc8d43"/><path d="M11 5h2v10h-2Z" fill="#f4e4c8"/>',
|
|
9
|
+
ghijek: '<circle cx="10" cy="15" r="4" fill="#f4e4c8"/><path d="M9 3h2v8H9Z" fill="#bc8d43"/>',
|
|
10
|
+
satar: '<path d="M8 3h2v9c1.6 1.9 3.5 3.4 3.5 5.8a4.5 3.2 0 0 1-9 0c0-2.4 1.9-3.9 3.5-5.8Z" fill="#bc8d43"/>',
|
|
11
|
+
dap: '<circle cx="12" cy="12" r="8.5" fill="#bc8d43"/><circle cx="12" cy="12" r="6.8" fill="#f4e4c8"/>',
|
|
12
|
+
atlas: '<path d="M4 3h16v18H4Z" fill="#f4e4c8"/><path d="m7 6 3 3-3 3 3 3-3 3m7-12 3 3-3 3 3 3-3 3" fill="none" stroke="#b54c3b" stroke-width="2.8"/>',
|
|
13
|
+
carpet: '<path d="M5 5h14v14H5Z" fill="#b54c3b"/><path d="m12 8 4 4-4 4-4-4Z" fill="#bc8d43"/>',
|
|
14
|
+
embroidery: '<circle cx="11" cy="13" r="8" fill="#bc8d43"/><circle cx="11" cy="13" r="6.4" fill="#f4e4c8"/>',
|
|
15
|
+
loom: '<path d="M5 6h14v12H5Z" fill="#f4e4c8"/><path d="M3 13l4-2h10l4 2-4 2H7Z" fill="#bc8d43"/>',
|
|
16
|
+
spindle: '<path d="M7 16c0-3 2-6 5-8 3 2 5 5 5 8Z" fill="#bc8d43"/>',
|
|
17
|
+
aywan: '<path d="m3 7 3-3h12l3 3Z" fill="#bc8d43"/><path d="M5 7h14v14H5Z" fill="#f4e4c8"/>',
|
|
18
|
+
archway: '<path d="M4 21V11c0-4 5-6 8-8 3 2 8 4 8 8v10Z" fill="#bc8d43"/><path d="M8 21V12c0-2 2-3.7 4-5 2 1.3 4 3 4 5v9Z" fill="#f4e4c8"/>',
|
|
19
|
+
'carved-door': '<path d="M5 3h14v18H5Z" fill="#f4e4c8"/><path d="m8.5 6 2 3-2 3-2-3Z" fill="#b54c3b"/><path d="m15.5 6 2 3-2 3-2-3Z" fill="#3f7d6a"/>',
|
|
20
|
+
'lattice-window': '<rect x="4" y="4" width="16" height="16" rx="1" fill="#f4e4c8"/>',
|
|
21
|
+
nan: '<circle cx="12" cy="12" r="8.5" fill="#bc8d43"/><circle cx="12" cy="12" r="3.5" fill="#f4e4c8"/>',
|
|
22
|
+
samsa: '<path d="m12 4 8.5 15.5c.4.7 0 1.5-.8 1.5H4.3c-.8 0-1.2-.8-.8-1.5Z" fill="#bc8d43"/>',
|
|
23
|
+
polo: '<ellipse cx="12" cy="16.5" rx="8.5" ry="4" fill="#f4e4c8"/><path d="M5 14c1-4 4-5 7-4 3-1 6 0 7 4Z" fill="#bc8d43"/>',
|
|
24
|
+
laghman: '<path d="M3.5 13c.5 5 3.5 7.5 8.5 7.5s8-2.5 8.5-7.5Z" fill="#3f7d6a"/><ellipse cx="12" cy="13" rx="8.5" ry="2.5" fill="#f4e4c8"/>',
|
|
25
|
+
teapot: '<path d="M8 9h9l1.5 4a5.5 5.5 0 0 1-11 0Z" fill="#3f7d6a"/><path d="M7.5 13 3 9v6l4.5 3Z" fill="#bc8d43"/>',
|
|
26
|
+
'tea-bowl': '<path d="M3.5 10c.5 6 3.5 9 8.5 9s8-3 8.5-9Z" fill="#3f7d6a"/><ellipse cx="12" cy="10" rx="8.5" ry="2.5" fill="#f4e4c8"/>',
|
|
27
|
+
pomegranate: '<path d="m9 7-2-3 5 2 5-2-2 3c3 1.3 4.5 3.7 4.5 6.5A7.5 7.5 0 0 1 12 21a7.5 7.5 0 0 1-7.5-7.5C4.5 10.7 6 8.3 9 7Z" fill="#b54c3b"/>',
|
|
28
|
+
grapes: '<g fill="#765e8d"><circle cx="7.5" cy="9" r="2.2"/><circle cx="12" cy="9" r="2.2"/><circle cx="16.5" cy="9" r="2.2"/><circle cx="9.8" cy="13.5" r="2.2"/><circle cx="14.2" cy="13.5" r="2.2"/><circle cx="12" cy="18" r="2.2"/></g><path d="M12 6c1-3 4-3 7-2-1 2-3 3-7 2Z" fill="#3f7d6a"/>',
|
|
29
|
+
apricot: '<path d="M12 8C7 5 3.5 9 4 14c.4 4 3.6 7 8 7s7.6-3 8-7c.5-5-3-9-8-6Z" fill="#bc8d43"/><path d="M12 7c0-3 3-4 7-3-1 3-3 4-7 3Z" fill="#3f7d6a"/>',
|
|
30
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Names and search hints for original digital pictograms, not a historical catalog.
|
|
2
|
+
const general = {
|
|
3
|
+
'arrow-left': ['سولغا', 'Arrow left'], 'arrow-right': ['ئوڭغا', 'Arrow right'],
|
|
4
|
+
'arrow-up': ['يۇقىرىغا', 'Arrow up'], 'arrow-down': ['تۆۋەنگە', 'Arrow down'],
|
|
5
|
+
'chevron-left': ['سول ئوق', 'Chevron left'], 'chevron-right': ['ئوڭ ئوق', 'Chevron right'],
|
|
6
|
+
'chevron-down': ['تۆۋەن ئوق', 'Chevron down'], 'chevron-up': ['يۇقىرى ئوق', 'Chevron up'],
|
|
7
|
+
check: ['تەستىق', 'Check'], 'check-circle': ['تەستىق بەلگىسى', 'Check circle'],
|
|
8
|
+
close: ['تاقاش', 'Close'], plus: ['قوشۇش', 'Plus'], minus: ['كېمەيتىش', 'Minus'],
|
|
9
|
+
search: ['ئىزدەش', 'Search'], menu: ['تىزىملىك', 'Menu'], home: ['باش بەت', 'Home'],
|
|
10
|
+
copy: ['كۆچۈرۈش', 'Copy'], download: ['چۈشۈرۈش', 'Download'], upload: ['يۈكلەش', 'Upload'],
|
|
11
|
+
'external-link': ['تاشقى ئۇلانما', 'External link'], link: ['ئۇلانما', 'Link'],
|
|
12
|
+
code: ['كود', 'Code'], settings: ['تەڭشەك', 'Settings'], sun: ['قۇياش', 'Sun'],
|
|
13
|
+
moon: ['ئاي', 'Moon'], heart: ['يۈرەك', 'Heart'], star: ['يۇلتۇز', 'Star'],
|
|
14
|
+
user: ['ئىشلەتكۈچى', 'User'], users: ['جامائەت', 'Community'], mail: ['ئېلخەت', 'Mail'],
|
|
15
|
+
calendar: ['كالېندار', 'Calendar'], book: ['كىتاب', 'Book'], keyboard: ['كۇنۇپكا تاختىسى', 'Keyboard'],
|
|
16
|
+
globe: ['يەر شارى', 'Globe'], language: ['تىل', 'Language'],
|
|
17
|
+
'direction-rtl': ['ئوڭدىن سولغا', 'Right to left'], 'direction-ltr': ['سولدىن ئوڭغا', 'Left to right'],
|
|
18
|
+
image: ['سۈرەت', 'Image'], palette: ['رەڭ تاختىسى', 'Palette'], edit: ['تەھرىرلەش', 'Edit'],
|
|
19
|
+
trash: ['ئۆچۈرۈش', 'Trash'], undo: ['قايتۇرۇش', 'Undo'], redo: ['قايتا ئىشلەش', 'Redo'],
|
|
20
|
+
info: ['ئۇچۇر', 'Information'], warning: ['ئاگاھلاندۇرۇش', 'Warning'],
|
|
21
|
+
play: ['قويۇش', 'Play'], pause: ['توختىتىش', 'Pause'],
|
|
22
|
+
};
|
|
23
|
+
const heritage = {
|
|
24
|
+
doppa: ['دوپپا', 'Doppa', 'textiles', ['döppä', 'do ppa', 'cap', 'hat', 'كەشتە']],
|
|
25
|
+
almond: ['بادام نەقشى', 'Almond motif', 'textiles', ['badam', 'paisley', 'ornament', 'نەقىش']],
|
|
26
|
+
flower: ['گۈل نەقشى', 'Floral motif', 'textiles', ['gul', 'rosette', 'ornament', 'نەقىش']],
|
|
27
|
+
dutar: ['دۇتار', 'Dutar', 'music', ['doutar', 'dotar', 'two string lute', 'ساز']],
|
|
28
|
+
tambur: ['تەمبۈر', 'Tambur', 'music', ['tembor', 'tanbur', 'تەمبۇر', 'ساز']],
|
|
29
|
+
rawap: ['راۋاپ', 'Rawap', 'music', ['rawab', 'rubab', 'راۋاب', 'ساز']],
|
|
30
|
+
ghijek: ['غېجەك', 'Ghijek', 'music', ['ghijak', 'ghichak', 'غىجەك', 'bowed fiddle', 'ساز']],
|
|
31
|
+
satar: ['ساتار', 'Satar', 'music', ['sattar', 'bowed lute', 'ساز']],
|
|
32
|
+
dap: ['داپ', 'Dap', 'music', ['daph', 'frame drum', 'tambourine', 'ساز']],
|
|
33
|
+
atlas: ['ئەتلەس', 'Atlas silk', 'textiles', ['etles', 'ikat', 'silk', 'رەخت']],
|
|
34
|
+
carpet: ['گىلەم', 'Carpet', 'textiles', ['gilem', 'rug', 'woven']],
|
|
35
|
+
embroidery: ['كەشتە', 'Embroidery', 'textiles', ['keshte', 'needle', 'thread', 'يىپ']],
|
|
36
|
+
loom: ['توقۇش دەستگاھى', 'Loom', 'textiles', ['toqumichiliq', 'weaving', 'توقۇمىچىلىق']],
|
|
37
|
+
spindle: ['ئۇرچۇق', 'Spindle', 'textiles', ['urchuq', 'yarn', 'spinning', 'يىپ']],
|
|
38
|
+
aywan: ['ئايۋان', 'Aywan', 'architecture', ['eywan', 'veranda', 'courtyard', 'ھويلا']],
|
|
39
|
+
archway: ['راۋاق', 'Arched gateway', 'architecture', ['arch', 'gateway', 'ئەگمە دەرۋازا']],
|
|
40
|
+
'carved-door': ['ئويما ئىشىك', 'Carved door', 'architecture', ['woodwork', 'oyma', 'ئىشىك']],
|
|
41
|
+
'lattice-window': ['تورلۇق دېرىزە', 'Lattice window', 'architecture', ['penjire', 'panjire', 'woodwork', 'پەنجىرە']],
|
|
42
|
+
nan: ['نان', 'Nan bread', 'table', ['naan', 'bread', 'tonur', 'تونۇر']],
|
|
43
|
+
samsa: ['سامسا', 'Samsa', 'table', ['samosa', 'pastry', 'samsa']],
|
|
44
|
+
polo: ['پولۇ', 'Polo', 'table', ['polu', 'pilaf', 'rice', 'گۈرۈچ', 'پولو']],
|
|
45
|
+
laghman: ['لەغمەن', 'Laghman', 'table', ['lagman', 'leghmen', 'noodles', 'ئاش']],
|
|
46
|
+
teapot: ['چەينەك', 'Teapot', 'table', ['cheynek', 'chogun', 'tea', 'چۆگۈن', 'چاي']],
|
|
47
|
+
'tea-bowl': ['پىيالە', 'Tea bowl', 'table', ['piyale', 'pigale', 'tea', 'cup', 'پىگالە', 'چاي']],
|
|
48
|
+
pomegranate: ['ئانار', 'Pomegranate', 'table', ['anar', 'fruit', 'مېۋە']],
|
|
49
|
+
grapes: ['ئۈزۈم', 'Grapes', 'garden', ['uzum', 'vine', 'fruit', 'باغ', 'مېۋە']],
|
|
50
|
+
apricot: ['ئۆرۈك', 'Apricot', 'garden', ['oruk', 'fruit', 'باغ', 'مېۋە']],
|
|
51
|
+
'fur-hat': ['تۇماق', 'Fur hat', 'clothing', ['tumaq', 'winter hat', 'تۈكلۈك تۇماق']],
|
|
52
|
+
'womens-headdress': ['ئاياللار باش كىيىمى', 'Women’s headdress', 'clothing', ['veil', 'headwear', 'باشكىيىم']],
|
|
53
|
+
'mens-coat': ['ئەرلەر چاپىنى', 'Men’s coat', 'clothing', ['coat', 'robe', 'ئەرلەر كىيىمى']],
|
|
54
|
+
'womens-dress': ['ئاياللار كۆينىكى', 'Women’s dress', 'clothing', ['dress', 'gown', 'كۆينەك']],
|
|
55
|
+
chapan: ['چاپان', 'Chapan robe', 'clothing', ['robe', 'chapan', 'تون']],
|
|
56
|
+
sash: ['بەلۋاغ', 'Belt and sash', 'clothing', ['belt', 'sash', 'بەلباغ']],
|
|
57
|
+
boots: ['ئۆتۈك', 'Boots', 'clothing', ['otuk', 'footwear']],
|
|
58
|
+
'traditional-shoes': ['كەشتىلىك ئاياغ', 'Embroidered shoes', 'clothing', ['slippers', 'traditional shoes', 'كەش']],
|
|
59
|
+
'ceramic-vase': ['ساپال گۈلدان', 'Ceramic vase', 'crafts', ['pottery', 'handicraft', 'vase', 'ساپال']],
|
|
60
|
+
jewelry: ['زىبۇزىننەت', 'Jewelry', 'crafts', ['pendant', 'jewellery', 'زىننەت']],
|
|
61
|
+
'doppa-top': ['دوپپا ئۈستى', 'Doppa top view', 'textiles', ['cap', 'embroidery', 'دوپپا']],
|
|
62
|
+
'uyghur-medallion': ['ئۇيغۇرچە گۈلنەقىش', 'Uyghur medallion', 'motifs', ['pattern', 'ornament', 'نەقىش']],
|
|
63
|
+
'floral-rosette': ['گۈللۈك نەقىش', 'Floral rosette', 'motifs', ['floral motif', 'flower', 'گۈل نەقشى']],
|
|
64
|
+
'ornamental-border': ['نەقىشلىك گىرۋەك', 'Ornamental border', 'motifs', ['border', 'trim', 'گىرۋەك']],
|
|
65
|
+
calligraphy: ['خەتتاتلىق', 'Calligraphy', 'crafts', ['pen', 'reed pen', 'script', 'قەلەم']],
|
|
66
|
+
'star-eight': ['سەككىز ئۇچلۇق يۇلتۇز', 'Eight-point star', 'motifs', ['star motif', 'eight point', 'يۇلتۇز']],
|
|
67
|
+
crescent: ['ھىلال', 'Crescent', 'motifs', ['crescent moon', 'ئاي']],
|
|
68
|
+
'tree-of-life': ['ھايات دەرىخى', 'Tree of life', 'motifs', ['tree', 'life', 'دەرىخ']],
|
|
69
|
+
unity: ['ئىتتىپاقلىق', 'Unity', 'motifs', ['handshake', 'together', 'بىرلىك']],
|
|
70
|
+
dove: ['تىنچلىق كەپتىرى', 'Dove of peace', 'motifs', ['dove', 'peace', 'olive branch', 'كەپتەر']],
|
|
71
|
+
surnai: ['سۇناي', 'Surnai', 'music', ['sunay', 'zurna', 'wind instrument', 'سۇرناي']],
|
|
72
|
+
mosque: ['مەسچىت', 'Mosque', 'architecture', ['mosque', 'dome', 'مەسچىت']],
|
|
73
|
+
mausoleum: ['مەقبەرە', 'Mausoleum', 'architecture', ['mausoleum', 'tomb', 'مازار']],
|
|
74
|
+
minaret: ['مۇنار', 'Minaret', 'architecture', ['tower', 'minaret', 'munar']],
|
|
75
|
+
madrasa: ['مەدرىسە', 'Madrasa', 'architecture', ['madrasa', 'school', 'portal']],
|
|
76
|
+
'traditional-house': ['ئەنئەنىۋى ئۆي', 'Traditional house', 'architecture', ['old town', 'house', 'dwelling', 'ئۆي']],
|
|
77
|
+
yurt: ['كىگىز ئۆي', 'Yurt', 'architecture', ['otaq', 'felt tent', 'yurt', 'ئوتاق']],
|
|
78
|
+
'city-gate': ['شەھەر دەرۋازىسى', 'City gate', 'architecture', ['gate', 'city', 'دەرۋازا']],
|
|
79
|
+
'ancient-ruins': ['قەدىمكى خارابە', 'Ancient ruins', 'architecture', ['ruins', 'ancient', 'خارابە']],
|
|
80
|
+
landscape: ['تاغ ۋە دەريا', 'Mountains and river', 'garden', ['landscape', 'mountain', 'river', 'تاغ', 'دەريا']],
|
|
81
|
+
'tea-set': ['چاي سايمانلىرى', 'Tea set', 'table', ['tea', 'teapot', 'cup', 'چاي']],
|
|
82
|
+
cotton: ['پاختا', 'Cotton', 'garden', ['cotton', 'paxta', 'plant']],
|
|
83
|
+
melon: ['قوغۇن', 'Melon', 'table', ['melon', 'qoghun', 'fruit', 'مېۋە']],
|
|
84
|
+
horse: ['ئات', 'Horse', 'garden', ['horse', 'at', 'animal']],
|
|
85
|
+
camel: ['تۆگە', 'Bactrian camel', 'garden', ['camel', 'toge', 'two humps', 'animal']],
|
|
86
|
+
'nan-stack': ['نان دۆۋىسى', 'Stack of nan', 'table', ['nan', 'bread', 'naan', 'stack']],
|
|
87
|
+
};
|
|
88
|
+
export const iconLabels = Object.freeze(Object.fromEntries([
|
|
89
|
+
...Object.entries(general).map(([name, [ug, en]]) => [name, Object.freeze({ ug, en, category: 'general', keywords: Object.freeze([]) })]),
|
|
90
|
+
...Object.entries(heritage).map(([name, [ug, en, category, keywords]]) => [name, Object.freeze({ ug, en, category, keywords: Object.freeze(keywords) })]),
|
|
91
|
+
]));
|
|
92
|
+
export const iconCategories = Object.freeze([
|
|
93
|
+
['all', 'ھەممىسى', 'All icons'], ['traditional', 'مىراس', 'Uyghur-inspired'],
|
|
94
|
+
['music', 'سازلار', 'Instruments'], ['textiles', 'نەقىش ۋە توقۇمىچىلىق', 'Textiles and motifs'],
|
|
95
|
+
['architecture', 'بىناكارلىق', 'Architecture'], ['table', 'داستىخان', 'Food and tea'],
|
|
96
|
+
['garden', 'تەبىئەت', 'Nature'], ['general', 'كۆرۈنمە يۈز', 'Interface'],
|
|
97
|
+
['clothing', 'كىيىم-كېچەك', 'Clothing'], ['crafts', 'قول ھۈنەر', 'Crafts'], ['motifs', 'نەقىش ۋە بەلگە', 'Motifs and symbols'],
|
|
98
|
+
].map(([id, ug, en]) => Object.freeze({ id, ug, en })));
|
package/src/icons.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const iconNames: readonly string[];
|
|
2
|
+
export declare const coloredIconNames: readonly string[];
|
|
3
|
+
export declare const directionalIcons: readonly string[];
|
|
4
|
+
export type IconCategory = 'general' | 'music' | 'textiles' | 'architecture' | 'table' | 'garden' | 'clothing' | 'crafts' | 'motifs';
|
|
5
|
+
export type IconFilter = IconCategory | 'all' | 'traditional';
|
|
6
|
+
export type IconVariant = 'outline' | 'color';
|
|
7
|
+
export interface IconEntry { readonly name: string; readonly ug: string; readonly en: string; readonly category: IconCategory; readonly keywords: readonly string[]; readonly variants: readonly IconVariant[] }
|
|
8
|
+
export declare const iconCatalog: readonly IconEntry[];
|
|
9
|
+
export declare const iconCategories: readonly { readonly id: IconFilter; readonly ug: string; readonly en: string }[];
|
|
10
|
+
export declare function findIcons(query?: string, options?: { category?: IconFilter }): string[];
|
|
11
|
+
export declare function escapeMarkup(value: unknown): string;
|
|
12
|
+
export declare function iconSVG(name: string, options?: { size?: number; strokeWidth?: number; label?: string; variant?: IconVariant }): string;
|
|
13
|
+
export declare function flagSVG(options?: { width?: number; label?: string }): string;
|
package/src/icons.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { traditionalDrawings } from './traditional-drawings.js';
|
|
2
|
+
import { iconLabels, iconCategories } from './icon-labels.js';
|
|
3
|
+
import { referenceClothingOutline, referenceClothingColor } from './reference-clothing.js';
|
|
4
|
+
import { referencePlacesOutline, referencePlacesColor } from './reference-places.js';
|
|
5
|
+
import { heritageUnderlays } from './heritage-color.js';
|
|
6
|
+
export { iconCategories } from './icon-labels.js';
|
|
7
|
+
/** Original 24×24 stroke drawings. The flag is a separate public-domain asset. */
|
|
8
|
+
const drawings = {
|
|
9
|
+
'arrow-left': '<path d="M19 12H5m6-6-6 6 6 6"/>',
|
|
10
|
+
'arrow-right': '<path d="M5 12h14m-6-6 6 6-6 6"/>',
|
|
11
|
+
'arrow-up': '<path d="M12 19V5m-6 6 6-6 6 6"/>',
|
|
12
|
+
'arrow-down': '<path d="M12 5v14m-6-6 6 6 6-6"/>',
|
|
13
|
+
'chevron-left': '<path d="m15 5-7 7 7 7"/>',
|
|
14
|
+
'chevron-right': '<path d="m9 5 7 7-7 7"/>',
|
|
15
|
+
'chevron-down': '<path d="m5 9 7 7 7-7"/>',
|
|
16
|
+
'chevron-up': '<path d="m5 15 7-7 7 7"/>',
|
|
17
|
+
'check': '<path d="m5 12 4 4L19 6"/>',
|
|
18
|
+
'check-circle': '<circle cx="12" cy="12" r="9"/><path d="m8 12 3 3 5-6"/>',
|
|
19
|
+
'close': '<path d="m6 6 12 12M18 6 6 18"/>',
|
|
20
|
+
'plus': '<path d="M12 4v16M4 12h16"/>',
|
|
21
|
+
'minus': '<path d="M4 12h16"/>',
|
|
22
|
+
'search': '<circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 5 5"/>',
|
|
23
|
+
'menu': '<path d="M4 6h16M4 12h16M4 18h16"/>',
|
|
24
|
+
'home': '<path d="m3 11 9-8 9 8M5 10v11h14V10M9 21v-7h6v7"/>',
|
|
25
|
+
'copy': '<rect x="8" y="8" width="12" height="13" rx="2"/><path d="M15 4H5a2 2 0 0 0-2 2v10"/>',
|
|
26
|
+
'download': '<path d="M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5"/>',
|
|
27
|
+
'upload': '<path d="M12 16V4m-5 5 5-5 5 5M4 16v5h16v-5"/>',
|
|
28
|
+
'external-link': '<path d="M14 3h7v7m0-7L10 14M10 5H4v16h16v-6"/>',
|
|
29
|
+
'link': '<path d="m9 15 6-6M8 13l-2 2a3.5 3.5 0 0 0 5 5l3-3M10 7l3-3a3.5 3.5 0 0 1 5 5l-2 2"/>',
|
|
30
|
+
'code': '<path d="m8 6-6 6 6 6m8-12 6 6-6 6M14 3l-4 18"/>',
|
|
31
|
+
'settings': '<path d="M4 6h16M4 12h16M4 18h16"/><circle cx="8" cy="6" r="2" fill="var(--ug-surface,white)"/><circle cx="16" cy="12" r="2" fill="var(--ug-surface,white)"/><circle cx="10" cy="18" r="2" fill="var(--ug-surface,white)"/>',
|
|
32
|
+
'sun': '<circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5"/>',
|
|
33
|
+
'moon': '<path d="M20 15.5A9 9 0 0 1 8.5 4 9 9 0 1 0 20 15.5Z"/>',
|
|
34
|
+
'heart': '<path d="M12 21 3.5 12a5 5 0 0 1 8.5-5 5 5 0 0 1 8.5 5Z"/>',
|
|
35
|
+
'star': '<path d="m12 2 3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1Z"/>',
|
|
36
|
+
'user': '<circle cx="12" cy="7" r="4"/><path d="M4 21v-2a8 8 0 0 1 16 0v2"/>',
|
|
37
|
+
'users': '<circle cx="9" cy="7" r="3.5"/><path d="M2 21v-2a7 7 0 0 1 14 0v2M17 4a3.5 3.5 0 0 1 0 7m1 4a6 6 0 0 1 4 6"/>',
|
|
38
|
+
'mail': '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/>',
|
|
39
|
+
'calendar': '<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M7 3v4m10-4v4M3 10h18M7 14h2m6 0h2m-10 4h2"/>',
|
|
40
|
+
'book': '<path d="M12 5c-4-3-7-3-10-1v15c3-2 6-2 10 1 4-3 7-3 10-1V4c-3-2-6-2-10 1Zm0 0v15"/>',
|
|
41
|
+
'keyboard': '<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M6 9h1m4 0h1m4 0h1M6 13h1m4 0h1m4 0h1M7 16h10"/>',
|
|
42
|
+
'globe': '<circle cx="12" cy="12" r="10"/><ellipse cx="12" cy="12" rx="4" ry="10"/><path d="M2 12h20M4 6h16M4 18h16"/>',
|
|
43
|
+
'language': '<path d="M3 5h11M8 2v3m3 0c0 6-3 10-8 13m1-9c1 3 4 6 8 8m1 4 4-11 4 11m-6-4h4"/>',
|
|
44
|
+
'direction-rtl': '<path d="M20 5H8m5-3L8 5l5 3M20 12H4m0 7h12m-5-3 5 3-5 3"/>',
|
|
45
|
+
'direction-ltr': '<path d="M4 5h12m-5-3 5 3-5 3M4 12h16M20 19H8m5-3-5 3 5 3"/>',
|
|
46
|
+
'image': '<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8" cy="8" r="2"/><path d="m3 17 5-5 4 4 4-7 5 8"/>',
|
|
47
|
+
'palette': '<path d="M20 13c2-5-2-10-8-10a9 9 0 1 0 0 18c2 0 2-2 1-3s-1-3 1-3h3c1 0 2-1 3-2Z"/><path d="M7 8h.01M12 6h.01M17 9h.01M6 13h.01"/>',
|
|
48
|
+
'edit': '<path d="m4 16 12-12 4 4L8 20H4Zm9-9 4 4"/>',
|
|
49
|
+
'trash': '<path d="M3 6h18M9 3h6l1 3M5 6l1 15h12l1-15M10 10v7m4-7v7"/>',
|
|
50
|
+
'undo': '<path d="M8 4 3 9l5 5M3 9h11a6 6 0 1 1 0 12"/>',
|
|
51
|
+
'redo': '<path d="m16 4 5 5-5 5m5-5H10a6 6 0 1 0 0 12"/>',
|
|
52
|
+
'info': '<circle cx="12" cy="12" r="9"/><path d="M12 11v6m0-10v.01"/>',
|
|
53
|
+
'warning': '<path d="m12 3 10 18H2ZM12 9v5m0 3v.01"/>',
|
|
54
|
+
'play': '<path d="m7 3 14 9-14 9Z"/>',
|
|
55
|
+
'pause': '<path d="M7 4h3v16H7Zm7 0h3v16h-3Z"/>',
|
|
56
|
+
'flower': '<path d="M12 11C5 8 7 2 12 4c5-2 7 4 0 7Zm1 1c3-7 9-5 7 0 2 5-4 7-7 0Zm-1 1c7 3 5 9 0 7-5 2-7-4 0-7Zm-1-1c-3 7-9 5-7 0-2-5 4-7 7 0Z"/>',
|
|
57
|
+
'almond': '<path d="M12 2C3 8 4 18 12 22c8-4 9-14 0-20Zm0 5c-4 4-4 8 0 11m0-5 4-4m-4 7-4-3"/>',
|
|
58
|
+
'doppa': '<path d="m3 10 9-6 9 6-2 9-7 3-7-3Zm0 0 9 3 9-3m-9 3v9M7 11l5-4 5 4"/>',
|
|
59
|
+
...traditionalDrawings,
|
|
60
|
+
...referenceClothingOutline,
|
|
61
|
+
...referencePlacesOutline,
|
|
62
|
+
};
|
|
63
|
+
const colorDrawings = Object.freeze({ ...Object.fromEntries(Object.entries(heritageUnderlays).map(([name, underlay]) => [name, `<g stroke="none">${underlay}</g><g fill="none">${drawings[name]}</g>`])), ...referenceClothingColor, ...referencePlacesColor });
|
|
64
|
+
export const coloredIconNames = Object.freeze(Object.keys(colorDrawings).sort());
|
|
65
|
+
export const iconNames = Object.freeze(Object.keys(drawings).sort());
|
|
66
|
+
export const iconCatalog = Object.freeze(iconNames.map((name) => {
|
|
67
|
+
if (!Object.hasOwn(iconLabels, name)) throw new Error(`Missing icon label: ${name}`);
|
|
68
|
+
return Object.freeze({ name, ...iconLabels[name], variants: Object.freeze(Object.hasOwn(colorDrawings, name) ? ['outline', 'color'] : ['outline']) });
|
|
69
|
+
}).sort((a, b) => Number(a.category === 'general') - Number(b.category === 'general') || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)));
|
|
70
|
+
const normalizeSearch = (text) => text.normalize('NFKC').toLowerCase().replace(/[’'ʻʼ]/g, '').replace(/[-_\s]+/g, ' ').trim();
|
|
71
|
+
/** Search names, Uyghur labels, English labels and aliases; category and query combine. */
|
|
72
|
+
export function findIcons(query = '', { category = 'all' } = {}) {
|
|
73
|
+
if (typeof query !== 'string') throw new TypeError('Icon query must be a string');
|
|
74
|
+
if (!iconCategories.some((entry) => entry.id === category)) throw new RangeError('Unknown icon category');
|
|
75
|
+
const terms = normalizeSearch(query).split(' ').filter(Boolean);
|
|
76
|
+
return iconCatalog.filter((entry) => {
|
|
77
|
+
const matchesCategory = category === 'all' || (category === 'traditional' ? entry.category !== 'general' : entry.category === category);
|
|
78
|
+
const haystack = normalizeSearch([entry.name, entry.ug, entry.en, ...entry.keywords].join(' '));
|
|
79
|
+
return matchesCategory && terms.every((term) => haystack.includes(term));
|
|
80
|
+
}).map((entry) => entry.name);
|
|
81
|
+
}
|
|
82
|
+
export const directionalIcons = Object.freeze(['arrow-left', 'arrow-right', 'chevron-left', 'chevron-right']);
|
|
83
|
+
export function escapeMarkup(value) {
|
|
84
|
+
return String(value).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
85
|
+
}
|
|
86
|
+
export function iconSVG(name, options = {}) {
|
|
87
|
+
if (!Object.hasOwn(drawings, name)) throw new RangeError(`Unknown icon: ${name}`);
|
|
88
|
+
const { size = 24, strokeWidth = 1.7, label = '', variant = 'outline' } = options;
|
|
89
|
+
if (!['outline', 'color'].includes(variant)) throw new RangeError('Icon variant must be outline or color');
|
|
90
|
+
if (!Number.isInteger(size) || size < 12 || size > 256) throw new RangeError('Icon size must be an integer from 12 to 256');
|
|
91
|
+
if (!Number.isFinite(strokeWidth) || strokeWidth < .5 || strokeWidth > 4) throw new RangeError('Stroke width must be between 0.5 and 4');
|
|
92
|
+
if (typeof label !== 'string' || label.length > 160) throw new TypeError('Use a label of at most 160 characters');
|
|
93
|
+
const colored = variant === 'color' && Object.hasOwn(colorDrawings, name);
|
|
94
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="${colored ? '#17364b' : 'currentColor'}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round" focusable="false" ${label ? `role="img" aria-label="${escapeMarkup(label)}"` : 'aria-hidden="true"'}>${colored ? colorDrawings[name] : drawings[name]}</svg>`;
|
|
95
|
+
}
|
|
96
|
+
// Geometry from the public-domain Kokbayraq flag; see THIRD_PARTY_NOTICES.md.
|
|
97
|
+
export function flagSVG(options = {}) {
|
|
98
|
+
const { width = 90, label = 'شەرقىي تۈركىستان بايرىقى / East Turkistan flag' } = options;
|
|
99
|
+
if (!Number.isInteger(width) || width < 24 || width > 1800) throw new RangeError('Flag width must be an integer from 24 to 1800');
|
|
100
|
+
if (typeof label !== 'string' || label.length > 160) throw new TypeError('Use a label of at most 160 characters');
|
|
101
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${width * 2 / 3}" viewBox="0 -30000 90000 60000" focusable="false" ${label ? `role="img" aria-label="${escapeMarkup(label)}"` : 'aria-hidden="true"'}><path fill="#559EE2" d="m0-30000h90000v60000H0"/><path fill="#fff" d="m41750 0 13568-4408-8386 11541V-7133l8386 11541zm925 8021a15000 15000 0 1 1 0-16042 12000 12000 0 1 0 0 16042"/></svg>`;
|
|
102
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { iconSVG, flagSVG, iconNames, coloredIconNames, directionalIcons, iconCatalog, iconCategories, findIcons } from './icons.js';
|
|
2
|
+
export type { IconCategory, IconFilter, IconEntry, IconVariant } from './icons.js';
|
|
3
|
+
export { mapSVG, mapMetadata } from './maps.js';
|
|
4
|
+
export type { MapMetadata } from './maps.js';
|
|
5
|
+
export interface Controller { destroy(): void }
|
|
6
|
+
export declare function bindDialog(dialog: HTMLDialogElement, options?: { trigger?: HTMLElement; initialFocus?: HTMLElement; dismissOutside?: boolean }): Controller & { open(): void; close(value?: string): void };
|
|
7
|
+
export declare function bindDisclosure(button: HTMLElement, panel: HTMLElement): Controller & { setOpen(value: boolean): void; toggle(): void };
|
|
8
|
+
export declare function bindTabs(container: HTMLElement): Controller & { select(tab: HTMLElement, focus?: boolean): void };
|
|
9
|
+
export interface FormError { field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; message: string }
|
|
10
|
+
export declare function validateForm(form: HTMLFormElement, options?: { messages?: Record<string, string> }): FormError[];
|
|
11
|
+
export declare function bindForm(form: HTMLFormElement, options?: { messages?: Record<string, string>; onValid?: (form: HTMLFormElement, event: SubmitEvent) => void }): Controller & { validate(): FormError[] };
|
|
12
|
+
export declare function showToast(region: HTMLElement, message: string, options?: { duration?: number; dismissLabel?: string }): Controller & { element: HTMLElement; dismiss(): void };
|
|
13
|
+
|
|
14
|
+
export * from './writing.js';
|
|
15
|
+
export * from './application.js';
|
|
16
|
+
export * from './interactions.js';
|
|
17
|
+
export * from './themes.js';
|