@regardio/react 0.4.7 → 0.5.5

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 (172) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -8
  3. package/dist/{components/background-slideshow.js → background-slideshow/index.js} +2 -11
  4. package/dist/{components/blurry-gradient.js → blurry-gradient/index.js} +15 -9
  5. package/dist/{components/carousel.d.ts → carousel/index.d.ts} +17 -9
  6. package/dist/{components/carousel.js → carousel/index.js} +34 -30
  7. package/dist/{components/countdown.js → countdown/index.js} +2 -11
  8. package/dist/{components/generic-error.js → generic-error/index.js} +1 -1
  9. package/dist/grid/index.d.ts +1196 -0
  10. package/dist/grid/index.js +239 -0
  11. package/dist/heading/index.d.ts +24 -0
  12. package/dist/{components/heading.js → heading/index.js} +15 -34
  13. package/dist/highlight/index.d.ts +13 -0
  14. package/dist/{components/highlight.js → highlight/index.js} +9 -17
  15. package/dist/hooks/use-nonce.d.ts +1 -6
  16. package/dist/hooks/use-nonce.js +1 -6
  17. package/dist/{components/icon-button.js → icon-button/index.js} +1 -1
  18. package/dist/{components/if.js → if/index.js} +1 -1
  19. package/dist/{components/iframe.js → iframe/index.js} +2 -11
  20. package/dist/{components/link.d.ts → link/index.d.ts} +19 -13
  21. package/dist/{components/link.js → link/index.js} +31 -36
  22. package/dist/list/index.d.ts +69 -0
  23. package/dist/list/index.js +65 -0
  24. package/dist/{components/markdown-container.js → markdown-container/index.js} +3 -67
  25. package/dist/{components/password-input.js → password-input/index.js} +2 -11
  26. package/dist/{components/picture.js → picture/index.js} +2 -11
  27. package/dist/{components/protected-email.d.ts → protected-email/index.d.ts} +1 -1
  28. package/dist/{components/protected-email.js → protected-email/index.js} +1 -1
  29. package/dist/text/index.d.ts +20 -0
  30. package/dist/text/index.js +38 -0
  31. package/dist/utils/author/index.d.ts +3 -0
  32. package/dist/utils/author/index.js +33 -0
  33. package/dist/utils/text/index.d.ts +15 -0
  34. package/dist/utils/text/index.js +73 -0
  35. package/package.json +170 -187
  36. package/src/background-slideshow/background-slideshow.stories.tsx +137 -0
  37. package/src/{components → background-slideshow}/background-slideshow.tsx +3 -1
  38. package/src/background-slideshow/index.ts +2 -0
  39. package/src/{stories/BlurryGradient.stories.tsx → blurry-gradient/blurry-gradient.stories.tsx} +1 -1
  40. package/src/{components → blurry-gradient}/blurry-gradient.tsx +14 -8
  41. package/src/blurry-gradient/index.ts +2 -0
  42. package/src/carousel/carousel-content.tsx +16 -0
  43. package/src/carousel/carousel-item.tsx +23 -0
  44. package/src/carousel/carousel-next.tsx +22 -0
  45. package/src/carousel/carousel-previous.tsx +22 -0
  46. package/src/{components/carousel.tsx → carousel/carousel-root.tsx} +8 -78
  47. package/src/carousel/carousel.stories.tsx +135 -0
  48. package/src/carousel/index.parts.ts +5 -0
  49. package/src/carousel/index.ts +4 -0
  50. package/src/{stories/Countdown.stories.tsx → countdown/countdown.stories.tsx} +1 -1
  51. package/src/{components → countdown}/countdown.tsx +3 -7
  52. package/src/countdown/index.ts +1 -0
  53. package/src/{stories/GenericError.stories.tsx → generic-error/generic-error.stories.tsx} +1 -1
  54. package/src/{components → generic-error}/generic-error.tsx +2 -0
  55. package/src/generic-error/index.ts +2 -0
  56. package/src/grid/grid-item.tsx +188 -0
  57. package/src/grid/grid-root.tsx +72 -0
  58. package/src/grid/grid.stories.tsx +236 -0
  59. package/src/grid/index.parts.ts +2 -0
  60. package/src/grid/index.ts +5 -0
  61. package/src/{stories/Heading.stories.tsx → heading/heading.stories.tsx} +1 -1
  62. package/src/{components → heading}/heading.tsx +17 -25
  63. package/src/heading/index.ts +2 -0
  64. package/src/{stories/Highlight.stories.tsx → highlight/highlight.stories.tsx} +1 -1
  65. package/src/{components → highlight}/highlight.tsx +13 -9
  66. package/src/highlight/index.ts +2 -0
  67. package/src/hooks/use-nonce.ts +0 -10
  68. package/src/{stories/IconButton.stories.tsx → icon-button/icon-button.stories.tsx} +1 -1
  69. package/src/icon-button/index.ts +2 -0
  70. package/src/{stories/If.stories.tsx → if/if.stories.tsx} +1 -1
  71. package/src/if/index.ts +1 -0
  72. package/src/{stories/Iframe.stories.tsx → iframe/iframe.stories.tsx} +1 -1
  73. package/src/{components → iframe}/iframe.tsx +1 -1
  74. package/src/iframe/index.ts +2 -0
  75. package/src/link/index.ts +2 -0
  76. package/src/{stories/Link.stories.tsx → link/link.stories.tsx} +52 -1
  77. package/src/{components → link}/link.tsx +39 -28
  78. package/src/list/index.parts.ts +2 -0
  79. package/src/list/index.ts +4 -0
  80. package/src/list/list-item.tsx +63 -0
  81. package/src/list/list-root-context.ts +21 -0
  82. package/src/list/list-root.tsx +81 -0
  83. package/src/list/list.css +32 -0
  84. package/src/list/list.stories.tsx +119 -0
  85. package/src/list/list.test.tsx +168 -0
  86. package/src/markdown-container/index.ts +2 -0
  87. package/src/{stories/MarkdownContainer.stories.tsx → markdown-container/markdown-container.stories.tsx} +56 -1
  88. package/src/{components → markdown-container}/markdown-container.tsx +3 -1
  89. package/src/password-input/index.ts +2 -0
  90. package/src/{stories/PasswordInput.stories.tsx → password-input/password-input.stories.tsx} +1 -1
  91. package/src/{components → password-input}/password-input.tsx +4 -4
  92. package/src/picture/index.ts +2 -0
  93. package/src/{stories/Picture.stories.tsx → picture/picture.stories.tsx} +1 -1
  94. package/src/{components → picture}/picture.tsx +2 -4
  95. package/src/protected-email/index.ts +2 -0
  96. package/src/{stories/ProtectedEmail.stories.tsx → protected-email/protected-email.stories.tsx} +1 -1
  97. package/src/{components → protected-email}/protected-email.tsx +3 -1
  98. package/src/tailwind.css +10 -0
  99. package/src/text/index.ts +2 -0
  100. package/src/{stories/Text.stories.tsx → text/text.stories.tsx} +1 -1
  101. package/src/text/text.tsx +46 -0
  102. package/src/utils/author/author.tsx +36 -0
  103. package/src/utils/author/index.ts +1 -0
  104. package/src/utils/text/index.ts +1 -0
  105. package/src/utils/text/text.tsx +103 -0
  106. package/dist/components/box.d.ts +0 -20
  107. package/dist/components/box.js +0 -50
  108. package/dist/components/definition-list.d.ts +0 -43
  109. package/dist/components/definition-list.js +0 -89
  110. package/dist/components/heading.d.ts +0 -27
  111. package/dist/components/highlight.d.ts +0 -19
  112. package/dist/components/item.d.ts +0 -70
  113. package/dist/components/item.js +0 -512
  114. package/dist/components/leaflet-map.d.ts +0 -34
  115. package/dist/components/leaflet-map.js +0 -201
  116. package/dist/components/list-item.d.ts +0 -19
  117. package/dist/components/list-item.js +0 -37
  118. package/dist/components/maptiler-map.d.ts +0 -27
  119. package/dist/components/maptiler-map.js +0 -129
  120. package/dist/components/text.d.ts +0 -20
  121. package/dist/components/text.js +0 -45
  122. package/dist/components/unordered-list.d.ts +0 -19
  123. package/dist/components/unordered-list.js +0 -39
  124. package/dist/utils/author.d.ts +0 -9
  125. package/dist/utils/author.js +0 -55
  126. package/dist/utils/cn.d.ts +0 -9
  127. package/dist/utils/cn.js +0 -14
  128. package/dist/utils/is-route-active.d.ts +0 -19
  129. package/dist/utils/is-route-active.js +0 -56
  130. package/dist/utils/text.d.ts +0 -24
  131. package/dist/utils/text.js +0 -127
  132. package/src/components/box.tsx +0 -45
  133. package/src/components/definition-list.tsx +0 -90
  134. package/src/components/item.tsx +0 -340
  135. package/src/components/leaflet-map.tsx +0 -294
  136. package/src/components/link.test.tsx +0 -387
  137. package/src/components/list-item.tsx +0 -30
  138. package/src/components/maptiler-map.tsx +0 -181
  139. package/src/components/text.tsx +0 -38
  140. package/src/components/unordered-list.tsx +0 -32
  141. package/src/hooks/use-nonce.test.ts +0 -35
  142. package/src/stories/BackgroundSlideshow.stories.tsx +0 -68
  143. package/src/stories/Box.stories.tsx +0 -83
  144. package/src/stories/Carousel.stories.tsx +0 -95
  145. package/src/stories/DefinitionList.stories.tsx +0 -51
  146. package/src/stories/Item.stories.tsx +0 -79
  147. package/src/stories/ListItem.stories.tsx +0 -38
  148. package/src/stories/UnorderedList.stories.tsx +0 -73
  149. package/src/styles/tailwind.css +0 -7
  150. package/src/test-setup.ts +0 -1
  151. package/src/utils/author.test.ts +0 -54
  152. package/src/utils/author.tsx +0 -73
  153. package/src/utils/cn.test.ts +0 -48
  154. package/src/utils/cn.ts +0 -14
  155. package/src/utils/is-route-active.test.ts +0 -80
  156. package/src/utils/is-route-active.ts +0 -100
  157. package/src/utils/text.test.ts +0 -152
  158. package/src/utils/text.tsx +0 -209
  159. package/src/vite-env.d.ts +0 -1
  160. /package/dist/{components/background-slideshow.d.ts → background-slideshow/index.d.ts} +0 -0
  161. /package/dist/{components/blurry-gradient.d.ts → blurry-gradient/index.d.ts} +0 -0
  162. /package/dist/{components/countdown.d.ts → countdown/index.d.ts} +0 -0
  163. /package/dist/{components/generic-error.d.ts → generic-error/index.d.ts} +0 -0
  164. /package/dist/{components/icon-button.d.ts → icon-button/index.d.ts} +0 -0
  165. /package/dist/{components/if.d.ts → if/index.d.ts} +0 -0
  166. /package/dist/{components/iframe.d.ts → iframe/index.d.ts} +0 -0
  167. /package/dist/{components/markdown-container.d.ts → markdown-container/index.d.ts} +0 -0
  168. /package/dist/{components/password-input.d.ts → password-input/index.d.ts} +0 -0
  169. /package/dist/{components/picture.d.ts → picture/index.d.ts} +0 -0
  170. /package/src/{components → icon-button}/icon-button.tsx +0 -0
  171. /package/src/{components → if}/if.tsx +0 -0
  172. /package/src/{styles/storybook.css → storybook.css} +0 -0
@@ -1,209 +0,0 @@
1
- import React, { cloneElement, isValidElement, type ReactElement, type ReactNode } from 'react';
2
-
3
- export const lowerCaseSzett = (text: ReactNode | string, _returnType?: 'string'): ReactNode => {
4
- // Helper function to process strings
5
- const processString = (str: string): ReactNode | string => {
6
- const parts = str.split(/(ß)/g);
7
- return parts.map((part, index) =>
8
- part === 'ß' ? (
9
- <span
10
- className="lowercase"
11
- key={index.toString()}
12
- >
13
- {part}
14
- </span>
15
- ) : (
16
- part
17
- ),
18
- );
19
- };
20
-
21
- // Handle strings
22
- if (typeof text === 'string') {
23
- return processString(text);
24
- }
25
-
26
- // Handle valid React elements with correct type assertion
27
- if (isValidElement(text)) {
28
- const element = text as ReactElement<{ children?: ReactNode }>;
29
- const { children, ...props } = element.props;
30
-
31
- return cloneElement(element, {
32
- ...props,
33
- children: lowerCaseSzett(children),
34
- });
35
- }
36
-
37
- // Handle arrays
38
- if (Array.isArray(text)) {
39
- return text.map((child, index) => (
40
- <React.Fragment key={index.toString()}>{lowerCaseSzett(child as ReactNode)}</React.Fragment>
41
- ));
42
- }
43
-
44
- // Return other types as is
45
- return text;
46
- };
47
-
48
- export function toBoolean(value: string | boolean | null | undefined): boolean {
49
- if (typeof value === 'boolean') {
50
- return value;
51
- }
52
-
53
- return value === 'true' || value === '1';
54
- }
55
-
56
- function replaceShyInString(input: string): string {
57
- return input.replace(/&shy;/g, '\u00AD');
58
- }
59
-
60
- // Recursive function to traverse ReactNode and replace &shy; in string nodes
61
- function replaceShyInReactNode(node: ReactNode): ReactNode {
62
- if (typeof node === 'string') {
63
- // Replace soft hyphen (&shy;) with an empty string or custom logic
64
- return node.replace(/\u00AD/g, '');
65
- }
66
-
67
- if (isValidElement(node)) {
68
- const element = node as ReactElement<{ children?: ReactNode }>;
69
- const { children, ...props } = element.props;
70
-
71
- return cloneElement(element, {
72
- ...props,
73
- children: replaceShyInReactNode(children),
74
- });
75
- }
76
-
77
- if (Array.isArray(node)) {
78
- return node.map((child, index) => (
79
- <React.Fragment key={index.toString()}>
80
- {replaceShyInReactNode(child as ReactNode)}
81
- </React.Fragment>
82
- ));
83
- }
84
-
85
- return node;
86
- }
87
-
88
- export function shy(input: string | ReactNode | null): string | ReactNode | null {
89
- if (input === null) {
90
- return null;
91
- }
92
-
93
- if (typeof input === 'string') {
94
- return replaceShyInString(input);
95
- }
96
-
97
- return replaceShyInReactNode(input);
98
- }
99
-
100
- /**
101
- * Quote style configuration for a locale
102
- */
103
- interface QuoteStyle {
104
- /** Opening primary quote (for double quotes) */
105
- open: string;
106
- /** Closing primary quote (for double quotes) */
107
- close: string;
108
- /** Opening secondary quote (for single quotes) */
109
- openSingle: string;
110
- /** Closing secondary quote (for single quotes) */
111
- closeSingle: string;
112
- }
113
-
114
- /**
115
- * Locale-specific typographic quote styles
116
- * Using Unicode escape sequences to avoid encoding issues
117
- * @see https://en.wikipedia.org/wiki/Quotation_mark#Summary_table
118
- */
119
- const quoteStyles: Record<string, QuoteStyle> = {
120
- cs: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
121
- // Danish, Norwegian - » « › ‹
122
- da: { close: '\u00AB', closeSingle: '\u203A', open: '\u00BB', openSingle: '\u2039' },
123
- // German (Germany, Austria) - „ " ‚ '
124
- de: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
125
- // German (Switzerland) - « » ‹ ›
126
- 'de-ch': { close: '\u00BB', closeSingle: '\u203A', open: '\u00AB', openSingle: '\u2039' },
127
- // English (US, UK, etc.) - " " ' '
128
- en: { close: '\u201D', closeSingle: '\u2019', open: '\u201C', openSingle: '\u2018' },
129
- // Spanish, Italian, Portuguese - « » " "
130
- es: { close: '\u00BB', closeSingle: '\u201D', open: '\u00AB', openSingle: '\u201C' },
131
- fi: { close: '\u201D', closeSingle: '\u2019', open: '\u201D', openSingle: '\u2019' },
132
- // French - « » ‹ › (with spaces)
133
- fr: { close: ' \u00BB', closeSingle: ' \u203A', open: '\u00AB ', openSingle: '\u2039 ' },
134
- hu: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
135
- it: { close: '\u00BB', closeSingle: '\u201D', open: '\u00AB', openSingle: '\u201C' },
136
- // Japanese - 「 」 『 』
137
- ja: { close: '\u300D', closeSingle: '\u300F', open: '\u300C', openSingle: '\u300E' },
138
- // Dutch - ' ' ' '
139
- nl: { close: '\u2019', closeSingle: '\u2019', open: '\u2018', openSingle: '\u2018' },
140
- no: { close: '\u00AB', closeSingle: '\u203A', open: '\u00BB', openSingle: '\u2039' },
141
- // Polish, Czech, Hungarian - „ " ‚ '
142
- pl: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
143
- pt: { close: '\u00BB', closeSingle: '\u201D', open: '\u00AB', openSingle: '\u201C' },
144
- // Russian - « » ‚ '
145
- ru: { close: '\u00BB', closeSingle: '\u2019', open: '\u00AB', openSingle: '\u201A' },
146
- // Swedish, Finnish - " " ' '
147
- sv: { close: '\u201D', closeSingle: '\u2019', open: '\u201D', openSingle: '\u2019' },
148
- // Chinese - 「 」 『 』
149
- zh: { close: '\u300D', closeSingle: '\u300F', open: '\u300C', openSingle: '\u300E' },
150
- };
151
-
152
- /**
153
- * Get the quote style for a given locale.
154
- * Falls back to base language if region-specific style not found,
155
- * then to English style as default.
156
- */
157
- function getQuoteStyle(locale: string): QuoteStyle {
158
- const normalized = locale.toLowerCase();
159
-
160
- // Try exact match first
161
- const exactMatch = quoteStyles[normalized];
162
- if (exactMatch) {
163
- return exactMatch;
164
- }
165
-
166
- // Try base language (e.g., 'de' from 'de-DE')
167
- const baseLanguage = normalized.split('-')[0];
168
- if (baseLanguage) {
169
- const baseMatch = quoteStyles[baseLanguage];
170
- if (baseMatch) {
171
- return baseMatch;
172
- }
173
- }
174
-
175
- // Default to English - we know 'en' exists
176
- return quoteStyles.en as QuoteStyle;
177
- }
178
-
179
- /**
180
- * Replace straight quotes with typographically correct quotes for the given locale.
181
- *
182
- * @param text - The text containing straight quotes
183
- * @param locale - The locale to use for quote style (e.g., 'en', 'de', 'fr')
184
- * @returns Text with typographic quotes
185
- *
186
- * @example
187
- * typographicQuotes('"Hello"', 'en') // → '"Hello"'
188
- * typographicQuotes('"Hello"', 'de') // → '„Hello"'
189
- * typographicQuotes('"Hello"', 'fr') // → '« Hello »'
190
- */
191
- export function typographicQuotes(text: string, locale: string): string {
192
- const style = getQuoteStyle(locale);
193
-
194
- // Replace double quotes
195
- let result = text.replace(/"([^"]*)"/g, `${style.open}$1${style.close}`);
196
-
197
- // Replace single quotes (apostrophes that are actually quotes)
198
- // Only replace pairs, not contractions like "don't"
199
- result = result.replace(/'([^']*)'/g, `${style.openSingle}$1${style.closeSingle}`);
200
-
201
- return result;
202
- }
203
-
204
- /**
205
- * @deprecated Use `typographicQuotes` for quote replacement and `shy` separately
206
- */
207
- export function replaceSpecialChars(text: string, locale: string) {
208
- return shy(typographicQuotes(text, locale));
209
- }
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
File without changes
File without changes
File without changes
File without changes