@flipova/foundation 1.14.0 → 2.0.4

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 (268) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/README.md +53 -178
  3. package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +162 -0
  4. package/components/ui/accordion/AccordionAnimatedHeight.tsx +56 -0
  5. package/components/ui/accordion/AccordionAnimatedIcon.tsx +41 -0
  6. package/components/ui/accordion/AnimatedHeight.tsx +56 -0
  7. package/components/ui/accordion/AnimatedIcon.tsx +41 -0
  8. package/components/ui/accordion/MIGRATION_SUMMARY.md +250 -0
  9. package/components/ui/accordion/USAGE_EXAMPLE.tsx +179 -0
  10. package/components/ui/accordion/animation-config.ts +32 -0
  11. package/components/ui/accordion/index.tsx +253 -0
  12. package/components/ui/actionsheet/index.tsx +511 -0
  13. package/components/ui/alert/index.tsx +158 -0
  14. package/components/ui/alert-dialog/index.tsx +254 -0
  15. package/components/ui/avatar/index.tsx +139 -0
  16. package/components/ui/badge/index.tsx +163 -0
  17. package/components/ui/bottomsheet/index.tsx +477 -0
  18. package/components/ui/box/index.tsx +19 -0
  19. package/components/ui/box/index.web.tsx +19 -0
  20. package/components/ui/box/styles.tsx +10 -0
  21. package/components/ui/button/index.tsx +264 -0
  22. package/components/ui/calendar/creator.tsx +366 -0
  23. package/components/ui/calendar/index.tsx +462 -0
  24. package/components/ui/calendar/styles.tsx +140 -0
  25. package/components/ui/card/index.tsx +23 -0
  26. package/components/ui/card/index.web.tsx +26 -0
  27. package/components/ui/card/styles.tsx +16 -0
  28. package/components/ui/center/index.tsx +22 -0
  29. package/components/ui/center/index.web.tsx +20 -0
  30. package/components/ui/center/styles.tsx +8 -0
  31. package/components/ui/checkbox/index.tsx +184 -0
  32. package/components/ui/date-time-picker/creator.tsx +109 -0
  33. package/components/ui/date-time-picker/index.tsx +585 -0
  34. package/components/ui/date-time-picker/index.web.tsx +217 -0
  35. package/components/ui/date-time-picker/styles.tsx +56 -0
  36. package/components/ui/divider/index.tsx +40 -0
  37. package/components/ui/drawer/index.tsx +362 -0
  38. package/components/ui/fab/index.tsx +215 -0
  39. package/components/ui/flat-list/index.tsx +21 -0
  40. package/components/ui/form-control/index.tsx +352 -0
  41. package/components/ui/gluestack-ui-provider/config.ts +72 -0
  42. package/components/ui/gluestack-ui-provider/index.tsx +47 -0
  43. package/components/ui/gluestack-ui-provider/index.web.tsx +96 -0
  44. package/components/ui/gluestack-ui-provider/script.ts +19 -0
  45. package/components/ui/gluestack-ui-provider/tokens.d.ts +17 -0
  46. package/components/ui/gluestack-ui-provider/tokens.js +188 -0
  47. package/components/ui/gluestack-ui-provider/useGluestackColors.ts +82 -0
  48. package/components/ui/grid/index.tsx +283 -0
  49. package/components/ui/grid/index.web.tsx +66 -0
  50. package/components/ui/grid/styles.tsx +15 -0
  51. package/components/ui/heading/index.tsx +220 -0
  52. package/components/ui/heading/index.web.tsx +202 -0
  53. package/components/ui/heading/styles.tsx +43 -0
  54. package/components/ui/hstack/index.tsx +27 -0
  55. package/components/ui/hstack/index.web.tsx +26 -0
  56. package/components/ui/hstack/styles.tsx +25 -0
  57. package/components/ui/icon/index.tsx +1588 -0
  58. package/components/ui/icon/index.web.tsx +1573 -0
  59. package/components/ui/image/index.tsx +48 -0
  60. package/components/ui/image-background/index.tsx +25 -0
  61. package/components/ui/image-viewer/index.tsx +743 -0
  62. package/components/ui/image-viewer/index.web.tsx +302 -0
  63. package/components/ui/index.ts +58 -0
  64. package/components/ui/input/index.tsx +125 -0
  65. package/components/ui/input-accessory-view/index.tsx +2 -0
  66. package/components/ui/keyboard-avoiding-view/index.tsx +2 -0
  67. package/components/ui/link/index.tsx +102 -0
  68. package/components/ui/liquid-glass/index.tsx +74 -0
  69. package/components/ui/menu/index.tsx +186 -0
  70. package/components/ui/modal/index.tsx +237 -0
  71. package/components/ui/popover/index.tsx +272 -0
  72. package/components/ui/portal/index.tsx +17 -0
  73. package/components/ui/pressable/index.tsx +39 -0
  74. package/components/ui/progress/index.tsx +83 -0
  75. package/components/ui/radio/index.tsx +217 -0
  76. package/components/ui/refresh-control/index.tsx +2 -0
  77. package/components/ui/safe-area-view/index.tsx +2 -0
  78. package/components/ui/scroll-view/index.tsx +2 -0
  79. package/components/ui/section-list/index.tsx +2 -0
  80. package/components/ui/select/index.tsx +277 -0
  81. package/components/ui/select/select-actionsheet.tsx +562 -0
  82. package/components/ui/skeleton/index.tsx +105 -0
  83. package/components/ui/skeleton/index.web.tsx +103 -0
  84. package/components/ui/skeleton/styles.tsx +35 -0
  85. package/components/ui/slider/index.tsx +181 -0
  86. package/components/ui/spinner/index.tsx +40 -0
  87. package/components/ui/status-bar/index.tsx +2 -0
  88. package/components/ui/switch/index.tsx +41 -0
  89. package/components/ui/table/index.tsx +210 -0
  90. package/components/ui/table/index.web.tsx +157 -0
  91. package/components/ui/table/styles.tsx +44 -0
  92. package/components/ui/tabs/TabsAnimatedIndicator.tsx +160 -0
  93. package/components/ui/tabs/animation-config.ts +3 -0
  94. package/components/ui/tabs/creator.tsx +206 -0
  95. package/components/ui/tabs/index.tsx +484 -0
  96. package/components/ui/text/index.tsx +48 -0
  97. package/components/ui/text/index.web.tsx +45 -0
  98. package/components/ui/text/styles.tsx +47 -0
  99. package/components/ui/textarea/index.tsx +94 -0
  100. package/components/ui/toast/index.tsx +252 -0
  101. package/components/ui/tooltip/index.tsx +131 -0
  102. package/components/ui/view/index.tsx +2 -0
  103. package/components/ui/virtualized-list/index.tsx +2 -0
  104. package/components/ui/vstack/index.tsx +28 -0
  105. package/components/ui/vstack/index.web.tsx +27 -0
  106. package/components/ui/vstack/styles.tsx +25 -0
  107. package/design/canonical.index.txt +53 -0
  108. package/design/documentation.xml +519 -0
  109. package/design/manifest.xml +90 -0
  110. package/design/schema.xsd +639 -0
  111. package/design/themes.xml +204 -0
  112. package/design/tokens.xml +510 -0
  113. package/design/tools/design.js +165 -0
  114. package/design/tools/npm.js +65 -0
  115. package/design/tools/requirements.txt +35 -0
  116. package/design/tools/sources/.checker/__init__.py +81 -0
  117. package/design/tools/sources/.checker/checks.py +198 -0
  118. package/design/tools/sources/.checker/cli.py +154 -0
  119. package/design/tools/sources/.checker/io.py +242 -0
  120. package/design/tools/sources/.checker/model.py +144 -0
  121. package/design/tools/sources/.checker/registry.py +115 -0
  122. package/design/tools/sources/.checker/report.py +21 -0
  123. package/design/tools/sources/.docgen/__init__.py +45 -0
  124. package/design/tools/sources/.docgen/cli.py +101 -0
  125. package/design/tools/sources/.docgen/model.py +147 -0
  126. package/design/tools/sources/.docgen/reference.py +97 -0
  127. package/design/tools/sources/.docgen/site.py +145 -0
  128. package/design/tools/sources/.docgen/xsddoc.py +329 -0
  129. package/design/tools/sources/.generate/__init__.py +35 -0
  130. package/design/tools/sources/.generate/cli.py +76 -0
  131. package/design/tools/sources/.generate/common.py +33 -0
  132. package/design/tools/sources/.generate/config.py +119 -0
  133. package/design/tools/sources/.generate/model.py +51 -0
  134. package/design/tools/sources/.generate/tokens.py +141 -0
  135. package/design/tools/sources/.linter/__init__.py +9 -0
  136. package/design/tools/sources/.linter/cli.py +44 -0
  137. package/design/tools/sources/.linter/discovery.py +30 -0
  138. package/design/tools/sources/.linter/errors.py +45 -0
  139. package/design/tools/sources/.linter/linter.py +68 -0
  140. package/design/tools/sources/.xmleditor/__init__.py +74 -0
  141. package/design/tools/sources/.xmleditor/blocks.py +185 -0
  142. package/design/tools/sources/.xmleditor/cli.py +141 -0
  143. package/design/tools/sources/.xmleditor/editor.py +906 -0
  144. package/design/tools/sources/.xmleditor/model.py +708 -0
  145. package/design/tools/sources/.xmleditor/widgets.py +1832 -0
  146. package/design/tools/sources/.xmleditor/xsdmodel.py +753 -0
  147. package/design/tools/sources/checker.py +55 -0
  148. package/design/tools/sources/docgen.py +66 -0
  149. package/design/tools/sources/generate.py +48 -0
  150. package/design/tools/sources/linter.py +54 -0
  151. package/design/tools/sources/ruff.toml +12 -0
  152. package/design/tools/sources/xmleditor.py +62 -0
  153. package/design/tools/unix/_venv_python.sh +16 -0
  154. package/design/tools/unix/check.sh +13 -0
  155. package/design/tools/unix/doc.sh +14 -0
  156. package/design/tools/unix/gen.sh +14 -0
  157. package/design/tools/unix/lint.sh +10 -0
  158. package/design/tools/unix/run.sh +20 -0
  159. package/design/tools/unix/verify.sh +12 -0
  160. package/design/tools/unix/xmledit.sh +12 -0
  161. package/design/tools/windows/check.cmd +12 -0
  162. package/design/tools/windows/doc.cmd +12 -0
  163. package/design/tools/windows/gen.cmd +11 -0
  164. package/design/tools/windows/lint.cmd +9 -0
  165. package/design/tools/windows/run.cmd +26 -0
  166. package/design/tools/windows/verify.cmd +10 -0
  167. package/design/tools/windows/xmledit.cmd +10 -0
  168. package/dist/chunk-LV4UIEQN.js +9730 -0
  169. package/dist/chunk-LV4UIEQN.js.map +1 -0
  170. package/dist/chunk-WNVU3BM2.mjs +9401 -0
  171. package/dist/chunk-WNVU3BM2.mjs.map +1 -0
  172. package/dist/index.d.mts +40 -10
  173. package/dist/index.d.ts +40 -10
  174. package/dist/index.js +726 -414
  175. package/dist/index.mjs +1 -5
  176. package/dist/ui/index.d.mts +6931 -3070
  177. package/dist/ui/index.d.ts +6931 -3070
  178. package/dist/ui/index.js +779 -352
  179. package/dist/ui/index.mjs +1 -2
  180. package/package.json +66 -149
  181. package/dist/chunk-2XORADW6.js +0 -24552
  182. package/dist/chunk-2XORADW6.js.map +0 -1
  183. package/dist/chunk-52BHHF5M.js +0 -46
  184. package/dist/chunk-52BHHF5M.js.map +0 -1
  185. package/dist/chunk-5647JY7Z.mjs +0 -100
  186. package/dist/chunk-5647JY7Z.mjs.map +0 -1
  187. package/dist/chunk-5N5HC4ZA.mjs +0 -3
  188. package/dist/chunk-5N5HC4ZA.mjs.map +0 -1
  189. package/dist/chunk-7QFZMGL6.js +0 -8583
  190. package/dist/chunk-7QFZMGL6.js.map +0 -1
  191. package/dist/chunk-ASZEP37D.js +0 -423
  192. package/dist/chunk-ASZEP37D.js.map +0 -1
  193. package/dist/chunk-BH5SU2JQ.mjs +0 -8282
  194. package/dist/chunk-BH5SU2JQ.mjs.map +0 -1
  195. package/dist/chunk-BO65GO53.mjs +0 -422
  196. package/dist/chunk-BO65GO53.mjs.map +0 -1
  197. package/dist/chunk-BSVXX52E.mjs +0 -413
  198. package/dist/chunk-BSVXX52E.mjs.map +0 -1
  199. package/dist/chunk-DNV5UBNF.mjs +0 -3
  200. package/dist/chunk-DNV5UBNF.mjs.map +0 -1
  201. package/dist/chunk-EDTAMUO2.js +0 -8310
  202. package/dist/chunk-EDTAMUO2.js.map +0 -1
  203. package/dist/chunk-IJTI6EX4.js +0 -4
  204. package/dist/chunk-IJTI6EX4.js.map +0 -1
  205. package/dist/chunk-M3YLASM2.js +0 -428
  206. package/dist/chunk-M3YLASM2.js.map +0 -1
  207. package/dist/chunk-OXKOGLXE.js +0 -4
  208. package/dist/chunk-OXKOGLXE.js.map +0 -1
  209. package/dist/chunk-RQXQK3ZO.mjs +0 -8486
  210. package/dist/chunk-RQXQK3ZO.mjs.map +0 -1
  211. package/dist/chunk-SR25V4EA.mjs +0 -40
  212. package/dist/chunk-SR25V4EA.mjs.map +0 -1
  213. package/dist/chunk-UB34WFEQ.js +0 -106
  214. package/dist/chunk-UB34WFEQ.js.map +0 -1
  215. package/dist/chunk-ZBRWXKDF.mjs +0 -24431
  216. package/dist/chunk-ZBRWXKDF.mjs.map +0 -1
  217. package/dist/cli/ds.d.mts +0 -1
  218. package/dist/cli/ds.d.ts +0 -1
  219. package/dist/cli/ds.js +0 -602
  220. package/dist/cli/ds.js.map +0 -1
  221. package/dist/cli/ds.mjs +0 -579
  222. package/dist/cli/ds.mjs.map +0 -1
  223. package/dist/cli/flipova.d.mts +0 -1
  224. package/dist/cli/flipova.d.ts +0 -1
  225. package/dist/cli/flipova.js +0 -161
  226. package/dist/cli/flipova.js.map +0 -1
  227. package/dist/cli/flipova.mjs +0 -154
  228. package/dist/cli/flipova.mjs.map +0 -1
  229. package/dist/config/index.d.mts +0 -123
  230. package/dist/config/index.d.ts +0 -123
  231. package/dist/config/index.js +0 -28
  232. package/dist/config/index.js.map +0 -1
  233. package/dist/config/index.mjs +0 -3
  234. package/dist/config/index.mjs.map +0 -1
  235. package/dist/createTheme-DQeX3s0I.d.mts +0 -78
  236. package/dist/createTheme-Y4jfz4-u.d.ts +0 -78
  237. package/dist/index-CuaJA3gM.d.mts +0 -78
  238. package/dist/index-CuaJA3gM.d.ts +0 -78
  239. package/dist/registry/index.d.mts +0 -10160
  240. package/dist/registry/index.d.ts +0 -10160
  241. package/dist/registry/index.js +0 -392
  242. package/dist/registry/index.js.map +0 -1
  243. package/dist/registry/index.mjs +0 -3
  244. package/dist/registry/index.mjs.map +0 -1
  245. package/dist/theme/index.d.mts +0 -35
  246. package/dist/theme/index.d.ts +0 -35
  247. package/dist/theme/index.js +0 -28
  248. package/dist/theme/index.js.map +0 -1
  249. package/dist/theme/index.mjs +0 -3
  250. package/dist/theme/index.mjs.map +0 -1
  251. package/dist/tokens/index.d.mts +0 -423
  252. package/dist/tokens/index.d.ts +0 -423
  253. package/dist/tokens/index.js +0 -44
  254. package/dist/tokens/index.js.map +0 -1
  255. package/dist/tokens/index.mjs +0 -3
  256. package/dist/tokens/index.mjs.map +0 -1
  257. package/dist/types/index.d.mts +0 -202
  258. package/dist/types/index.d.ts +0 -202
  259. package/dist/types/index.js +0 -4
  260. package/dist/types/index.js.map +0 -1
  261. package/dist/types/index.mjs +0 -3
  262. package/dist/types/index.mjs.map +0 -1
  263. package/dist/web/index.d.mts +0 -316
  264. package/dist/web/index.d.ts +0 -316
  265. package/dist/web/index.js +0 -1500
  266. package/dist/web/index.js.map +0 -1
  267. package/dist/web/index.mjs +0 -1396
  268. package/dist/web/index.mjs.map +0 -1
@@ -0,0 +1,329 @@
1
+ """xsd2md walker — generic XSD -> Markdown renderer driven by <xs:documentation>.
2
+
3
+ Split out of the historical docgen.py monolith: collects complexTypes /
4
+ simpleTypes / groups / key constraints from a schema and renders the
5
+ Schema Reference pages (see .docgen/reference.py::render_schema_reference).
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from dataclasses import dataclass, field
10
+
11
+ from lxml import etree
12
+
13
+ # ---------------------------------------------------------------------------
14
+ # Schema Reference renderer (inlined from the former xsd2doc.py; generic
15
+ # XSD -> Markdown walker driven by <xs:documentation> annotations).
16
+ # ---------------------------------------------------------------------------
17
+ XS = "http://www.w3.org/2001/XMLSchema"
18
+ NS = {"xs": XS}
19
+
20
+
21
+ def qn(tag: str) -> str:
22
+ return f"{{{XS}}}{tag}"
23
+
24
+
25
+ def local(tag: str) -> str:
26
+ return etree.QName(tag).localname if "{" in tag else tag
27
+
28
+
29
+ def doc_text(node) -> str:
30
+ """Extrait et nettoie le texte de la première xs:annotation/xs:documentation d'un noeud."""
31
+ ann = node.find(qn("annotation"))
32
+ if ann is None:
33
+ return ""
34
+ parts = []
35
+ for d in ann.findall(qn("documentation")):
36
+ if d.text:
37
+ parts.append(d.text)
38
+ text = " ".join(p.strip() for p in parts if p and p.strip())
39
+ # Normalise les espaces multiples issus de l'indentation XML
40
+ return " ".join(text.split())
41
+
42
+
43
+ def summary_of(text: str) -> str:
44
+ """Première phrase d'un bloc de documentation, utilisée comme résumé court."""
45
+ if not text:
46
+ return ""
47
+ for sep in (". ", " — ", " - "):
48
+ if sep in text:
49
+ return text.split(sep, 1)[0].strip().rstrip(".") + "."
50
+ return text
51
+
52
+
53
+ @dataclass
54
+ class AttrInfo:
55
+ name: str
56
+ type: str
57
+ use: str
58
+ fixed: str | None
59
+ default: str | None
60
+ doc: str
61
+
62
+
63
+ @dataclass
64
+ class ChildInfo:
65
+ name: str
66
+ type_ref: str
67
+ min_occurs: str
68
+ max_occurs: str
69
+ doc: str
70
+ inline: bool = False # True si le type est déclaré en ligne (anonyme)
71
+
72
+
73
+ @dataclass
74
+ class TypeInfo:
75
+ name: str
76
+ kind: str # 'complexType' | 'simpleType' | 'element' | 'group'
77
+ doc: str
78
+ attrs: list = field(default_factory=list)
79
+ children: list = field(default_factory=list)
80
+ enum_values: list = field(default_factory=list)
81
+ base: str | None = None
82
+ constraints: list = field(default_factory=list) # (kind, name, xpath_info)
83
+
84
+
85
+ def describe_particle(parent_el, container: TypeInfo, prefix=""):
86
+ """Parcourt un sequence/choice/group ref et remplit container.children."""
87
+ for node in parent_el:
88
+ if not isinstance(node.tag, str):
89
+ continue # comments / processing instructions have callable tags
90
+ tag = local(node.tag)
91
+ if tag in ("sequence", "choice", "all"):
92
+ marker = " (choix)" if tag == "choice" else ""
93
+ describe_particle(node, container, prefix=prefix + marker)
94
+ elif tag == "group":
95
+ ref = node.get("ref", "").split(":")[-1]
96
+ container.children.append(
97
+ ChildInfo(name=f"« groupe: {ref} »", type_ref=ref,
98
+ min_occurs="1", max_occurs="1",
99
+ doc=f"Inclusion du groupe réutilisable `{ref}`.{prefix}")
100
+ )
101
+ elif tag == "element":
102
+ name = node.get("name", node.get("ref", "?"))
103
+ min_o = node.get("minOccurs", "1")
104
+ max_o = node.get("maxOccurs", "1")
105
+ d = doc_text(node)
106
+ type_attr = node.get("type")
107
+ inline_ct = node.find(qn("complexType"))
108
+ inline_st = node.find(qn("simpleType"))
109
+ if type_attr:
110
+ type_ref = type_attr.split(":")[-1]
111
+ inline = False
112
+ elif inline_ct is not None or inline_st is not None:
113
+ type_ref = f"{container.name}.{name}"
114
+ inline = True
115
+ else:
116
+ type_ref = "xs:string"
117
+ inline = False
118
+ container.children.append(
119
+ ChildInfo(name=name, type_ref=type_ref, min_occurs=min_o,
120
+ max_occurs=max_o, doc=d + prefix, inline=inline)
121
+ )
122
+
123
+
124
+ def parse_attributes(el) -> list:
125
+ out = []
126
+ for a in el.findall(qn("attribute")):
127
+ out.append(AttrInfo(
128
+ name=a.get("name", a.get("ref", "?")),
129
+ type=(a.get("type", "").split(":")[-1] or "inline"),
130
+ use=a.get("use", "optional"),
131
+ fixed=a.get("fixed"),
132
+ default=a.get("default"),
133
+ doc=doc_text(a),
134
+ ))
135
+ return out
136
+
137
+
138
+ def parse_constraints(el) -> list:
139
+ out = []
140
+ for kind in ("key", "keyref", "unique"):
141
+ for c in el.findall(qn(kind)):
142
+ sel = c.find(qn("selector"))
143
+ fields = c.findall(qn("field"))
144
+ info = {
145
+ "name": c.get("name"),
146
+ "refer": c.get("refer", "").split(":")[-1] if kind == "keyref" else None,
147
+ "selector": sel.get("xpath") if sel is not None else "",
148
+ "fields": [f.get("xpath") for f in fields],
149
+ }
150
+ out.append((kind, info))
151
+ return out
152
+
153
+
154
+ def collect_types(schema_root) -> dict[str, TypeInfo]:
155
+ types: dict[str, TypeInfo] = {}
156
+
157
+ # complexTypes et simpleTypes nommés au niveau racine
158
+ for ct in schema_root.findall(qn("complexType")):
159
+ name = ct.get("name")
160
+ if not name:
161
+ continue
162
+ info = TypeInfo(name=name, kind="complexType", doc=doc_text(ct))
163
+ info.attrs = parse_attributes(ct)
164
+ # contenu simple (extension de xs:string, etc.)
165
+ simple = ct.find(qn("simpleContent"))
166
+ if simple is not None:
167
+ ext = simple.find(qn("extension"))
168
+ if ext is not None:
169
+ info.base = ext.get("base", "").split(":")[-1]
170
+ info.attrs += parse_attributes(ext)
171
+ else:
172
+ describe_particle(ct, info)
173
+ types[name] = info
174
+
175
+ for st in schema_root.findall(qn("simpleType")):
176
+ name = st.get("name")
177
+ if not name:
178
+ continue
179
+ info = TypeInfo(name=name, kind="simpleType", doc=doc_text(st))
180
+ restr = st.find(qn("restriction"))
181
+ if restr is not None:
182
+ info.base = restr.get("base", "").split(":")[-1]
183
+ info.enum_values = [e.get("value") for e in restr.findall(qn("enumeration"))]
184
+ types[name] = info
185
+
186
+ # groupes réutilisables
187
+ for gr in schema_root.findall(qn("group")):
188
+ name = gr.get("name")
189
+ if not name:
190
+ continue
191
+ info = TypeInfo(name=name, kind="group", doc=doc_text(gr))
192
+ describe_particle(gr, info)
193
+ types[name] = info
194
+
195
+ # éléments racine (avec complexType éventuellement en ligne)
196
+ for el in schema_root.findall(qn("element")):
197
+ name = el.get("name")
198
+ if not name:
199
+ continue
200
+ info = TypeInfo(name=name, kind="element (racine)", doc=doc_text(el))
201
+ ct = el.find(qn("complexType"))
202
+ if ct is not None:
203
+ info.attrs = parse_attributes(ct)
204
+ describe_particle(ct, info)
205
+ info.constraints = parse_constraints(el)
206
+ types[f"@{name}"] = info # préfixe pour distinguer des types portant le même nom
207
+
208
+ return types
209
+
210
+
211
+ def render_markdown(types: dict, title: str) -> str:
212
+ lines = [f"# {title}", ""]
213
+ lines.append(
214
+ "> Documentation générée automatiquement depuis le schéma XSD "
215
+ "par `xsd2doc.py`. Ne pas éditer à la main : modifier le `.xsd` "
216
+ "puis régénérer.\n"
217
+ )
218
+
219
+ roots = {k: v for k, v in types.items() if k.startswith("@")}
220
+ groups = {k: v for k, v in types.items() if v.kind == "group"}
221
+ simples = {k: v for k, v in types.items() if v.kind == "simpleType"}
222
+ complexes = {k: v for k, v in types.items()
223
+ if v.kind == "complexType"}
224
+
225
+ # Sommaire
226
+ lines.append("## Sommaire\n")
227
+ if roots:
228
+ lines.append("- **Fichiers racine** : " +
229
+ ", ".join(f"[{v.name}](#{v.name.lower()})" for v in roots.values()))
230
+ if complexes:
231
+ lines.append("- **Types complexes** : " +
232
+ ", ".join(f"[{n}](#{n.lower()})" for n in sorted(complexes)))
233
+ if groups:
234
+ lines.append("- **Groupes réutilisables** : " +
235
+ ", ".join(f"[{n}](#{n.lower()})" for n in sorted(groups)))
236
+ if simples:
237
+ lines.append("- **Types simples / énumérations** : " +
238
+ ", ".join(f"[{n}](#{n.lower()})" for n in sorted(simples)))
239
+ lines.append("")
240
+
241
+ def render_children_table(info: TypeInfo):
242
+ if not info.children:
243
+ return []
244
+ out = ["| Élément | Occurrences | Type | Description |",
245
+ "|---|---|---|---|"]
246
+ for c in info.children:
247
+ occ = f"{c.min_occurs}..{'∞' if c.max_occurs == 'unbounded' else c.max_occurs}"
248
+ type_link = (
249
+ f"[`{c.type_ref}`](#{c.type_ref.lower().split('.')[0]})"
250
+ if not c.inline and c.type_ref in types
251
+ else f"`{c.type_ref}` (en ligne)" if c.inline
252
+ else f"`{c.type_ref}`"
253
+ )
254
+ out.append(f"| `{c.name}` | {occ} | {type_link} | {c.doc or '—'} |")
255
+ out.append("")
256
+ return out
257
+
258
+ def render_attrs_table(info: TypeInfo):
259
+ if not info.attrs:
260
+ return []
261
+ out = ["| Attribut | Type | Contrainte | Description |",
262
+ "|---|---|---|---|"]
263
+ for a in info.attrs:
264
+ constraint = a.use
265
+ if a.fixed:
266
+ constraint += f", figé à `{a.fixed}`"
267
+ if a.default:
268
+ constraint += f", défaut `{a.default}`"
269
+ out.append(f"| `{a.name}` | `{a.type}` | {constraint} | {a.doc or '—'} |")
270
+ out.append("")
271
+ return out
272
+
273
+ def render_type_block(info: TypeInfo, heading_level="##"):
274
+ block = [f"{heading_level} {info.name}", ""]
275
+ if info.doc:
276
+ block.append(f"*{info.doc}*\n")
277
+ if info.kind == "simpleType":
278
+ block.append(f"Type de base : `{info.base}`\n")
279
+ if info.enum_values:
280
+ block.append("Valeurs autorisées : " +
281
+ ", ".join(f"`{v}`" for v in info.enum_values) + "\n")
282
+ else:
283
+ if info.base:
284
+ block.append(f"Contenu textuel simple, extension de `{info.base}`.\n")
285
+ block += render_attrs_table(info)
286
+ block += render_children_table(info)
287
+ if info.constraints:
288
+ block.append("**Contraintes d'intégrité :**\n")
289
+ for kind, c in info.constraints:
290
+ if kind == "keyref":
291
+ block.append(
292
+ f"- `{c['name']}` (*keyref* → `{c['refer']}`) : "
293
+ f"chaque `{c['selector']}` doit référencer un `{c['fields'][0]}` "
294
+ f"existant dans la clé correspondante."
295
+ )
296
+ elif kind == "key":
297
+ block.append(
298
+ f"- `{c['name']}` (*key*) : `{c['selector']}` est une clé "
299
+ f"faisant foi sur `{c['fields'][0]}`."
300
+ )
301
+ else:
302
+ block.append(
303
+ f"- `{c['name']}` (*unique*) : `{c['fields'][0]}` doit être "
304
+ f"unique parmi `{c['selector']}`."
305
+ )
306
+ block.append("")
307
+ return block
308
+
309
+ if roots:
310
+ lines.append("## Fichiers racine\n")
311
+ for info in roots.values():
312
+ lines += render_type_block(info, heading_level="###")
313
+
314
+ if complexes:
315
+ lines.append("## Types complexes\n")
316
+ for name in sorted(complexes):
317
+ lines += render_type_block(complexes[name], heading_level="###")
318
+
319
+ if groups:
320
+ lines.append("## Groupes réutilisables\n")
321
+ for name in sorted(groups):
322
+ lines += render_type_block(groups[name], heading_level="###")
323
+
324
+ if simples:
325
+ lines.append("## Types simples / énumérations\n")
326
+ for name in sorted(simples):
327
+ lines += render_type_block(simples[name], heading_level="###")
328
+
329
+ return "\n".join(lines) + "\n"
@@ -0,0 +1,35 @@
1
+ """Flipova Foundation gluestack config generator (implementation package).
2
+
3
+ The design pipeline has a single function: turn the registries
4
+ (design/tokens.xml + design/themes.xml) into the gluestack-ui/nativewind theme
5
+ configuration (components/ui/gluestack-ui-provider/config.ts).
6
+
7
+ Modules:
8
+
9
+ - ``common.py`` : shared imports, XML namespace, ``q()`` helper
10
+ - ``model.py`` : ManifestModel + load_manifest (manifest.xml)
11
+ - ``config.py`` : tokens/themes -> gluestack config.ts renderer (colours)
12
+ - ``tokens.py`` : tokens -> Tailwind/nativewind theme fragment (tokens.js)
13
+ - ``cli.py`` : argument parsing & dispatch (``main``)
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from .cli import main
19
+ from .common import GENERATOR_NOTE, NS, q
20
+ from .config import render_gluestack_config, theme_role_colours, theme_role_ids
21
+ from .model import ManifestModel, load_manifest
22
+ from .tokens import render_tokens_theme
23
+
24
+ __all__ = [
25
+ "GENERATOR_NOTE",
26
+ "NS",
27
+ "ManifestModel",
28
+ "load_manifest",
29
+ "main",
30
+ "q",
31
+ "render_gluestack_config",
32
+ "render_tokens_theme",
33
+ "theme_role_colours",
34
+ "theme_role_ids",
35
+ ]
@@ -0,0 +1,76 @@
1
+ """CLI (main) for the gluestack config + tokens generator."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .common import *
6
+ from .config import render_gluestack_config, theme_role_colours
7
+ from .model import load_manifest
8
+ from .tokens import render_tokens_theme
9
+
10
+ RENDERERS = {
11
+ "gluestackConfig": render_gluestack_config,
12
+ "gluestackTokens": render_tokens_theme,
13
+ }
14
+
15
+
16
+ def _list(man: ManifestModel) -> None:
17
+ for tid, roles in theme_role_colours(man):
18
+ print(f"{tid} ({len(roles)} role(s))")
19
+ for rid, triplet in roles:
20
+ print(f" --{rid}: {triplet}")
21
+
22
+
23
+ def _targets(man: ManifestModel) -> list[tuple[Path, str]]:
24
+ targets: list[tuple[Path, str]] = []
25
+ for kind, rel in man.outputs.items():
26
+ render = RENDERERS.get(kind)
27
+ if render is None:
28
+ print(f"error: manifest output {kind!r} has no generator", file=sys.stderr)
29
+ raise SystemExit(2)
30
+ if not rel:
31
+ print(f"error: manifest output {kind!r} has an empty path", file=sys.stderr)
32
+ raise SystemExit(2)
33
+ targets.append(((man.root / rel).resolve(), render(man)))
34
+ if not targets:
35
+ print("error: manifest declares no outputs", file=sys.stderr)
36
+ raise SystemExit(2)
37
+ return targets
38
+
39
+
40
+ def main() -> int:
41
+ repo_root = Path(__file__).resolve().parents[4]
42
+ default_manifest = repo_root / "design" / "manifest.xml"
43
+ parser = argparse.ArgumentParser(
44
+ description="Compile design/tokens.xml + design/themes.xml into the gluestack-ui theme config")
45
+ parser.add_argument("--manifest", "-m", default=str(default_manifest))
46
+ parser.add_argument("--root", "-r", default=str(repo_root),
47
+ help="repo root (output paths resolve against it)")
48
+ parser.add_argument("--check", action="store_true",
49
+ help="verify the generated files match (regeneration drift)")
50
+ parser.add_argument("--list", action="store_true", help="list themes and their roles")
51
+ args = parser.parse_args()
52
+
53
+ man = load_manifest(Path(args.root), Path(args.manifest))
54
+
55
+ if args.list:
56
+ _list(man)
57
+ return 0
58
+
59
+ drift = 0
60
+ for target, text in _targets(man):
61
+ if args.check:
62
+ if not target.exists() or target.read_text(encoding="utf-8") != text:
63
+ print(f"changed {target}" if target.exists() else f"missing {target}")
64
+ drift += 1
65
+ else:
66
+ target.parent.mkdir(parents=True, exist_ok=True)
67
+ with open(target, "w", encoding="utf-8", newline="\n") as fh:
68
+ fh.write(text)
69
+ print(f"written {target}")
70
+
71
+ if args.check:
72
+ if drift:
73
+ return 1
74
+ print("up to date")
75
+ return 0
76
+
@@ -0,0 +1,33 @@
1
+ """Shared imports, namespace and helpers for the .generate package.
2
+
3
+ This package has exactly one responsibility: turn the design registries
4
+ (design/tokens.xml + design/themes.xml) into the gluestack-ui/nativewind theme
5
+ configuration consumed by components/ui/gluestack-ui-provider/config.ts.
6
+
7
+ The sibling modules (config.py, model.py, cli.py) rely on
8
+ `from .common import *` to see these names, so the "unused" imports below are
9
+ deliberate re-exports (hence the noqa: F401 markers).
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import argparse # noqa: F401 (re-exported via `from .common import *`)
15
+ import re # noqa: F401 (re-exported via `from .common import *`)
16
+ import sys
17
+ from dataclasses import ( # noqa: F401 (re-exported via `from .common import *`)
18
+ dataclass,
19
+ field,
20
+ )
21
+ from pathlib import Path
22
+
23
+ from lxml import etree # noqa: F401 (re-exported via `from .common import *`)
24
+
25
+ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
26
+ import checker # noqa: F401 (registry model; re-exported via `from .common import *`)
27
+
28
+ NS = "urn:flipova:foundation:registry"
29
+ GENERATOR_NOTE = "generated by design/tools/sources/generate.py -- do not edit by hand"
30
+
31
+
32
+ def q(tag: str) -> str:
33
+ return f"{{{NS}}}{tag}"
@@ -0,0 +1,119 @@
1
+ """gluestack / nativewind config emitter.
2
+
3
+ Compiles design/tokens.xml + design/themes.xml into
4
+ components/ui/gluestack-ui-provider/config.ts:
5
+
6
+ - each theme (themes.xml) becomes a `colors.<theme-id>` record;
7
+ - each role id (the gluestack CSS variable name without the leading "--")
8
+ becomes a `'--<role>'` entry;
9
+ - each role value is resolved against the tokens registry and normalised to a
10
+ space-separated RGB triplet (the nativewind/gluestack colour format).
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from .common import *
16
+ from .model import ManifestModel
17
+
18
+ _HEADER = [
19
+ "// Generated by design/tools/sources/generate.py -- do not edit by hand.",
20
+ "// Source of truth: design/tokens.xml + design/themes.xml",
21
+ "// Regenerate with: npm run design:gen",
22
+ "import { vars } from 'nativewind';",
23
+ "",
24
+ ]
25
+
26
+
27
+ def _to_rgb_triplet(literal: str) -> str:
28
+ """Normalise a resolved colour to the gluestack format ('r g b')."""
29
+ text = literal.strip()
30
+ if text.startswith("#"):
31
+ digits = text[1:]
32
+ if len(digits) == 3:
33
+ digits = "".join(ch * 2 for ch in digits)
34
+ if len(digits) != 6:
35
+ raise SystemExit(f"unsupported colour {literal!r} (expected #RGB or #RRGGBB)")
36
+ r, g, b = (int(digits[i:i + 2], 16) for i in (0, 2, 4))
37
+ return f"{r} {g} {b}"
38
+ # Already a literal gluestack value (space-separated RGB triplet).
39
+ return " ".join(text.split())
40
+
41
+
42
+ def _resolve_colour(ctx: checker.RegistryModel, ref: str) -> str:
43
+ """Resolve `$ref.<register>.<id>.<path>` against the tokens registry."""
44
+ raw = ref.strip()
45
+ parts = raw[len("$ref."):].split(".") if raw.startswith("$ref.") else raw.split(".")
46
+ if parts and parts[0] in ctx.registers:
47
+ parts = parts[1:]
48
+ if len(parts) < 2:
49
+ raise SystemExit(f"dangling reference {ref!r} (expected $ref.<register>.<id>.<path>)")
50
+ item_id, key = parts[0], ".".join(parts[1:])
51
+ values = ctx.token_values.get(item_id)
52
+ if values is None or key not in values:
53
+ raise SystemExit(f"dangling reference {ref!r}: no token value matches")
54
+ return values[key]
55
+
56
+
57
+ def theme_role_colours(man: ManifestModel) -> list[tuple[str, list[tuple[str, str]]]]:
58
+ """[(theme_id, [(role_id, 'r g b'), ...]), ...] in themes.xml order."""
59
+ themes_path = man.ctx.catalog_files.get("themes")
60
+ if themes_path is None or not themes_path.exists():
61
+ raise SystemExit("manifest: no themes catalog file found")
62
+ root = etree.parse(str(themes_path)).getroot()
63
+ themes: list[tuple[str, list[tuple[str, str]]]] = []
64
+ for theme in root.findall(q("items") + "/" + q("theme")):
65
+ tid = (theme.get("id") or "").strip()
66
+ roles: list[tuple[str, str]] = []
67
+ for role in theme.findall(q("roleMap") + "/" + q("role")):
68
+ rid = (role.get("id") or "").strip()
69
+ ref_el = role.find(q("ref"))
70
+ val_el = role.find(q("value"))
71
+ if ref_el is not None:
72
+ literal = _resolve_colour(man.ctx, ref_el.text or "")
73
+ elif val_el is not None:
74
+ literal = val_el.text or ""
75
+ else:
76
+ raise SystemExit(f"theme {tid!r}: role {rid!r} needs a <ref> or a <value>")
77
+ roles.append((rid, _to_rgb_triplet(literal)))
78
+ themes.append((tid, roles))
79
+ return themes
80
+
81
+
82
+ def theme_role_ids(man: ManifestModel) -> list[str]:
83
+ """Ordered semantic role ids (the gluestack CSS variable names), from themes.xml.
84
+
85
+ A role id defines the semantic colour surface of the design system, so it is
86
+ emitted twice: as a `'--<role>'` variable in config.ts, and as a
87
+ `rgb(var(--<role>)/<alpha-value>)` colour in the Tailwind theme (tokens.js).
88
+ Every theme must therefore declare the same roles.
89
+ """
90
+ themes = theme_role_colours(man)
91
+ if not themes:
92
+ return []
93
+ reference = [rid for rid, _ in themes[0][1]]
94
+ for tid, roles in themes[1:]:
95
+ others = [rid for rid, _ in roles]
96
+ if others != reference:
97
+ print(f"warning: theme {tid!r} declares a different role set than "
98
+ f"{themes[0][0]!r} (Tailwind colours are generated from {themes[0][0]!r})")
99
+ return reference
100
+
101
+
102
+ def render_gluestack_config(man: ManifestModel) -> str:
103
+ themes = theme_role_colours(man)
104
+ lines = list(_HEADER)
105
+ lines.append("// Raw color values (space-separated RGB) - edit design/themes.xml and regenerate")
106
+ lines.append("export const colors = {")
107
+ for tid, roles in themes:
108
+ lines.append(f" {tid}: {{")
109
+ for rid, triplet in roles:
110
+ lines.append(f" '--{rid}': '{triplet}',")
111
+ lines.append(" },")
112
+ lines.append("};")
113
+ lines.append("")
114
+ lines.append("// Config for nativewind vars() - used by the provider")
115
+ lines.append("export const config = {")
116
+ for tid, _ in themes:
117
+ lines.append(f" {tid}: vars(colors.{tid}),")
118
+ lines.append("};")
119
+ return "\n".join(lines) + "\n"
@@ -0,0 +1,51 @@
1
+ """Manifest model (strictly read from manifest.xml)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .common import *
6
+
7
+ # ---------------------------------------------------------------------------
8
+ # Manifest model (strictly read from manifest.xml)
9
+ # ---------------------------------------------------------------------------
10
+
11
+
12
+ @dataclass
13
+ class ManifestModel:
14
+ root: Path
15
+ manifest_path: Path
16
+ schema_path: Path
17
+ source: str
18
+ outputs: dict[str, str] # output kind -> relative path
19
+ ctx: checker.RegistryModel
20
+
21
+ @property
22
+ def registers(self) -> list[str]:
23
+ return self.ctx.registers
24
+
25
+
26
+ def load_manifest(root: Path, manifest_path: Path) -> ManifestModel:
27
+ mroot = etree.parse(str(manifest_path)).getroot()
28
+ pipeline = mroot.find(q("meta") + "/" + q("pipeline"))
29
+ if pipeline is None:
30
+ raise SystemExit("manifest: missing meta/pipeline")
31
+ source_el = pipeline.find(q("source"))
32
+ outputs_el = pipeline.find(q("outputs"))
33
+ if outputs_el is None:
34
+ raise SystemExit("manifest: missing meta/pipeline/outputs")
35
+ outputs: dict[str, str] = {}
36
+ for child in outputs_el:
37
+ outputs[checker.localname(child.tag)] = (child.text or "").strip()
38
+
39
+ schema_path = manifest_path.parent / "schema.xsd"
40
+ if not schema_path.exists():
41
+ raise SystemExit("schema.xsd not found next to the manifest")
42
+
43
+ ctx = checker.build_model(root, manifest_path)
44
+ return ManifestModel(
45
+ root=root.resolve(),
46
+ manifest_path=manifest_path.resolve(),
47
+ schema_path=schema_path,
48
+ source=(source_el.text or "").strip() if source_el is not None else "",
49
+ outputs=outputs,
50
+ ctx=ctx,
51
+ )