geez-input 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -53
- package/dist/main.d.ts +2 -24
- package/dist/main.js +42 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@ A type-safe React library for Geez (Ethiopic) script input with phonetic keyboar
|
|
|
7
7
|
- **Type-Safe**: Built with TypeScript for full type safety with comprehensive JSDoc documentation
|
|
8
8
|
- **Phonetic Keyboard**: Intuitive Latin-to-Geez transformation following standard conventions
|
|
9
9
|
- **Customizable Components**: Pre-styled input and textarea components with toggle support
|
|
10
|
-
- **React Hook**: `useGeez` hook for custom implementations
|
|
11
10
|
- **Form Library Support**: Works with React Hook Form, Formik, and other form libraries
|
|
12
11
|
- **Controlled & Uncontrolled**: Full support for both component patterns
|
|
13
12
|
|
|
@@ -72,27 +71,6 @@ function MyForm() {
|
|
|
72
71
|
}
|
|
73
72
|
```
|
|
74
73
|
|
|
75
|
-
## Hook API
|
|
76
|
-
|
|
77
|
-
### useGeez
|
|
78
|
-
|
|
79
|
-
For custom implementations, use the `useGeez` hook:
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
import { useGeez } from 'geez-input'
|
|
83
|
-
|
|
84
|
-
function CustomInput() {
|
|
85
|
-
const { onKeyDown } = useGeez({
|
|
86
|
-
enabled: true,
|
|
87
|
-
onTransform: (result) => {
|
|
88
|
-
console.log('Transformed:', result)
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
return <input onKeyDown={onKeyDown} />
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
74
|
## Phonetic Guide
|
|
97
75
|
|
|
98
76
|
The library uses intuitive phonetic mappings:
|
|
@@ -147,39 +125,9 @@ Props:
|
|
|
147
125
|
- `className?: string` - Additional CSS classes
|
|
148
126
|
- `...TextareaHTMLAttributes` - All standard HTML textarea attributes
|
|
149
127
|
|
|
150
|
-
### Hooks
|
|
151
|
-
|
|
152
|
-
#### useGeez(options)
|
|
153
|
-
|
|
154
|
-
Options:
|
|
155
|
-
- `enabled?: boolean` - Enable/disable transformation (default: `true`)
|
|
156
|
-
- `onTransform?: (result: EngineResult) => void` - Callback after each transformation
|
|
157
|
-
|
|
158
|
-
Returns:
|
|
159
|
-
- `onKeyDown: KeyboardEventHandler` - Event handler for keyboard events
|
|
160
|
-
|
|
161
|
-
### Engine
|
|
162
|
-
|
|
163
|
-
#### GeezEngine.transform(textBefore, textAfter, key)
|
|
164
|
-
|
|
165
|
-
Core transformation method:
|
|
166
|
-
- `textBefore: string` - Text before cursor
|
|
167
|
-
- `textAfter: string` - Text after cursor
|
|
168
|
-
- `key: string` - Key pressed
|
|
169
|
-
- Returns: `EngineResult`
|
|
170
|
-
|
|
171
128
|
## TypeScript Support
|
|
172
129
|
|
|
173
|
-
The library is written in TypeScript and provides comprehensive type definitions
|
|
174
|
-
|
|
175
|
-
```tsx
|
|
176
|
-
import type {
|
|
177
|
-
GeezOptions,
|
|
178
|
-
EngineResult,
|
|
179
|
-
PhoneticMap,
|
|
180
|
-
SyllableMap
|
|
181
|
-
} from 'geez-input'
|
|
182
|
-
```
|
|
130
|
+
The library is written in TypeScript and provides comprehensive type definitions for all component props.
|
|
183
131
|
|
|
184
132
|
## Browser Support
|
|
185
133
|
|
package/dist/main.d.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Geez Input Library - Phonetic keyboard support for Geez/Ethiopic script in React
|
|
4
4
|
*
|
|
5
|
-
* This library provides React components
|
|
5
|
+
* This library provides React components for typing in Geez (Ethiopic) script
|
|
6
6
|
* using Latin phonetic characters. It supports Amharic, Tigrinya, and other languages
|
|
7
7
|
* written in the Geez script.
|
|
8
8
|
*
|
|
9
9
|
* ## Quick Start
|
|
10
10
|
*
|
|
11
11
|
* \`\`\`tsx
|
|
12
|
-
* import { GeezInput, GeezTextArea
|
|
12
|
+
* import { GeezInput, GeezTextArea } from 'geez-input'
|
|
13
13
|
*
|
|
14
14
|
* function App() {
|
|
15
15
|
* return (
|
|
@@ -26,28 +26,6 @@
|
|
|
26
26
|
* ### Components
|
|
27
27
|
* - {@link GeezInput} - Styled input with Geez keyboard
|
|
28
28
|
* - {@link GeezTextArea} - Styled textarea with Geez keyboard
|
|
29
|
-
*
|
|
30
|
-
* ### Hooks
|
|
31
|
-
* - {@link useGeez} - Hook for custom implementations
|
|
32
|
-
*
|
|
33
|
-
* ### Engine
|
|
34
|
-
* - {@link GeezEngine} - Core transformation engine
|
|
35
|
-
*
|
|
36
|
-
* ### Types
|
|
37
|
-
* - {@link GeezOptions} - Configuration options
|
|
38
|
-
* - {@link EngineResult} - Transformation result
|
|
39
|
-
* - {@link PhoneticMap} - Character mapping type
|
|
40
|
-
* - {@link SyllableMap} - Syllable mapping type
|
|
41
|
-
*
|
|
42
|
-
* ### Mappings
|
|
43
|
-
* - {@link CONSONANTS} - Base consonant mappings
|
|
44
|
-
* - {@link SYLLABLES} - Syllable form mappings
|
|
45
|
-
* - {@link PUNCTUATION} - Punctuation mappings
|
|
46
|
-
* - {@link MULTI_CONSONANTS} - Multi-character consonants
|
|
47
29
|
*/
|
|
48
|
-
export * from './engine';
|
|
49
|
-
export * from './use-geez';
|
|
50
|
-
export * from './types';
|
|
51
|
-
export * from './mapping';
|
|
52
30
|
export * from './components/geez-input';
|
|
53
31
|
export * from './components/geez-textarea';
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { jsxs as v, jsx as f } from "react/jsx-runtime";
|
|
1
2
|
import { useCallback as S, forwardRef as y, useState as N } from "react";
|
|
2
|
-
import
|
|
3
|
-
import './assets/main.css';const z = {
|
|
3
|
+
import './assets/main.css';const A = {
|
|
4
4
|
h: "ህ",
|
|
5
5
|
l: "ል",
|
|
6
6
|
m: "ም",
|
|
@@ -384,7 +384,7 @@ import './assets/main.css';const z = {
|
|
|
384
384
|
o: "ቮ",
|
|
385
385
|
ua: "ቯ"
|
|
386
386
|
}
|
|
387
|
-
},
|
|
387
|
+
}, z = {
|
|
388
388
|
ስh: "ሽ",
|
|
389
389
|
ችh: "ች",
|
|
390
390
|
ንy: "ኝ",
|
|
@@ -398,7 +398,7 @@ import './assets/main.css';const z = {
|
|
|
398
398
|
"፣,": "፤",
|
|
399
399
|
";": "፤"
|
|
400
400
|
};
|
|
401
|
-
class
|
|
401
|
+
class T {
|
|
402
402
|
/**
|
|
403
403
|
* Transform input text based on a new key press
|
|
404
404
|
*
|
|
@@ -444,9 +444,9 @@ class P {
|
|
|
444
444
|
newCursorPosition: e.length + 1,
|
|
445
445
|
isReplacement: !1
|
|
446
446
|
};
|
|
447
|
-
if (
|
|
447
|
+
if (z[s])
|
|
448
448
|
return {
|
|
449
|
-
transformedValue: e.slice(0, -1) +
|
|
449
|
+
transformedValue: e.slice(0, -1) + z[s] + a,
|
|
450
450
|
newCursorPosition: e.length,
|
|
451
451
|
isReplacement: !0
|
|
452
452
|
};
|
|
@@ -468,8 +468,8 @@ class P {
|
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
return
|
|
472
|
-
transformedValue: e +
|
|
471
|
+
return A[i] ? {
|
|
472
|
+
transformedValue: e + A[i] + a,
|
|
473
473
|
newCursorPosition: e.length + 1,
|
|
474
474
|
isReplacement: !1
|
|
475
475
|
} : {
|
|
@@ -501,7 +501,7 @@ class P {
|
|
|
501
501
|
return null;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const D = (r = {}) => {
|
|
505
505
|
const { enabled: e = !0, onTransform: a } = r;
|
|
506
506
|
return { onKeyDown: S(
|
|
507
507
|
(n) => {
|
|
@@ -521,7 +521,7 @@ const K = (r = {}) => {
|
|
|
521
521
|
"PageDown"
|
|
522
522
|
].includes(n.key) || n.ctrlKey || n.metaKey || n.key.length !== 1 || n.altKey) return;
|
|
523
523
|
n.preventDefault();
|
|
524
|
-
const t = n.currentTarget, { selectionStart: l, selectionEnd:
|
|
524
|
+
const t = n.currentTarget, { selectionStart: l, selectionEnd: h, value: p } = t, o = p.substring(0, l || 0), w = p.substring(h || 0), c = T.transform(o, w, n.key), d = Object.getOwnPropertyDescriptor(t.constructor.prototype, "value");
|
|
525
525
|
d && d.set ? d.set.bind(t)(c.transformedValue) : t.value = c.transformedValue;
|
|
526
526
|
let E;
|
|
527
527
|
typeof InputEvent < "u" ? E = new InputEvent("input", {
|
|
@@ -530,11 +530,11 @@ const K = (r = {}) => {
|
|
|
530
530
|
inputType: "insertText",
|
|
531
531
|
data: n.key
|
|
532
532
|
}) : E = new Event("input", { bubbles: !0, cancelable: !0 }), t.dispatchEvent(E);
|
|
533
|
-
const
|
|
533
|
+
const u = new Event("change", {
|
|
534
534
|
bubbles: !0,
|
|
535
535
|
cancelable: !0
|
|
536
536
|
});
|
|
537
|
-
t.dispatchEvent(
|
|
537
|
+
t.dispatchEvent(u), requestAnimationFrame(() => {
|
|
538
538
|
if (document.activeElement === t)
|
|
539
539
|
try {
|
|
540
540
|
t.setSelectionRange(c.newCursorPosition, c.newCursorPosition);
|
|
@@ -548,32 +548,30 @@ const K = (r = {}) => {
|
|
|
548
548
|
function m(...r) {
|
|
549
549
|
return r.filter(Boolean).join(" ");
|
|
550
550
|
}
|
|
551
|
-
const
|
|
552
|
-
({ defaultGeez: r = !0, wrapperClassName: e, inputClassName: a, buttonClassName: i, className: n, onChange: s, onKeyDown: t, value: l, ...
|
|
553
|
-
const [o,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}, { onKeyDown: d } = K({ enabled: o }), E = (u) => {
|
|
557
|
-
d(u), t && t(u);
|
|
558
|
-
}, w = (u) => {
|
|
551
|
+
const G = y(
|
|
552
|
+
({ defaultGeez: r = !0, wrapperClassName: e, inputClassName: a, buttonClassName: i, className: n, onChange: s, onKeyDown: t, value: l, ...h }, p) => {
|
|
553
|
+
const [o, w] = N(r), { onKeyDown: c } = D({ enabled: o }), d = (u) => {
|
|
554
|
+
c(u), t && t(u);
|
|
555
|
+
}, E = (u) => {
|
|
559
556
|
s && s(u);
|
|
560
557
|
};
|
|
561
|
-
return /* @__PURE__ */
|
|
562
|
-
/* @__PURE__ */
|
|
558
|
+
return /* @__PURE__ */ v("div", { className: m("geez-input-wrapper", e), children: [
|
|
559
|
+
/* @__PURE__ */ f(
|
|
563
560
|
"input",
|
|
564
561
|
{
|
|
565
|
-
...
|
|
562
|
+
...h,
|
|
563
|
+
...l !== void 0 && { value: l },
|
|
566
564
|
ref: p,
|
|
567
|
-
onKeyDown:
|
|
568
|
-
onChange:
|
|
565
|
+
onKeyDown: d,
|
|
566
|
+
onChange: E,
|
|
569
567
|
className: m("geez-input-field", n, a)
|
|
570
568
|
}
|
|
571
569
|
),
|
|
572
|
-
/* @__PURE__ */
|
|
570
|
+
/* @__PURE__ */ f(
|
|
573
571
|
"button",
|
|
574
572
|
{
|
|
575
573
|
type: "button",
|
|
576
|
-
onClick: () =>
|
|
574
|
+
onClick: () => w(!o),
|
|
577
575
|
className: m(
|
|
578
576
|
"geez-input-toggle",
|
|
579
577
|
o ? "geez-input-toggle--active" : "geez-input-toggle--inactive",
|
|
@@ -587,33 +585,31 @@ const T = y(
|
|
|
587
585
|
] });
|
|
588
586
|
}
|
|
589
587
|
);
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
({ defaultGeez: r = !0, wrapperClassName: e, textareaClassName: a, buttonClassName: i, className: n, onChange: s, onKeyDown: t, value: l, ...
|
|
593
|
-
const [o,
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}, { onKeyDown: d } = K({ enabled: o }), E = (u) => {
|
|
597
|
-
d(u), t && t(u);
|
|
598
|
-
}, w = (u) => {
|
|
588
|
+
G.displayName = "GeezInput";
|
|
589
|
+
const P = y(
|
|
590
|
+
({ defaultGeez: r = !0, wrapperClassName: e, textareaClassName: a, buttonClassName: i, className: n, onChange: s, onKeyDown: t, value: l, ...h }, p) => {
|
|
591
|
+
const [o, w] = N(r), { onKeyDown: c } = D({ enabled: o }), d = (u) => {
|
|
592
|
+
c(u), t && t(u);
|
|
593
|
+
}, E = (u) => {
|
|
599
594
|
s && s(u);
|
|
600
595
|
};
|
|
601
|
-
return /* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
596
|
+
return /* @__PURE__ */ v("div", { className: m("geez-textarea-wrapper", e), children: [
|
|
597
|
+
/* @__PURE__ */ f(
|
|
603
598
|
"textarea",
|
|
604
599
|
{
|
|
605
|
-
...
|
|
600
|
+
...h,
|
|
601
|
+
...l !== void 0 && { value: l },
|
|
606
602
|
ref: p,
|
|
607
|
-
onKeyDown:
|
|
608
|
-
onChange:
|
|
603
|
+
onKeyDown: d,
|
|
604
|
+
onChange: E,
|
|
609
605
|
className: m("geez-textarea-field", n, a)
|
|
610
606
|
}
|
|
611
607
|
),
|
|
612
|
-
/* @__PURE__ */
|
|
608
|
+
/* @__PURE__ */ f(
|
|
613
609
|
"button",
|
|
614
610
|
{
|
|
615
611
|
type: "button",
|
|
616
|
-
onClick: () =>
|
|
612
|
+
onClick: () => w(!o),
|
|
617
613
|
className: m(
|
|
618
614
|
"geez-textarea-toggle",
|
|
619
615
|
o ? "geez-textarea-toggle--active" : "geez-textarea-toggle--inactive",
|
|
@@ -627,14 +623,8 @@ const G = y(
|
|
|
627
623
|
] });
|
|
628
624
|
}
|
|
629
625
|
);
|
|
630
|
-
|
|
626
|
+
P.displayName = "GeezTextArea";
|
|
631
627
|
export {
|
|
632
|
-
|
|
633
|
-
P as
|
|
634
|
-
T as GeezInput,
|
|
635
|
-
G as GeezTextArea,
|
|
636
|
-
v as MULTI_CONSONANTS,
|
|
637
|
-
b as PUNCTUATION,
|
|
638
|
-
g as SYLLABLES,
|
|
639
|
-
K as useGeez
|
|
628
|
+
G as GeezInput,
|
|
629
|
+
P as GeezTextArea
|
|
640
630
|
};
|