@pie-lib/mask-markup 3.0.4-next.33 → 3.0.4-next.36

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.
Files changed (107) hide show
  1. package/CHANGELOG.json +17 -0
  2. package/CHANGELOG.md +1256 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/choices/choice.js +116 -0
  5. package/lib/choices/choice.js.map +1 -0
  6. package/lib/choices/index.js +103 -0
  7. package/lib/choices/index.js.map +1 -0
  8. package/lib/componentize.js +21 -0
  9. package/lib/componentize.js.map +1 -0
  10. package/lib/components/blank.js +371 -0
  11. package/lib/components/blank.js.map +1 -0
  12. package/lib/components/correct-input.js +94 -0
  13. package/lib/components/correct-input.js.map +1 -0
  14. package/lib/components/dropdown.js +483 -0
  15. package/lib/components/dropdown.js.map +1 -0
  16. package/lib/components/input.js +50 -0
  17. package/lib/components/input.js.map +1 -0
  18. package/lib/constructed-response.js +101 -0
  19. package/lib/constructed-response.js.map +1 -0
  20. package/lib/customizable.js +42 -0
  21. package/lib/customizable.js.map +1 -0
  22. package/lib/drag-in-the-blank.js +254 -0
  23. package/lib/drag-in-the-blank.js.map +1 -0
  24. package/lib/index.js +55 -0
  25. package/lib/index.js.map +1 -0
  26. package/lib/inline-dropdown.js +40 -0
  27. package/lib/inline-dropdown.js.map +1 -0
  28. package/lib/mask.js +198 -0
  29. package/lib/mask.js.map +1 -0
  30. package/lib/serialization.js +261 -0
  31. package/lib/serialization.js.map +1 -0
  32. package/lib/with-mask.js +97 -0
  33. package/lib/with-mask.js.map +1 -0
  34. package/package.json +20 -39
  35. package/src/__tests__/drag-in-the-blank.test.js +111 -0
  36. package/src/__tests__/index.test.js +38 -0
  37. package/src/__tests__/mask.test.js +381 -0
  38. package/src/__tests__/serialization.test.js +54 -0
  39. package/src/__tests__/utils.js +1 -0
  40. package/src/__tests__/with-mask.test.js +76 -0
  41. package/src/choices/__tests__/index.test.js +75 -0
  42. package/src/choices/choice.jsx +97 -0
  43. package/src/choices/index.jsx +64 -0
  44. package/src/componentize.js +13 -0
  45. package/src/components/__tests__/blank.test.js +199 -0
  46. package/src/components/__tests__/correct-input.test.js +90 -0
  47. package/src/components/__tests__/dropdown.test.js +129 -0
  48. package/src/components/__tests__/input.test.js +102 -0
  49. package/src/components/blank.jsx +386 -0
  50. package/src/components/correct-input.jsx +82 -0
  51. package/src/components/dropdown.jsx +423 -0
  52. package/src/components/input.jsx +48 -0
  53. package/src/constructed-response.jsx +87 -0
  54. package/src/customizable.jsx +34 -0
  55. package/src/drag-in-the-blank.jsx +241 -0
  56. package/src/index.js +16 -0
  57. package/src/inline-dropdown.jsx +29 -0
  58. package/src/mask.jsx +172 -0
  59. package/src/serialization.js +260 -0
  60. package/src/with-mask.jsx +75 -0
  61. package/dist/_virtual/_rolldown/runtime.js +0 -4
  62. package/dist/choices/choice.d.ts +0 -24
  63. package/dist/choices/choice.js +0 -77
  64. package/dist/choices/index.d.ts +0 -25
  65. package/dist/choices/index.js +0 -49
  66. package/dist/componentize.d.ts +0 -12
  67. package/dist/componentize.js +0 -4
  68. package/dist/components/blank.d.ts +0 -39
  69. package/dist/components/blank.js +0 -240
  70. package/dist/components/correct-input.d.ts +0 -11
  71. package/dist/components/dropdown.d.ts +0 -37
  72. package/dist/components/dropdown.js +0 -320
  73. package/dist/components/input.d.ts +0 -37
  74. package/dist/constructed-response.d.ts +0 -44
  75. package/dist/constructed-response.js +0 -55
  76. package/dist/customizable.d.ts +0 -43
  77. package/dist/customizable.js +0 -8
  78. package/dist/drag-in-the-blank.d.ts +0 -37
  79. package/dist/drag-in-the-blank.js +0 -164
  80. package/dist/index.d.ts +0 -15
  81. package/dist/index.js +0 -7
  82. package/dist/inline-dropdown.d.ts +0 -44
  83. package/dist/inline-dropdown.js +0 -24
  84. package/dist/mask.d.ts +0 -30
  85. package/dist/mask.js +0 -99
  86. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  87. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js +0 -17
  88. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssPrefix.js +0 -9
  89. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssUnitless.js +0 -26
  90. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/hasOwn.js +0 -11
  91. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isFunction.js +0 -11
  92. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isObject.js +0 -11
  93. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixInfo.js +0 -24
  94. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixProperties.js +0 -32
  95. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixer.js +0 -29
  96. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/camelize.js +0 -14
  97. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenRe.js +0 -8
  98. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenate.js +0 -12
  99. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/separate.js +0 -11
  100. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toLowerFirst.js +0 -10
  101. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toUpperFirst.js +0 -10
  102. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js +0 -55
  103. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js +0 -16
  104. package/dist/serialization.d.ts +0 -34
  105. package/dist/serialization.js +0 -132
  106. package/dist/with-mask.d.ts +0 -55
  107. package/dist/with-mask.js +0 -45
@@ -1,55 +0,0 @@
1
- import { __commonJSMin as e } from "../../../../../../_virtual/_rolldown/runtime.js";
2
- import { require_cssUnitless as t } from "./cssUnitless.js";
3
- import { require_prefixInfo as n } from "./prefixInfo.js";
4
- import { require_camelize as r } from "./stringUtils/camelize.js";
5
- import { require_hyphenate as i } from "./stringUtils/hyphenate.js";
6
- import { require_cssPrefix as a } from "./cssPrefix.js";
7
- import { require_hasOwn as o } from "./hasOwn.js";
8
- import { require_isObject as s } from "./isObject.js";
9
- import { require_isFunction as c } from "./isFunction.js";
10
- //#region ../../../node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js
11
- var l = /* @__PURE__ */ e(((e, l) => {
12
- n();
13
- var u = a(), d = i(), f = r(), p = o(), m = s(), h = c(), g = function(e, t, n, r) {
14
- u(t).forEach(function(t) {
15
- e[r ? r(t) : t] = n;
16
- });
17
- }, _ = function(e) {
18
- e = (e || "").split(";");
19
- var t = {};
20
- return e.forEach(function(e) {
21
- var n = e.split(":");
22
- n.length == 2 && (t[n[0].trim()] = n[1].trim());
23
- }), t;
24
- }, v = { cssUnitless: t() }, y = function(e, t, n, r) {
25
- typeof e == "string" && (e = _(e)), t ||= v, t.cssUnitless = t.cssUnitless || v.cssUnitless, r ||= {};
26
- var i = t.scope || {}, a = t.addUnits == null ? i && i.addUnits != null ? i.addUnits : !0 : t.addUnits, o = (t.cssUnitless == null ? i ? i.cssUnitless : null : t.cssUnitless) || {}, s = (t.cssUnit || i ? i.cssUnit : null) || "px", c = t.prefixProperties || (i ? i.prefixProperties : null) || {}, l = t.camelize ? f : d, u, b, x, S, C, w, T, E;
27
- for (x in e) if (p(e, x)) {
28
- if (S = e[x], b = d(n ? n + x : x), u = !1, E = !1, h(S) && (T = S.call(i || e, S, x, b, e), m(T) && T.value != null ? (S = T.value, E = T.prefix, b = T.name ? d(T.name) : b) : S = T), C = typeof S, w = C == "number" || C == "string" && S != "" && S * 1 == S, S == null || b == null || b === "") continue;
29
- if ((w || C == "string") && (u = !0), !u && S.value != null && S.prefix && (u = !0, E = S.prefix, S = S.value), u) {
30
- if (E ||= !!c[b], w && (S = a && !(b in o) ? S + s : S + ""), (b == "border" || !b.indexOf("border") && !~b.indexOf("radius") && !~b.indexOf("width")) && w && (b += "-width"), !b.indexOf("border-radius-") && (b.replace(/border(-radius)(-(.*))/, function(e, t, n) {
31
- var r = {
32
- "-top": ["-top-left", "-top-right"],
33
- "-left": ["-top-left", "-bottom-left"],
34
- "-right": ["-top-right", "-bottom-right"],
35
- "-bottom": ["-bottom-left", "-bottom-right"]
36
- };
37
- n in r ? (b = [], r[n].forEach(function(e) {
38
- b.push("border" + e + t);
39
- })) : b = "border" + n + t;
40
- }), Array.isArray(b))) {
41
- b.forEach(function(e) {
42
- E ? g(r, e, S, l) : r[l(e)] = S;
43
- });
44
- continue;
45
- }
46
- E ? g(r, b, S, l) : r[l(b)] = S;
47
- } else y(S, t, b + "-", r);
48
- }
49
- return r;
50
- };
51
- l.exports = y;
52
- }));
53
- //#endregion
54
- export default l();
55
- export { l as require_toStyleObject };
@@ -1,16 +0,0 @@
1
- import { __commonJSMin as e } from "../../../../../../_virtual/_rolldown/runtime.js";
2
- import { require_hasOwn as t } from "./hasOwn.js";
3
- import { require_toStyleObject as n } from "./toStyleObject.js";
4
- //#region ../../../node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js
5
- var r = /* @__PURE__ */ e(((e, r) => {
6
- var i = n(), a = t();
7
- r.exports = function(e, t) {
8
- e = i(e, t);
9
- var n = [], r;
10
- for (r in e) a(e, r) && n.push(r + ": " + e[r]);
11
- return n.join("; ");
12
- };
13
- }));
14
- //#endregion
15
- export default r();
16
- export { r as require_toStyleString };
@@ -1,34 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/mask-markup/src/serialization.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- export declare const parseStyleString: (s: any) => {};
10
- export declare const reactAttributes: (o: any) => any;
11
- /**
12
- * Tags to marks.
13
- *
14
- * @type {Object}
15
- */
16
- export declare const MARK_TAGS: {
17
- b: string;
18
- em: string;
19
- u: string;
20
- s: string;
21
- code: string;
22
- strong: string;
23
- };
24
- /**
25
- * Deserialize HTML string to Slate JSON format
26
- */
27
- export declare const deserialize: (htmlString: any) => {
28
- object: string;
29
- document: {
30
- object: string;
31
- data: {};
32
- nodes: any;
33
- };
34
- };
@@ -1,132 +0,0 @@
1
- import { require_to_style as e } from "./node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js";
2
- import t from "debug";
3
- //#region src/serialization.ts
4
- var n = e(), r = t("@pie-lib:mask-markup:serialization"), i = ["span"], a = [
5
- "em",
6
- "strong",
7
- "u"
8
- ], o = 3, s = 8, c = 1, l = (e) => {
9
- if (!e.attributes || e.attributes.length <= 0) return;
10
- let t = {}, n;
11
- for (n = 0; n < e.attributes.length; n++) {
12
- let r = e.attributes[n];
13
- t[r.name] = r.value;
14
- }
15
- return t;
16
- }, u = (e) => i.includes(e) ? "inline" : a.includes(e) ? "mark" : "block", d = (e) => {
17
- let t = /([\w-]*)\s*:\s*([^;]*)/g, n, r = {};
18
- for (; n = t.exec(e);) r[n[1]] = n[2].trim();
19
- return r;
20
- }, f = (e) => (0, n.object)(e, {
21
- camelize: !0,
22
- addUnits: !1
23
- }), p = (e, t) => f(d(e.getAttribute(t))), m = (e, t, n) => {
24
- let r = e.getAttribute(n);
25
- return delete t.class, r;
26
- }, h = (e) => (t, n) => {
27
- if (!e.getAttribute) return t;
28
- if (e.getAttribute(n)) switch (n) {
29
- case "style":
30
- t.style = p(e, n);
31
- break;
32
- case "class":
33
- t.className = m(e, t, n);
34
- break;
35
- default:
36
- t[n] = e.getAttribute(n);
37
- break;
38
- }
39
- return t;
40
- }, g = [
41
- "border",
42
- "class",
43
- "style"
44
- ], _ = {
45
- b: "bold",
46
- em: "italic",
47
- u: "underline",
48
- s: "strikethrough",
49
- code: "code",
50
- strong: "strong"
51
- }, v = (e, t = []) => {
52
- if (e.nodeType === s) return null;
53
- if (e.nodeType === o) {
54
- let n = { text: e.textContent };
55
- return t.length > 0 && (n.marks = t.map((e) => ({
56
- type: e,
57
- data: void 0
58
- }))), {
59
- object: "text",
60
- leaves: [n]
61
- };
62
- }
63
- if (e.nodeType === c) {
64
- let n = e.tagName.toLowerCase(), i = _[n];
65
- if (i) return r("[deserialize] mark: ", i), {
66
- _flatten: !0,
67
- nodes: y(e.childNodes, [...t, i])
68
- };
69
- if (n === "math") return {
70
- isMath: !0,
71
- nodes: [e]
72
- };
73
- let a = l(e) || {};
74
- n === "audio" && a.controls === "" && (a.controls = !0);
75
- let o = g.reduce(h(e), { ...a }), s = u(n), c = y(e.childNodes, t);
76
- return {
77
- object: s,
78
- type: n,
79
- data: {
80
- dataset: { ...e.dataset },
81
- attributes: { ...o }
82
- },
83
- nodes: c
84
- };
85
- }
86
- return null;
87
- }, y = (e, t = []) => {
88
- let n = [];
89
- for (let r = 0; r < e.length; r++) {
90
- let i = v(e[r], t);
91
- i !== null && (i._flatten && i.nodes ? n.push(...i.nodes) : n.push(i));
92
- }
93
- return n;
94
- }, b = (e) => {
95
- if (!e || !e.trim()) return {
96
- object: "value",
97
- document: {
98
- object: "document",
99
- data: {},
100
- nodes: [{
101
- object: "block",
102
- type: "span",
103
- data: {},
104
- isVoid: !1,
105
- nodes: []
106
- }]
107
- }
108
- };
109
- let t = y(new DOMParser().parseFromString(e, "text/html").body.childNodes);
110
- return !t.some((e) => e.object === "block" || e.object === "inline") && t.length > 0 && (t = [{
111
- object: "block",
112
- type: "span",
113
- data: {},
114
- isVoid: !1,
115
- nodes: t
116
- }]), t.length === 0 && (t = [{
117
- object: "block",
118
- type: "span",
119
- data: {},
120
- isVoid: !1,
121
- nodes: []
122
- }]), {
123
- object: "value",
124
- document: {
125
- object: "document",
126
- data: {},
127
- nodes: t
128
- }
129
- };
130
- };
131
- //#endregion
132
- export { _ as MARK_TAGS, b as deserialize };
@@ -1,55 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/mask-markup/src/with-mask.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- import PropTypes from 'prop-types';
11
- export declare const buildLayoutFromMarkup: (markup: any, type: any) => {
12
- object: string;
13
- data: {};
14
- nodes: any;
15
- };
16
- export declare const withMask: (type: any, renderChildren: any) => {
17
- new (props: any): {
18
- componentDidUpdate(prevProps: any): void;
19
- render(): React.JSX.Element;
20
- context: unknown;
21
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
22
- forceUpdate(callback?: (() => void) | undefined): void;
23
- readonly props: Readonly<{}>;
24
- state: Readonly<{}>;
25
- refs: {
26
- [key: string]: React.ReactInstance;
27
- };
28
- componentDidMount?(): void;
29
- shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
30
- componentWillUnmount?(): void;
31
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
32
- getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
33
- componentWillMount?(): void;
34
- UNSAFE_componentWillMount?(): void;
35
- componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
36
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
37
- componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
38
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
39
- };
40
- propTypes: {
41
- /**
42
- * At the start we'll probably work with markup
43
- */
44
- markup: PropTypes.Requireable<string>;
45
- /**
46
- * Once we start authoring, it may make sense for use to us layout, which will be a simple js object that maps to `slate.Value`.
47
- */
48
- layout: PropTypes.Requireable<object>;
49
- value: PropTypes.Requireable<object>;
50
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
51
- customMarkMarkupComponent: PropTypes.Requireable<(...args: any[]) => any>;
52
- elementType: PropTypes.Requireable<string>;
53
- };
54
- contextType?: React.Context<any> | undefined;
55
- };
package/dist/with-mask.js DELETED
@@ -1,45 +0,0 @@
1
- import { deserialize as e } from "./serialization.js";
2
- import t from "./mask.js";
3
- import n from "./componentize.js";
4
- import r from "react";
5
- import i from "prop-types";
6
- import { jsx as a } from "react/jsx-runtime";
7
- //#region src/with-mask.tsx
8
- var o = (t, r) => {
9
- let { markup: i } = n(t, r);
10
- return e(i).document;
11
- }, s = (e, n) => class extends r.Component {
12
- static propTypes = {
13
- markup: i.string,
14
- layout: i.object,
15
- value: i.object,
16
- onChange: i.func,
17
- customMarkMarkupComponent: i.func,
18
- elementType: i.string
19
- };
20
- constructor(e) {
21
- super(e), this.containerRef = r.createRef();
22
- }
23
- componentDidUpdate(e) {
24
- if (this.props.markup !== e.markup) {
25
- let e = this.containerRef.current;
26
- (e && e.querySelectorAll("[data-latex][data-math-handled=\"true\"]") || []).forEach((e) => {
27
- let t = e.querySelector("mjx-container");
28
- t && e.removeChild(t), e.innerHTML = e.getAttribute("data-raw"), e.removeAttribute("data-math-handled");
29
- });
30
- }
31
- }
32
- render() {
33
- let { markup: r, layout: i, value: s, onChange: c, elementType: l } = this.props, u = i || o(r, e);
34
- return /* @__PURE__ */ a(t, {
35
- containerRef: this.containerRef,
36
- elementType: l,
37
- layout: u,
38
- value: s,
39
- onChange: c,
40
- renderChildren: n(this.props)
41
- });
42
- }
43
- };
44
- //#endregion
45
- export { o as buildLayoutFromMarkup, s as withMask };