react-balochi-input
Version:
Seamless Balochi typing in React, no system adjustments needed.
755 lines (751 loc) • 23.6 kB
JavaScript
import Pe, { useState as ee, useEffect as ur } from "react";
var re = { exports: {} }, $ = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Ce;
function sr() {
if (Ce)
return $;
Ce = 1;
var I = Pe, w = Symbol.for("react.element"), M = Symbol.for("react.fragment"), S = Object.prototype.hasOwnProperty, O = I.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 };
function P(E, d, C) {
var v, y = {}, m = null, D = null;
C !== void 0 && (m = "" + C), d.key !== void 0 && (m = "" + d.key), d.ref !== void 0 && (D = d.ref);
for (v in d)
S.call(d, v) && !j.hasOwnProperty(v) && (y[v] = d[v]);
if (E && E.defaultProps)
for (v in d = E.defaultProps, d)
y[v] === void 0 && (y[v] = d[v]);
return { $$typeof: w, type: E, key: m, ref: D, props: y, _owner: O.current };
}
return $.Fragment = M, $.jsx = P, $.jsxs = P, $;
}
var Y = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Oe;
function fr() {
return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && function() {
var I = Pe, w = Symbol.for("react.element"), M = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), P = Symbol.for("react.provider"), E = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), b = Symbol.iterator, R = "@@iterator";
function p(e) {
if (e === null || typeof e != "object")
return null;
var r = b && e[b] || e[R];
return typeof r == "function" ? r : null;
}
var c = I.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function s(e) {
{
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
t[n - 1] = arguments[n];
x("error", e, t);
}
}
function x(e, r, t) {
{
var n = c.ReactDebugCurrentFrame, o = n.getStackAddendum();
o !== "" && (r += "%s", t = t.concat([o]));
var u = t.map(function(i) {
return String(i);
});
u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
}
}
var xe = !1, ke = !1, je = !1, De = !1, Fe = !1, te;
te = Symbol.for("react.module.reference");
function Ae(e) {
return !!(typeof e == "string" || typeof e == "function" || e === S || e === j || Fe || e === O || e === C || e === v || De || e === D || xe || ke || je || typeof e == "object" && e !== null && (e.$$typeof === m || e.$$typeof === y || e.$$typeof === P || e.$$typeof === E || e.$$typeof === d || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
e.$$typeof === te || e.getModuleId !== void 0));
}
function Ie(e, r, t) {
var n = e.displayName;
if (n)
return n;
var o = r.displayName || r.name || "";
return o !== "" ? t + "(" + o + ")" : t;
}
function ne(e) {
return e.displayName || "Context";
}
function _(e) {
if (e == null)
return null;
if (typeof e.tag == "number" && s("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
return e.displayName || e.name || null;
if (typeof e == "string")
return e;
switch (e) {
case S:
return "Fragment";
case M:
return "Portal";
case j:
return "Profiler";
case O:
return "StrictMode";
case C:
return "Suspense";
case v:
return "SuspenseList";
}
if (typeof e == "object")
switch (e.$$typeof) {
case E:
var r = e;
return ne(r) + ".Consumer";
case P:
var t = e;
return ne(t._context) + ".Provider";
case d:
return Ie(e, e.render, "ForwardRef");
case y:
var n = e.displayName || null;
return n !== null ? n : _(e.type) || "Memo";
case m: {
var o = e, u = o._payload, i = o._init;
try {
return _(i(u));
} catch {
return null;
}
}
}
return null;
}
var k = Object.assign, L = 0, ae, ie, oe, ue, se, fe, le;
function ce() {
}
ce.__reactDisabledLog = !0;
function Me() {
{
if (L === 0) {
ae = console.log, ie = console.info, oe = console.warn, ue = console.error, se = console.group, fe = console.groupCollapsed, le = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: ce,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
L++;
}
}
function Le() {
{
if (L--, L === 0) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: k({}, e, {
value: ae
}),
info: k({}, e, {
value: ie
}),
warn: k({}, e, {
value: oe
}),
error: k({}, e, {
value: ue
}),
group: k({}, e, {
value: se
}),
groupCollapsed: k({}, e, {
value: fe
}),
groupEnd: k({}, e, {
value: le
})
});
}
L < 0 && s("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var J = c.ReactCurrentDispatcher, K;
function V(e, r, t) {
{
if (K === void 0)
try {
throw Error();
} catch (o) {
var n = o.stack.trim().match(/\n( *(at )?)/);
K = n && n[1] || "";
}
return `
` + K + e;
}
}
var G = !1, N;
{
var We = typeof WeakMap == "function" ? WeakMap : Map;
N = new We();
}
function de(e, r) {
if (!e || G)
return "";
{
var t = N.get(e);
if (t !== void 0)
return t;
}
var n;
G = !0;
var o = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var u;
u = J.current, J.current = null, Me();
try {
if (r) {
var i = function() {
throw Error();
};
if (Object.defineProperty(i.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(i, []);
} catch (T) {
n = T;
}
Reflect.construct(e, [], i);
} else {
try {
i.call();
} catch (T) {
n = T;
}
e.call(i.prototype);
}
} else {
try {
throw Error();
} catch (T) {
n = T;
}
e();
}
} catch (T) {
if (T && n && typeof T.stack == "string") {
for (var a = T.stack.split(`
`), h = n.stack.split(`
`), f = a.length - 1, l = h.length - 1; f >= 1 && l >= 0 && a[f] !== h[l]; )
l--;
for (; f >= 1 && l >= 0; f--, l--)
if (a[f] !== h[l]) {
if (f !== 1 || l !== 1)
do
if (f--, l--, l < 0 || a[f] !== h[l]) {
var g = `
` + a[f].replace(" at new ", " at ");
return e.displayName && g.includes("<anonymous>") && (g = g.replace("<anonymous>", e.displayName)), typeof e == "function" && N.set(e, g), g;
}
while (f >= 1 && l >= 0);
break;
}
}
} finally {
G = !1, J.current = u, Le(), Error.prepareStackTrace = o;
}
var A = e ? e.displayName || e.name : "", Se = A ? V(A) : "";
return typeof e == "function" && N.set(e, Se), Se;
}
function $e(e, r, t) {
return de(e, !1);
}
function Ye(e) {
var r = e.prototype;
return !!(r && r.isReactComponent);
}
function U(e, r, t) {
if (e == null)
return "";
if (typeof e == "function")
return de(e, Ye(e));
if (typeof e == "string")
return V(e);
switch (e) {
case C:
return V("Suspense");
case v:
return V("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case d:
return $e(e.render);
case y:
return U(e.type, r, t);
case m: {
var n = e, o = n._payload, u = n._init;
try {
return U(u(o), r, t);
} catch {
}
}
}
return "";
}
var B = Object.prototype.hasOwnProperty, ve = {}, pe = c.ReactDebugCurrentFrame;
function q(e) {
if (e) {
var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
pe.setExtraStackFrame(t);
} else
pe.setExtraStackFrame(null);
}
function Ve(e, r, t, n, o) {
{
var u = Function.call.bind(B);
for (var i in e)
if (u(e, i)) {
var a = void 0;
try {
if (typeof e[i] != "function") {
var h = Error((n || "React class") + ": " + t + " type `" + i + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[i] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw h.name = "Invariant Violation", h;
}
a = e[i](r, i, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (f) {
a = f;
}
a && !(a instanceof Error) && (q(o), s("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, i, typeof a), q(null)), a instanceof Error && !(a.message in ve) && (ve[a.message] = !0, q(o), s("Failed %s type: %s", t, a.message), q(null));
}
}
}
var Ne = Array.isArray;
function z(e) {
return Ne(e);
}
function Ue(e) {
{
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
return t;
}
}
function Be(e) {
try {
return he(e), !1;
} catch {
return !0;
}
}
function he(e) {
return "" + e;
}
function ge(e) {
if (Be(e))
return s("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ue(e)), he(e);
}
var W = c.ReactCurrentOwner, qe = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, ye, Ee, H;
H = {};
function Je(e) {
if (B.call(e, "ref")) {
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
if (r && r.isReactWarning)
return !1;
}
return e.ref !== void 0;
}
function Ke(e) {
if (B.call(e, "key")) {
var r = Object.getOwnPropertyDescriptor(e, "key").get;
if (r && r.isReactWarning)
return !1;
}
return e.key !== void 0;
}
function Ge(e, r) {
if (typeof e.ref == "string" && W.current && r && W.current.stateNode !== r) {
var t = _(W.current.type);
H[t] || (s('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', _(W.current.type), e.ref), H[t] = !0);
}
}
function ze(e, r) {
{
var t = function() {
ye || (ye = !0, s("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
};
t.isReactWarning = !0, Object.defineProperty(e, "key", {
get: t,
configurable: !0
});
}
}
function He(e, r) {
{
var t = function() {
Ee || (Ee = !0, s("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
};
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
get: t,
configurable: !0
});
}
}
var Xe = function(e, r, t, n, o, u, i) {
var a = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: w,
// Built-in properties that belong on the element
type: e,
key: r,
ref: t,
props: i,
// Record the component responsible for creating this element.
_owner: u
};
return a._store = {}, Object.defineProperty(a._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(a, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: n
}), Object.defineProperty(a, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: o
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
};
function Ze(e, r, t, n, o) {
{
var u, i = {}, a = null, h = null;
t !== void 0 && (ge(t), a = "" + t), Ke(r) && (ge(r.key), a = "" + r.key), Je(r) && (h = r.ref, Ge(r, o));
for (u in r)
B.call(r, u) && !qe.hasOwnProperty(u) && (i[u] = r[u]);
if (e && e.defaultProps) {
var f = e.defaultProps;
for (u in f)
i[u] === void 0 && (i[u] = f[u]);
}
if (a || h) {
var l = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
a && ze(i, l), h && He(i, l);
}
return Xe(e, a, h, o, n, W.current, i);
}
}
var X = c.ReactCurrentOwner, be = c.ReactDebugCurrentFrame;
function F(e) {
if (e) {
var r = e._owner, t = U(e.type, e._source, r ? r.type : null);
be.setExtraStackFrame(t);
} else
be.setExtraStackFrame(null);
}
var Z;
Z = !1;
function Q(e) {
return typeof e == "object" && e !== null && e.$$typeof === w;
}
function me() {
{
if (X.current) {
var e = _(X.current.type);
if (e)
return `
Check the render method of \`` + e + "`.";
}
return "";
}
}
function Qe(e) {
{
if (e !== void 0) {
var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber;
return `
Check your code at ` + r + ":" + t + ".";
}
return "";
}
}
var Re = {};
function er(e) {
{
var r = me();
if (!r) {
var t = typeof e == "string" ? e : e.displayName || e.name;
t && (r = `
Check the top-level render call using <` + t + ">.");
}
return r;
}
}
function _e(e, r) {
{
if (!e._store || e._store.validated || e.key != null)
return;
e._store.validated = !0;
var t = er(r);
if (Re[t])
return;
Re[t] = !0;
var n = "";
e && e._owner && e._owner !== X.current && (n = " It was passed a child from " + _(e._owner.type) + "."), F(e), s('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), F(null);
}
}
function Te(e, r) {
{
if (typeof e != "object")
return;
if (z(e))
for (var t = 0; t < e.length; t++) {
var n = e[t];
Q(n) && _e(n, r);
}
else if (Q(e))
e._store && (e._store.validated = !0);
else if (e) {
var o = p(e);
if (typeof o == "function" && o !== e.entries)
for (var u = o.call(e), i; !(i = u.next()).done; )
Q(i.value) && _e(i.value, r);
}
}
}
function rr(e) {
{
var r = e.type;
if (r == null || typeof r == "string")
return;
var t;
if (typeof r == "function")
t = r.propTypes;
else if (typeof r == "object" && (r.$$typeof === d || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
r.$$typeof === y))
t = r.propTypes;
else
return;
if (t) {
var n = _(r);
Ve(t, e.props, "prop", n, e);
} else if (r.PropTypes !== void 0 && !Z) {
Z = !0;
var o = _(r);
s("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", o || "Unknown");
}
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && s("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function tr(e) {
{
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
var n = r[t];
if (n !== "children" && n !== "key") {
F(e), s("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), F(null);
break;
}
}
e.ref !== null && (F(e), s("Invalid attribute `ref` supplied to `React.Fragment`."), F(null));
}
}
function we(e, r, t, n, o, u) {
{
var i = Ae(e);
if (!i) {
var a = "";
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var h = Qe(o);
h ? a += h : a += me();
var f;
e === null ? f = "null" : z(e) ? f = "array" : e !== void 0 && e.$$typeof === w ? (f = "<" + (_(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : f = typeof e, s("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", f, a);
}
var l = Ze(e, r, t, o, u);
if (l == null)
return l;
if (i) {
var g = r.children;
if (g !== void 0)
if (n)
if (z(g)) {
for (var A = 0; A < g.length; A++)
Te(g[A], e);
Object.freeze && Object.freeze(g);
} else
s("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
else
Te(g, e);
}
return e === S ? tr(l) : rr(l), l;
}
}
function nr(e, r, t) {
return we(e, r, t, !0);
}
function ar(e, r, t) {
return we(e, r, t, !1);
}
var ir = ar, or = nr;
Y.Fragment = S, Y.jsx = ir, Y.jsxs = or;
}()), Y;
}
process.env.NODE_ENV === "production" ? re.exports = sr() : re.exports = fr();
var lr = re.exports;
const dr = ({
className: I,
onChange: w,
value: M,
placeholder: S,
allowSwitching: O = !1,
...j
}) => {
const [P, E] = ee(!1), [d, C] = ee(!1), v = (b) => {
const R = {
q: "ق",
w: "و",
e: "ع",
r: "ر",
t: "ت",
y: "ے",
u: "ء",
i: "ی",
o: "ہ",
p: "پ",
a: "ا",
s: "س",
d: "د",
f: "ف",
g: "گ",
h: "ھ",
j: "ج",
k: "ک",
l: "ل",
z: "ز",
x: "ش",
c: "چ",
v: "ط",
b: "ب",
n: "ن",
m: "م",
Q: "ءُ",
W: "ؤ",
E: "ءِ",
R: "ڑ",
T: "ٹ",
Y: "ئے",
U: "ٰ",
I: "ئ",
O: "ْ",
P: "ُ",
A: "آ",
S: "ص",
D: "ڈ",
F: "ءَ",
G: "غ",
H: "ح",
J: "ض",
K: "خ",
L: "ئِے",
Z: "ذ",
X: "ژ",
C: "ث",
V: "ظ",
B: "یٔ",
N: "ں",
M: "اَنت",
"`": "ً",
";": "؛",
"'": "ۂ",
",": "،",
".": "۔",
"/": "ْ"
}, p = {
",": "ِ",
// , caps on
"<": "ِ",
".": "َ",
// . caps on
">": "َ",
"/": "؟",
// caps on
"?": "؟",
";": ":",
// caps on
":": ":",
"'": "‘",
// / caps on
'"': "‘",
0: "ّ",
// / caps on
")": "ّ"
};
let c = "";
for (let s = 0; s < b.length; s++) {
const x = b[s];
P && p[x] ? c += p[x] : R[x] ? c += R[x] : c += x;
}
return c;
}, [y, m] = ee(v(M || ""));
ur(() => {
const b = (p) => {
(p.key === "Shift" || p.getModifierState && p.getModifierState("CapsLock")) && E(!0), p.ctrlKey && p.keyCode === 32 && O && C((c) => !c);
}, R = (p) => {
(p.key === "Shift" || p.getModifierState && p.getModifierState("CapsLock")) && E(!1);
};
return window.addEventListener("keydown", b), window.addEventListener("keyup", R), () => {
window.removeEventListener("keydown", b), window.removeEventListener("keyup", R);
};
}, [O]);
const D = (b) => {
const { nativeEvent: R, target: p } = b, { value: c } = p;
let s;
R.inputType === "insertText" && !d ? s = c.slice(0, -1) + v(c.charAt(c.length - 1)) : s = c, m(s), w && w(s);
};
return /* @__PURE__ */ lr.jsx(
"input",
{
dir: "rtl",
type: "text",
className: I,
value: y,
onChange: D,
placeholder: S,
...j
}
);
};
export {
dr as default
};