@medway-ui/native 1.1.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/lib/commonjs/components/Alert.js +5 -4
  2. package/lib/commonjs/components/Alert.js.map +1 -1
  3. package/lib/commonjs/components/Avatar.js +2 -1
  4. package/lib/commonjs/components/Avatar.js.map +1 -1
  5. package/lib/commonjs/components/Badge.js +2 -1
  6. package/lib/commonjs/components/Badge.js.map +1 -1
  7. package/lib/commonjs/components/Button.js +3 -2
  8. package/lib/commonjs/components/Button.js.map +1 -1
  9. package/lib/commonjs/components/CardNews.js +7 -6
  10. package/lib/commonjs/components/CardNews.js.map +1 -1
  11. package/lib/commonjs/components/Carousel.js +122 -0
  12. package/lib/commonjs/components/Carousel.js.map +1 -0
  13. package/lib/commonjs/components/Checkbox.js +11 -2
  14. package/lib/commonjs/components/Checkbox.js.map +1 -1
  15. package/lib/commonjs/components/DropdownMenu.js +225 -0
  16. package/lib/commonjs/components/DropdownMenu.js.map +1 -0
  17. package/lib/commonjs/components/EmptyState.js +19 -20
  18. package/lib/commonjs/components/EmptyState.js.map +1 -1
  19. package/lib/commonjs/components/Feed.js +82 -0
  20. package/lib/commonjs/components/Feed.js.map +1 -0
  21. package/lib/commonjs/components/FeedNotice.js +76 -0
  22. package/lib/commonjs/components/FeedNotice.js.map +1 -0
  23. package/lib/commonjs/components/Input.js +21 -9
  24. package/lib/commonjs/components/Input.js.map +1 -1
  25. package/lib/commonjs/components/InvitePopover.js +196 -0
  26. package/lib/commonjs/components/InvitePopover.js.map +1 -0
  27. package/lib/commonjs/components/Label.js +2 -1
  28. package/lib/commonjs/components/Label.js.map +1 -1
  29. package/lib/commonjs/components/LeaderboardCard.js +58 -0
  30. package/lib/commonjs/components/LeaderboardCard.js.map +1 -0
  31. package/lib/commonjs/components/MemberRow.js +131 -0
  32. package/lib/commonjs/components/MemberRow.js.map +1 -0
  33. package/lib/commonjs/components/PageHeader.js +3 -2
  34. package/lib/commonjs/components/PageHeader.js.map +1 -1
  35. package/lib/commonjs/components/PostForm.js +182 -0
  36. package/lib/commonjs/components/PostForm.js.map +1 -0
  37. package/lib/commonjs/components/PrizeCollection.js +135 -0
  38. package/lib/commonjs/components/PrizeCollection.js.map +1 -0
  39. package/lib/commonjs/components/RadioGroup.js +22 -0
  40. package/lib/commonjs/components/RadioGroup.js.map +1 -1
  41. package/lib/commonjs/components/SectionHeader.js +36 -0
  42. package/lib/commonjs/components/SectionHeader.js.map +1 -0
  43. package/lib/commonjs/components/Switch.js +33 -19
  44. package/lib/commonjs/components/Switch.js.map +1 -1
  45. package/lib/commonjs/components/Tabs.js +156 -0
  46. package/lib/commonjs/components/Tabs.js.map +1 -0
  47. package/lib/commonjs/components/Tag.js +2 -1
  48. package/lib/commonjs/components/Tag.js.map +1 -1
  49. package/lib/commonjs/components/Text.js +60 -0
  50. package/lib/commonjs/components/Text.js.map +1 -0
  51. package/lib/commonjs/components/Toast.js +3 -2
  52. package/lib/commonjs/components/Toast.js.map +1 -1
  53. package/lib/commonjs/components/Tooltip.js +2 -2
  54. package/lib/commonjs/components/Tooltip.js.map +1 -1
  55. package/lib/commonjs/editor/NoteEditor.js +710 -0
  56. package/lib/commonjs/editor/NoteEditor.js.map +1 -0
  57. package/lib/commonjs/editor/editorHtml.generated.js +21 -0
  58. package/lib/commonjs/editor/editorHtml.generated.js.map +1 -0
  59. package/lib/commonjs/editor/index.js +33 -0
  60. package/lib/commonjs/editor/index.js.map +1 -0
  61. package/lib/commonjs/editor/protocol.js +88 -0
  62. package/lib/commonjs/editor/protocol.js.map +1 -0
  63. package/lib/commonjs/hooks/useThemeColor.js +66 -29
  64. package/lib/commonjs/hooks/useThemeColor.js.map +1 -1
  65. package/lib/commonjs/index.js +319 -1
  66. package/lib/commonjs/index.js.map +1 -1
  67. package/lib/commonjs/lib/overlay-host.js +101 -0
  68. package/lib/commonjs/lib/overlay-host.js.map +1 -0
  69. package/lib/commonjs/lib/typography.js +26 -0
  70. package/lib/commonjs/lib/typography.js.map +1 -0
  71. package/lib/commonjs/nativewind-env.d.js +0 -1
  72. package/lib/commonjs/nativewind-env.d.js.map +1 -1
  73. package/lib/module/components/Alert.js +3 -2
  74. package/lib/module/components/Alert.js.map +1 -1
  75. package/lib/module/components/Avatar.js +2 -1
  76. package/lib/module/components/Avatar.js.map +1 -1
  77. package/lib/module/components/Badge.js +2 -1
  78. package/lib/module/components/Badge.js.map +1 -1
  79. package/lib/module/components/Button.js +2 -1
  80. package/lib/module/components/Button.js.map +1 -1
  81. package/lib/module/components/CardNews.js +2 -1
  82. package/lib/module/components/CardNews.js.map +1 -1
  83. package/lib/module/components/Carousel.js +117 -0
  84. package/lib/module/components/Carousel.js.map +1 -0
  85. package/lib/module/components/Checkbox.js +12 -2
  86. package/lib/module/components/Checkbox.js.map +1 -1
  87. package/lib/module/components/DropdownMenu.js +216 -0
  88. package/lib/module/components/DropdownMenu.js.map +1 -0
  89. package/lib/module/components/EmptyState.js +19 -20
  90. package/lib/module/components/EmptyState.js.map +1 -1
  91. package/lib/module/components/Feed.js +77 -0
  92. package/lib/module/components/Feed.js.map +1 -0
  93. package/lib/module/components/FeedNotice.js +73 -0
  94. package/lib/module/components/FeedNotice.js.map +1 -0
  95. package/lib/module/components/Input.js +21 -9
  96. package/lib/module/components/Input.js.map +1 -1
  97. package/lib/module/components/InvitePopover.js +183 -0
  98. package/lib/module/components/InvitePopover.js.map +1 -0
  99. package/lib/module/components/Label.js +2 -1
  100. package/lib/module/components/Label.js.map +1 -1
  101. package/lib/module/components/LeaderboardCard.js +53 -0
  102. package/lib/module/components/LeaderboardCard.js.map +1 -0
  103. package/lib/module/components/MemberRow.js +127 -0
  104. package/lib/module/components/MemberRow.js.map +1 -0
  105. package/lib/module/components/PageHeader.js +2 -1
  106. package/lib/module/components/PageHeader.js.map +1 -1
  107. package/lib/module/components/PostForm.js +174 -0
  108. package/lib/module/components/PostForm.js.map +1 -0
  109. package/lib/module/components/PrizeCollection.js +127 -0
  110. package/lib/module/components/PrizeCollection.js.map +1 -0
  111. package/lib/module/components/RadioGroup.js +21 -1
  112. package/lib/module/components/RadioGroup.js.map +1 -1
  113. package/lib/module/components/SectionHeader.js +33 -0
  114. package/lib/module/components/SectionHeader.js.map +1 -0
  115. package/lib/module/components/Switch.js +34 -20
  116. package/lib/module/components/Switch.js.map +1 -1
  117. package/lib/module/components/Tabs.js +148 -0
  118. package/lib/module/components/Tabs.js.map +1 -0
  119. package/lib/module/components/Tag.js +2 -1
  120. package/lib/module/components/Tag.js.map +1 -1
  121. package/lib/module/components/Text.js +58 -0
  122. package/lib/module/components/Text.js.map +1 -0
  123. package/lib/module/components/Toast.js +2 -1
  124. package/lib/module/components/Toast.js.map +1 -1
  125. package/lib/module/components/Tooltip.js +1 -1
  126. package/lib/module/components/Tooltip.js.map +1 -1
  127. package/lib/module/editor/NoteEditor.js +705 -0
  128. package/lib/module/editor/NoteEditor.js.map +1 -0
  129. package/lib/module/editor/editorHtml.generated.js +17 -0
  130. package/lib/module/editor/editorHtml.generated.js.map +1 -0
  131. package/lib/module/editor/index.js +5 -0
  132. package/lib/module/editor/index.js.map +1 -0
  133. package/lib/module/editor/protocol.js +83 -0
  134. package/lib/module/editor/protocol.js.map +1 -0
  135. package/lib/module/hooks/useThemeColor.js +66 -31
  136. package/lib/module/hooks/useThemeColor.js.map +1 -1
  137. package/lib/module/index.js +33 -3
  138. package/lib/module/index.js.map +1 -1
  139. package/lib/module/lib/overlay-host.js +96 -0
  140. package/lib/module/lib/overlay-host.js.map +1 -0
  141. package/lib/module/lib/typography.js +22 -0
  142. package/lib/module/lib/typography.js.map +1 -0
  143. package/lib/module/nativewind-env.d.js +0 -1
  144. package/lib/module/nativewind-env.d.js.map +1 -1
  145. package/lib/typescript/components/Alert.d.ts.map +1 -1
  146. package/lib/typescript/components/Avatar.d.ts.map +1 -1
  147. package/lib/typescript/components/Badge.d.ts.map +1 -1
  148. package/lib/typescript/components/Button.d.ts.map +1 -1
  149. package/lib/typescript/components/CardNews.d.ts.map +1 -1
  150. package/lib/typescript/components/Carousel.d.ts +29 -0
  151. package/lib/typescript/components/Carousel.d.ts.map +1 -0
  152. package/lib/typescript/components/Checkbox.d.ts.map +1 -1
  153. package/lib/typescript/components/DropdownMenu.d.ts +39 -0
  154. package/lib/typescript/components/DropdownMenu.d.ts.map +1 -0
  155. package/lib/typescript/components/EmptyState.d.ts +1 -1
  156. package/lib/typescript/components/EmptyState.d.ts.map +1 -1
  157. package/lib/typescript/components/Feed.d.ts +22 -0
  158. package/lib/typescript/components/Feed.d.ts.map +1 -0
  159. package/lib/typescript/components/FeedNotice.d.ts +17 -0
  160. package/lib/typescript/components/FeedNotice.d.ts.map +1 -0
  161. package/lib/typescript/components/Input.d.ts +3 -2
  162. package/lib/typescript/components/Input.d.ts.map +1 -1
  163. package/lib/typescript/components/InvitePopover.d.ts +46 -0
  164. package/lib/typescript/components/InvitePopover.d.ts.map +1 -0
  165. package/lib/typescript/components/Label.d.ts.map +1 -1
  166. package/lib/typescript/components/LeaderboardCard.d.ts +16 -0
  167. package/lib/typescript/components/LeaderboardCard.d.ts.map +1 -0
  168. package/lib/typescript/components/MemberRow.d.ts +40 -0
  169. package/lib/typescript/components/MemberRow.d.ts.map +1 -0
  170. package/lib/typescript/components/PageHeader.d.ts.map +1 -1
  171. package/lib/typescript/components/PostForm.d.ts +50 -0
  172. package/lib/typescript/components/PostForm.d.ts.map +1 -0
  173. package/lib/typescript/components/PrizeCollection.d.ts +35 -0
  174. package/lib/typescript/components/PrizeCollection.d.ts.map +1 -0
  175. package/lib/typescript/components/RadioGroup.d.ts +10 -2
  176. package/lib/typescript/components/RadioGroup.d.ts.map +1 -1
  177. package/lib/typescript/components/SectionHeader.d.ts +12 -0
  178. package/lib/typescript/components/SectionHeader.d.ts.map +1 -0
  179. package/lib/typescript/components/Switch.d.ts.map +1 -1
  180. package/lib/typescript/components/Tabs.d.ts +32 -0
  181. package/lib/typescript/components/Tabs.d.ts.map +1 -0
  182. package/lib/typescript/components/Tag.d.ts.map +1 -1
  183. package/lib/typescript/components/Text.d.ts +23 -0
  184. package/lib/typescript/components/Text.d.ts.map +1 -0
  185. package/lib/typescript/components/Toast.d.ts +1 -1
  186. package/lib/typescript/components/Toast.d.ts.map +1 -1
  187. package/lib/typescript/components/Tooltip.d.ts.map +1 -1
  188. package/lib/typescript/editor/NoteEditor.d.ts +82 -0
  189. package/lib/typescript/editor/NoteEditor.d.ts.map +1 -0
  190. package/lib/typescript/editor/editorHtml.generated.d.ts +13 -0
  191. package/lib/typescript/editor/editorHtml.generated.d.ts.map +1 -0
  192. package/lib/typescript/editor/index.d.ts +6 -0
  193. package/lib/typescript/editor/index.d.ts.map +1 -0
  194. package/lib/typescript/editor/protocol.d.ts +153 -0
  195. package/lib/typescript/editor/protocol.d.ts.map +1 -0
  196. package/lib/typescript/hooks/useThemeColor.d.ts +4 -2
  197. package/lib/typescript/hooks/useThemeColor.d.ts.map +1 -1
  198. package/lib/typescript/index.d.ts +28 -4
  199. package/lib/typescript/index.d.ts.map +1 -1
  200. package/lib/typescript/lib/overlay-host.d.ts +23 -0
  201. package/lib/typescript/lib/overlay-host.d.ts.map +1 -0
  202. package/lib/typescript/lib/typography.d.ts +12 -0
  203. package/lib/typescript/lib/typography.d.ts.map +1 -0
  204. package/package.json +36 -3
  205. package/setup/MedwayUiProvider.tsx +15 -3
  206. package/setup/metro.js +27 -5
  207. package/setup/tailwind.js +52 -4
  208. package/setup/tokens.native.css +8 -3
  209. package/src/components/Alert.tsx +4 -2
  210. package/src/components/Avatar.tsx +3 -1
  211. package/src/components/Badge.tsx +3 -1
  212. package/src/components/Button.tsx +3 -7
  213. package/src/components/CardNews.tsx +2 -1
  214. package/src/components/Carousel.tsx +152 -0
  215. package/src/components/Checkbox.tsx +14 -4
  216. package/src/components/DropdownMenu.tsx +312 -0
  217. package/src/components/EmptyState.tsx +21 -23
  218. package/src/components/Feed.tsx +96 -0
  219. package/src/components/FeedNotice.tsx +112 -0
  220. package/src/components/Input.tsx +11 -6
  221. package/src/components/InvitePopover.tsx +240 -0
  222. package/src/components/Label.tsx +3 -1
  223. package/src/components/LeaderboardCard.tsx +70 -0
  224. package/src/components/MemberRow.tsx +157 -0
  225. package/src/components/PageHeader.tsx +3 -1
  226. package/src/components/PostForm.tsx +250 -0
  227. package/src/components/PrizeCollection.tsx +190 -0
  228. package/src/components/RadioGroup.tsx +32 -3
  229. package/src/components/SectionHeader.tsx +45 -0
  230. package/src/components/Switch.tsx +65 -59
  231. package/src/components/Tabs.tsx +182 -0
  232. package/src/components/Tag.tsx +3 -1
  233. package/src/components/Text.tsx +66 -0
  234. package/src/components/Toast.tsx +3 -1
  235. package/src/components/Tooltip.tsx +2 -1
  236. package/src/editor/NoteEditor.tsx +802 -0
  237. package/src/editor/editorHtml.generated.ts +14 -0
  238. package/src/editor/index.ts +13 -0
  239. package/src/editor/protocol.ts +184 -0
  240. package/src/hooks/useThemeColor.ts +77 -32
  241. package/src/index.ts +153 -6
  242. package/src/lib/overlay-host.tsx +102 -0
  243. package/src/lib/typography.ts +21 -0
  244. package/src/nativewind-env.d.ts +2 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EDITOR_HTML","exports"],"sourceRoot":"../../../src","sources":["editor/editorHtml.generated.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,WAAmB,GAAAC,OAAA,CAAAD,WAAA,GAAG,i5haAAi5ha","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EDITOR_PROTOCOL_VERSION", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _protocol.EDITOR_PROTOCOL_VERSION;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "EDITOR_RECEIVE_HANDLER", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _protocol.EDITOR_RECEIVE_HANDLER;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "NoteEditor", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _NoteEditor.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "isEditorMessage", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _protocol.isEditorMessage;
28
+ }
29
+ });
30
+ var _NoteEditor = _interopRequireDefault(require("./NoteEditor.js"));
31
+ var _protocol = require("./protocol.js");
32
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_NoteEditor","_interopRequireDefault","require","_protocol","e","__esModule","default"],"sourceRoot":"../../../src","sources":["editor/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AAIoB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isEditorMessage = exports.EDITOR_RECEIVE_HANDLER = exports.EDITOR_PROTOCOL_VERSION = void 0;
7
+ /**
8
+ * Transport between React Native and the Tiptap editor inside the WebView. Both
9
+ * sides compile against this file — the bundle imports it through the `@/`
10
+ * alias in `editor-bundle/vite.config.ts`.
11
+ *
12
+ * Invariants:
13
+ * - The document never crosses the bridge on keystrokes: the editor emits
14
+ * `change` with a revision counter, and the native side asks with
15
+ * `getDocument`.
16
+ * - Every message is validated on arrival (`isEditorMessage`: envelope plus the
17
+ * required fields of its variant) — the WebView renders student content, so
18
+ * its output is untrusted input. Documents get a second pass through
19
+ * `normalizeDocument` before reaching the host.
20
+ */
21
+
22
+ /**
23
+ * Bumped whenever the message shapes below change. The native side refuses to
24
+ * talk to a bundle that reports a different version, which turns a stale
25
+ * `editorHtml.generated.ts` into a clear error instead of silent breakage.
26
+ */
27
+ const EDITOR_PROTOCOL_VERSION = exports.EDITOR_PROTOCOL_VERSION = 3;
28
+
29
+ /** Name of the global the WebView bundle installs to receive native messages. */
30
+ const EDITOR_RECEIVE_HANDLER = exports.EDITOR_RECEIVE_HANDLER = '__medwayNoteEditorReceive';
31
+ const isRecord = value => typeof value === 'object' && value !== null && !Array.isArray(value);
32
+ const isString = value => typeof value === 'string';
33
+
34
+ /** Rejects `NaN` and the infinities, which `JSON.parse` can still produce. */
35
+ const isFiniteNumber = value => typeof value === 'number' && Number.isFinite(value);
36
+
37
+ /*
38
+ * `Record<Union, …>` rather than an array so it is exhaustive: adding a variant
39
+ * to `EditorToNativeMessage` without listing it here stops compiling, instead
40
+ * of letting `isEditorMessage` reject the new type at runtime — which would
41
+ * look like the message never arrived, not like a build error.
42
+ *
43
+ * Each entry checks the fields its own variant declares, so narrowing to the
44
+ * union is backed by the payload and not by `type` alone: a `document` without
45
+ * `doc`/`requestId`, or a `ready` without `protocol`, is rejected here instead
46
+ * of blowing up at the use site.
47
+ *
48
+ * `state`, `slash` and `doc` are checked as objects rather than field by field:
49
+ * their shapes belong to `@medway-ui/notes-core` and are validated there — for
50
+ * `doc`, by the `normalizeDocument` pass the native side runs before handing a
51
+ * document to the host.
52
+ */
53
+ const EDITOR_MESSAGE_VALIDATORS = {
54
+ ready: message => isFiniteNumber(message.protocol),
55
+ state: message => isRecord(message.state),
56
+ change: message => isFiniteNumber(message.revision),
57
+ document: message => isString(message.requestId) && isFiniteNumber(message.revision) && isRecord(message.doc),
58
+ slash: message => isRecord(message.slash),
59
+ resize: message => isFiniteNumber(message.height),
60
+ linkPress: message => isString(message.href),
61
+ backspaceAtDocStart: () => true,
62
+ imageRemoved: message => isString(message.src),
63
+ error: message => isString(message.message)
64
+ };
65
+
66
+ /**
67
+ * Guard for anything arriving from the WebView: checks the envelope *and* the
68
+ * required fields of the variant its `type` names. Establishes the shape, not
69
+ * the contents — a `document` payload's `doc` still goes through
70
+ * `normalizeDocument` before the native side hands it to the host.
71
+ */
72
+ const isEditorMessage = value => {
73
+ if (!isRecord(value)) return false;
74
+ const {
75
+ type
76
+ } = value;
77
+ if (typeof type !== 'string') return false;
78
+
79
+ // `hasOwnProperty`, not `in`: `in` walks the prototype chain, so a `type` of
80
+ // `"toString"` or `"constructor"` matches any plain object literal.
81
+ // `Object.hasOwn` would read better but is ES2022 and `lib` here is ES2020.
82
+ if (!Object.prototype.hasOwnProperty.call(EDITOR_MESSAGE_VALIDATORS, type)) {
83
+ return false;
84
+ }
85
+ return EDITOR_MESSAGE_VALIDATORS[type](value);
86
+ };
87
+ exports.isEditorMessage = isEditorMessage;
88
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EDITOR_PROTOCOL_VERSION","exports","EDITOR_RECEIVE_HANDLER","isRecord","value","Array","isArray","isString","isFiniteNumber","Number","isFinite","EDITOR_MESSAGE_VALIDATORS","ready","message","protocol","state","change","revision","document","requestId","doc","slash","resize","height","linkPress","href","backspaceAtDocStart","imageRemoved","src","error","isEditorMessage","type","Object","prototype","hasOwnProperty","call"],"sourceRoot":"../../../src","sources":["editor/protocol.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,CAAC;;AAExC;AACO,MAAME,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,GAAG,2BAA2B;AAmFjE,MAAMC,QAAQ,GAAIC,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAEtE,MA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AG3B,KAAK;EACtB,IAAI,OAAO2B,IAAI,KAAK,QAAQ,EAAE,OAAO,KAAK;;EAE1C;EACA;EACA;EACA,IAAI,CAACC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACxB,yBAAyB,EAAEoB,IAAI,CAAC,EAAE;IAC1E,OAAO,KAAK;EACd;EAEA,OAAOpB,yBAAyB,CAACoB,IAAI,CAAkC,CACrE3B,KACF,CAAC;AACH,CAAC;AAACH,OAAA,CAAA6B,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.DEFAULT_COLOR = void 0;
7
+ exports.getFallbackColor = getFallbackColor;
6
8
  exports.toCssVariable = toCssVariable;
7
9
  exports.useThemeColor = useThemeColor;
8
10
  var _nativewind = require("nativewind");
@@ -10,47 +12,82 @@ var _nativewind = require("nativewind");
10
12
 
11
13
  /** Fallback quando NativeWind não resolve cadeias `var()` — light mode. */
12
14
  const LIGHT_COLOR_ALIAS_MAP = {
13
- "content-title": "primary",
14
- "content-paragraph": "gray-600",
15
- "gray-foreground": "gray-600",
16
- "primary-foreground": "primary",
17
- "secondary-foreground": "secondary-darken-3",
18
- "surface-card": "white",
19
- "gray-foreground-muted": "gray-450",
20
- "gray-stroke-muted": "gray-100",
21
- "gray-background-fill-muted": "gray-400",
22
- "gray-background-soft-muted": "gray-30",
23
- "primary-foreground-onfill": "white",
24
- "primary-background-fill": "primary"
15
+ 'content-title': 'primary',
16
+ 'content-paragraph': 'gray-600',
17
+ 'gray-foreground': 'gray-600',
18
+ 'primary-foreground': 'primary',
19
+ 'secondary-foreground': 'secondary-darken-3',
20
+ 'secondary-stroke-emphasis': 'secondary-darken-1',
21
+ 'surface-card': 'white',
22
+ 'gray-foreground-muted': 'gray-450',
23
+ 'gray-stroke-muted': 'gray-100',
24
+ 'gray-background-fill-muted': 'gray-400',
25
+ 'gray-background-soft-muted': 'gray-30',
26
+ 'primary-foreground-onfill': 'white',
27
+ 'primary-background-fill': 'primary',
28
+ 'red-foreground': 'red-darken-2',
29
+ 'go-foreground': 'go-darken-1'
25
30
  };
26
31
 
27
32
  /** Fallback — dark mode (espelha tokens.css `.dark`). */
28
33
  const DARK_COLOR_ALIAS_MAP = {
29
- "content-title": "white",
30
- "content-paragraph": "gray-150",
31
- "gray-foreground": "gray-100",
32
- "primary-foreground": "gray-100",
33
- "secondary-foreground": "secondary-lighten-1",
34
- "surface-card": "gray-850",
35
- "gray-foreground-muted": "gray-150",
36
- "gray-stroke-muted": "gray-700",
37
- "gray-background-fill-muted": "gray-300",
38
- "gray-background-soft-muted": "gray-700",
39
- "primary-foreground-onfill": "primary",
40
- "primary-background-fill": "gray-70"
34
+ 'content-title': 'white',
35
+ 'content-paragraph': 'gray-150',
36
+ 'gray-foreground': 'gray-100',
37
+ 'primary-foreground': 'gray-100',
38
+ 'secondary-foreground': 'secondary-lighten-1',
39
+ 'secondary-stroke-emphasis': 'secondary',
40
+ 'surface-card': 'gray-850',
41
+ 'gray-foreground-muted': 'gray-150',
42
+ 'gray-stroke-muted': 'gray-700',
43
+ 'gray-background-fill-muted': 'gray-300',
44
+ 'gray-background-soft-muted': 'gray-700',
45
+ 'primary-foreground-onfill': 'primary',
46
+ 'primary-background-fill': 'gray-70',
47
+ 'red-foreground': 'red-lighten-3',
48
+ 'go-foreground': 'go-lighten-5'
41
49
  };
50
+
51
+ /** Fallback estático quando NativeWind não resolve `var(--color-*)` encadeado. */
52
+ const THEME_COLOR_FALLBACKS = {
53
+ white: '#FFFFFF',
54
+ primary: 'rgba(0, 32, 91, 1)',
55
+ 'gray-600': 'rgba(49, 57, 73, 1)',
56
+ 'gray-450': 'rgba(90, 105, 135, 1)',
57
+ 'gray-400': 'rgba(122, 133, 151, 1)',
58
+ 'gray-100': 'rgba(231, 233, 239, 1)',
59
+ 'gray-30': 'rgba(249, 250, 251, 1)',
60
+ 'gray-150': 'rgba(206, 211, 222, 1)',
61
+ 'gray-300': 'rgba(133, 146, 173, 1)',
62
+ 'gray-700': 'rgba(33, 38, 49, 1)',
63
+ 'gray-850': 'rgba(16, 19, 24, 1)',
64
+ 'gray-70': 'rgba(240, 241, 245, 1)',
65
+ 'red-darken-2': 'rgba(182, 27, 45, 1)',
66
+ 'red-lighten-3': 'rgba(231, 131, 142, 1)',
67
+ 'go-darken-1': 'rgba(141, 22, 77, 1)',
68
+ 'go-lighten-5': 'rgba(237, 187, 192, 1)',
69
+ 'secondary-darken-1': 'rgba(7, 171, 149, 1)',
70
+ 'secondary-darken-3': 'rgba(13, 104, 92, 1)',
71
+ 'secondary-lighten-1': 'rgba(22, 208, 118, 1)'
72
+ };
73
+ const DEFAULT_COLOR = exports.DEFAULT_COLOR = '#3B4958';
42
74
  function toCssVariable(token) {
43
- return token.startsWith("--") ? token : `--color-${token}`;
75
+ return token.startsWith('--') ? token : `--color-${token}`;
44
76
  }
45
77
  function toTokenName(token) {
46
- return token.startsWith("--color-") ? token.slice("--color-".length) : token;
78
+ return token.startsWith('--color-') ? token.slice('--color-'.length) : token;
47
79
  }
48
80
  function toResolvedCssVariable(token, aliasMap) {
49
81
  const tokenName = toTokenName(token);
50
82
  return toCssVariable(aliasMap[tokenName] ?? tokenName);
51
83
  }
52
84
  function isResolvedColor(value) {
53
- return typeof value === "string" && !value.startsWith("var(");
85
+ return typeof value === 'string' && !value.startsWith('var(');
86
+ }
87
+ function getFallbackColor(token, aliasMap) {
88
+ const tokenName = toTokenName(token);
89
+ const aliasToken = aliasMap[tokenName] ?? tokenName;
90
+ return THEME_COLOR_FALLBACKS[tokenName] ?? THEME_COLOR_FALLBACKS[aliasToken] ?? DEFAULT_COLOR;
54
91
  }
55
92
 
56
93
  /**
@@ -61,11 +98,11 @@ function useThemeColor(token) {
61
98
  const {
62
99
  colorScheme
63
100
  } = (0, _nativewind.useColorScheme)();
64
- const aliasMap = colorScheme === "dark" ? DARK_COLOR_ALIAS_MAP : LIGHT_COLOR_ALIAS_MAP;
101
+ const aliasMap = colorScheme === 'dark' ? DARK_COLOR_ALIAS_MAP : LIGHT_COLOR_ALIAS_MAP;
65
102
  const value = (0, _nativewind.useUnstableNativeVariable)(toCssVariable(token));
66
103
  const resolvedValue = (0, _nativewind.useUnstableNativeVariable)(toResolvedCssVariable(token, aliasMap));
67
104
  if (isResolvedColor(value)) return value;
68
105
  if (isResolvedColor(resolvedValue)) return resolvedValue;
69
- return undefined;
106
+ return getFallbackColor(token, aliasMap);
70
107
  }
71
108
  //# sourceMappingURL=useThemeColor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_nativewind","require","LIGHT_COLOR_ALIAS_MAP","DARK_COLOR_ALIAS_MAP","toCssVariable","token","startsWith","toTokenName","slice","length","toResolvedCssVariable","aliasMap","tokenName","isResolvedColor","value","useThemeColor","colorScheme","useColorScheme","useUnstableNativeVariable","resolvedValue","undefined"],"sourceRoot":"../../../src","sources":["hooks/useThemeColor.ts"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA;;AAGA;AACA,MAAMC,qBAA6C,GAAG;EACpD,eAAe,EAAE,SAAS;EAC1B,mBAAmB,EAAE,UAAU;EAC/B,iBAAiB,EAAE,UAAU;EAC7B,oBAAoB,EAAE,SAAS;EAC/B,sBAAsB,EAAE,oBAAoB;EAC5C,cAAc,EAAE,OAAO;EACvB,uBAAuB,EAAE,UAAU;EACnC,mBAAmB,EAAE,UAAU;EAC/B,4BAA4B,EAAE,UAAU;EACxC,4BAA4B,EAAE,SAAS;EACvC,2BAA2B,EAAE,OAAO;EACpC,yBAAyB,EAAE;AAC7B,CAAC;;AAED;AACA,MAAMC,oBAA4C,GAAG;EACnD,eAAe,EAAE,OAAO;EACxB,mBAAmB,EAAE,UAAU;EAC/B,iBAAiB,EAAE,UAAU;EAC7B,oBAAoB,EAAE,UAAU;EAChC,sBAAsB,EAAE,qBAAqB;EAC7C,cAAc,EAAE,UAAU;EAC1B,uBAAuB,EAAE,UAAU;EAC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AAa;EAExD,OAAOC,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"names":["_nativewind","require","LIGHT_COLOR_ALIAS_MAP","DARK_COLOR_ALIAS_MAP","THEME_COLOR_FALLBACKS","white","primary","DEFAULT_COLOR","exports","toCssVariable","token","startsWith","toTokenName","slice","length","toResolvedCssVariable","aliasMap","tokenName","isResolvedColor","value","getFallbackColor","aliasToken","useThemeColor","colorScheme","useColorScheme","useUnstableNativeVariable","resolvedValue"],"sourceRoot":"../../../src","sources":["hooks/useThemeColor.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA;;AAGA;AACA,MAAMC,qBAA6C,GAAG;EACpD,eAAe,EAAE,SAAS;EAC1B,mBAAmB,EAAE,UAAU;EAC/B,iBAAiB,EAAE,UAAU;EAC7B,oBAAoB,EAAE,SAAS;EAC/B,sBAAsB,EAAE,oBAAoB;EAC5C,2BAA2B,EAAE,oBAAoB;EACjD,cAAc,EAAE,OAAO;EACvB,uBAAuB,EAAE,UAAU;EACnC,mBAAmB,EAAE,UAAU;EAC/B,4BAA4B,EAAE,UAAU;EACxC,4BAA4B,EAAE,SAAS;EACvC,2BAA2B,EAAE,OAAO;EACpC,yBAAyB,EAAE,SAAS;EACpC,gBAAgB,EAAE,cAAc;EAChC,eAAe,EAAE;AACnB,CAAC;;AAED;AACA,MAAMC,oBAA4C,GAAG;EACnD,eAAe,EAAE,OAAO;EACxB,mBAAmB,EAAE,UAAU;EAC/B,iBAAiB,EAAE,UAAU;EAC7B,oBAAoB,EAAE,UAAU;EAChC,sBAAsB,EAAE,qBAAqB;EAC7C,2BAA2B,EAAE,WAAW;EACxC,cAAc,EAAE,UAAU;EAC1B,uBAAuB,EAAE,UAAU;EACnC,mBAAmB,EAAE,UAAU;EAC/B,4BAA4B,EAAE,UAAU;EACxC,4BAA4B,EAAE,UAAU;EACxC,2BAA2B,EAAE,SAAS;EACtC,yBAAyB,EAAE,SAAS;EACpC,gBAAgB,EAAE,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