@dracor/react 0.9.0 → 1.0.0-beta.1

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 (114) hide show
  1. package/README.md +42 -22
  2. package/dist/index.d.ts +208 -117
  3. package/dist/index.es.js +1548 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.umd.js +44 -0
  6. package/dist/index.umd.js.map +1 -0
  7. package/package.json +98 -75
  8. package/src/dracor.css +142 -0
  9. package/ceteicean.js +0 -46
  10. package/dist/cjs/index.js +0 -4631
  11. package/dist/cjs/index.js.map +0 -1
  12. package/dist/cjs/types/components/ApiDoc/ApiDoc.d.ts +0 -6
  13. package/dist/cjs/types/components/ApiDoc/ApiDoc.stories.d.ts +0 -21
  14. package/dist/cjs/types/components/ApiDoc/ApiDoc.test.d.ts +0 -1
  15. package/dist/cjs/types/components/ApiDoc/index.d.ts +0 -1
  16. package/dist/cjs/types/components/AuthorInfo/AuthorInfo.d.ts +0 -7
  17. package/dist/cjs/types/components/AuthorInfo/AuthorInfo.stories.d.ts +0 -10
  18. package/dist/cjs/types/components/AuthorInfo/AuthorInfo.test.d.ts +0 -1
  19. package/dist/cjs/types/components/AuthorInfo/index.d.ts +0 -1
  20. package/dist/cjs/types/components/Authors/Authors.d.ts +0 -10
  21. package/dist/cjs/types/components/Authors/Authors.stories.d.ts +0 -12
  22. package/dist/cjs/types/components/Authors/Authors.test.d.ts +0 -1
  23. package/dist/cjs/types/components/Authors/index.d.ts +0 -1
  24. package/dist/cjs/types/components/DebouncedInput/DebouncedInput.d.ts +0 -6
  25. package/dist/cjs/types/components/DebouncedInput/index.d.ts +0 -1
  26. package/dist/cjs/types/components/IdCopy/IdCopy.d.ts +0 -8
  27. package/dist/cjs/types/components/IdCopy/IdCopy.stories.d.ts +0 -11
  28. package/dist/cjs/types/components/IdCopy/IdCopy.test.d.ts +0 -1
  29. package/dist/cjs/types/components/IdCopy/index.d.ts +0 -1
  30. package/dist/cjs/types/components/IdLink/IdLink.d.ts +0 -7
  31. package/dist/cjs/types/components/IdLink/IdLink.stories.d.ts +0 -15
  32. package/dist/cjs/types/components/IdLink/IdLink.test.d.ts +0 -1
  33. package/dist/cjs/types/components/IdLink/index.d.ts +0 -1
  34. package/dist/cjs/types/components/Navigation/NavBar.d.ts +0 -13
  35. package/dist/cjs/types/components/Navigation/NavBar.stories.d.ts +0 -28
  36. package/dist/cjs/types/components/Navigation/NavBar.test.d.ts +0 -1
  37. package/dist/cjs/types/components/Navigation/NavItem.d.ts +0 -8
  38. package/dist/cjs/types/components/Navigation/NavItem.stories.d.ts +0 -19
  39. package/dist/cjs/types/components/Navigation/NavMenu.d.ts +0 -12
  40. package/dist/cjs/types/components/Navigation/NavMenu.stories.d.ts +0 -19
  41. package/dist/cjs/types/components/Navigation/index.d.ts +0 -1
  42. package/dist/cjs/types/components/TEIText/TEIText.d.ts +0 -14
  43. package/dist/cjs/types/components/TEIText/TEIText.stories.d.ts +0 -10
  44. package/dist/cjs/types/components/TEIText/index.d.ts +0 -1
  45. package/dist/cjs/types/components/Table/Table.d.ts +0 -11
  46. package/dist/cjs/types/components/Table/Table.stories.d.ts +0 -9
  47. package/dist/cjs/types/components/Table/Table.test.d.ts +0 -1
  48. package/dist/cjs/types/components/Table/index.d.ts +0 -1
  49. package/dist/cjs/types/components/Tabs/Tabs.d.ts +0 -11
  50. package/dist/cjs/types/components/Tabs/Tabs.stories.d.ts +0 -23
  51. package/dist/cjs/types/components/Tabs/Tabs.test.d.ts +0 -1
  52. package/dist/cjs/types/components/Tabs/index.d.ts +0 -1
  53. package/dist/cjs/types/components/Years/Years.d.ts +0 -10
  54. package/dist/cjs/types/components/Years/Years.stories.d.ts +0 -11
  55. package/dist/cjs/types/components/Years/Years.test.d.ts +0 -1
  56. package/dist/cjs/types/components/Years/index.d.ts +0 -1
  57. package/dist/cjs/types/components/index.d.ts +0 -10
  58. package/dist/cjs/types/einakter-gh.d.ts +0 -2
  59. package/dist/cjs/types/index.d.ts +0 -2
  60. package/dist/cjs/types/testHelpers.d.ts +0 -7
  61. package/dist/cjs/types/utils.d.ts +0 -2
  62. package/dist/esm/index.js +0 -4618
  63. package/dist/esm/index.js.map +0 -1
  64. package/dist/esm/types/components/ApiDoc/ApiDoc.d.ts +0 -6
  65. package/dist/esm/types/components/ApiDoc/ApiDoc.stories.d.ts +0 -21
  66. package/dist/esm/types/components/ApiDoc/ApiDoc.test.d.ts +0 -1
  67. package/dist/esm/types/components/ApiDoc/index.d.ts +0 -1
  68. package/dist/esm/types/components/AuthorInfo/AuthorInfo.d.ts +0 -7
  69. package/dist/esm/types/components/AuthorInfo/AuthorInfo.stories.d.ts +0 -10
  70. package/dist/esm/types/components/AuthorInfo/AuthorInfo.test.d.ts +0 -1
  71. package/dist/esm/types/components/AuthorInfo/index.d.ts +0 -1
  72. package/dist/esm/types/components/Authors/Authors.d.ts +0 -10
  73. package/dist/esm/types/components/Authors/Authors.stories.d.ts +0 -12
  74. package/dist/esm/types/components/Authors/Authors.test.d.ts +0 -1
  75. package/dist/esm/types/components/Authors/index.d.ts +0 -1
  76. package/dist/esm/types/components/DebouncedInput/DebouncedInput.d.ts +0 -6
  77. package/dist/esm/types/components/DebouncedInput/index.d.ts +0 -1
  78. package/dist/esm/types/components/IdCopy/IdCopy.d.ts +0 -8
  79. package/dist/esm/types/components/IdCopy/IdCopy.stories.d.ts +0 -11
  80. package/dist/esm/types/components/IdCopy/IdCopy.test.d.ts +0 -1
  81. package/dist/esm/types/components/IdCopy/index.d.ts +0 -1
  82. package/dist/esm/types/components/IdLink/IdLink.d.ts +0 -7
  83. package/dist/esm/types/components/IdLink/IdLink.stories.d.ts +0 -15
  84. package/dist/esm/types/components/IdLink/IdLink.test.d.ts +0 -1
  85. package/dist/esm/types/components/IdLink/index.d.ts +0 -1
  86. package/dist/esm/types/components/Navigation/NavBar.d.ts +0 -13
  87. package/dist/esm/types/components/Navigation/NavBar.stories.d.ts +0 -28
  88. package/dist/esm/types/components/Navigation/NavBar.test.d.ts +0 -1
  89. package/dist/esm/types/components/Navigation/NavItem.d.ts +0 -8
  90. package/dist/esm/types/components/Navigation/NavItem.stories.d.ts +0 -19
  91. package/dist/esm/types/components/Navigation/NavMenu.d.ts +0 -12
  92. package/dist/esm/types/components/Navigation/NavMenu.stories.d.ts +0 -19
  93. package/dist/esm/types/components/Navigation/index.d.ts +0 -1
  94. package/dist/esm/types/components/TEIText/TEIText.d.ts +0 -14
  95. package/dist/esm/types/components/TEIText/TEIText.stories.d.ts +0 -10
  96. package/dist/esm/types/components/TEIText/index.d.ts +0 -1
  97. package/dist/esm/types/components/Table/Table.d.ts +0 -11
  98. package/dist/esm/types/components/Table/Table.stories.d.ts +0 -9
  99. package/dist/esm/types/components/Table/Table.test.d.ts +0 -1
  100. package/dist/esm/types/components/Table/index.d.ts +0 -1
  101. package/dist/esm/types/components/Tabs/Tabs.d.ts +0 -11
  102. package/dist/esm/types/components/Tabs/Tabs.stories.d.ts +0 -23
  103. package/dist/esm/types/components/Tabs/Tabs.test.d.ts +0 -1
  104. package/dist/esm/types/components/Tabs/index.d.ts +0 -1
  105. package/dist/esm/types/components/Years/Years.d.ts +0 -10
  106. package/dist/esm/types/components/Years/Years.stories.d.ts +0 -11
  107. package/dist/esm/types/components/Years/Years.test.d.ts +0 -1
  108. package/dist/esm/types/components/Years/index.d.ts +0 -1
  109. package/dist/esm/types/components/index.d.ts +0 -10
  110. package/dist/esm/types/einakter-gh.d.ts +0 -2
  111. package/dist/esm/types/index.d.ts +0 -2
  112. package/dist/esm/types/testHelpers.d.ts +0 -7
  113. package/dist/esm/types/utils.d.ts +0 -2
  114. package/tailwind.js +0 -57
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dracor-react
2
2
 
3
- The *DraCor React Component Library* provides reusable [react](https://react.dev)
3
+ The _DraCor React Component Library_ provides reusable [react](https://react.dev)
4
4
  components for various [DraCor](https://dracor.org) and related projects.
5
5
 
6
6
  The components are documented in
@@ -14,37 +14,57 @@ First add the DraCor React components to your react project:
14
14
  npm i @dracor/react
15
15
  # or
16
16
  yarn add @dracor/react
17
+ # or
18
+ pnpm add @dracor/react
19
+ ```
20
+
21
+ Then add the following two lines to your index.css file to import the DraCor
22
+ Tailwind theme and make the tailwind compiler aware of the utility classes the
23
+ DraCor components are using:
24
+
25
+ ```css
26
+ @import "@dracor/react/dracor.css";
27
+ @source "../node_modules/@dracor/react";
17
28
  ```
18
29
 
19
- Then adjust your tailwind.config.js to make the DraCor styles available to your
20
- project:
21
-
22
- ```js
23
- // tailwind.config.js
24
- module.exports = {
25
- // make the library available to the tailwind compiler
26
- content: [
27
- './node_modules/@dracor/react/**/*.js',
28
- './src/**/*.{js,jsx,ts,tsx}',
29
- ],
30
- plugins: [
31
- // main DraCor Tailwindcss customization
32
- require('@dracor/react/tailwind'),
33
- // support CETEIcean markup in the TEIText component
34
- require('@dracor/react/ceteicean'),
35
- ],
36
-
37
- // ... your customisations
38
- };
30
+ ### React Helmet integration
31
+
32
+ Several components optionally integrate with
33
+ [React Helmet](https://github.com/staylor/react-helmet-async), which is a peer
34
+ dependency of this package:
35
+
36
+ ```sh
37
+ npm i react-helmet-async
39
38
  ```
40
39
 
40
+ If you intend to make use of this integration you need to set up the
41
+ `HelmetProvider`:
42
+
43
+ ```jsx
44
+ // index.tsx
45
+ import { HelmetProvider } from 'react-helmet-async';
46
+ import App from './App';
47
+
48
+ const root = ReactDOM.createRoot(
49
+ document.getElementById('root') as HTMLElement
50
+ );
51
+
52
+ root.render(
53
+ <HelmetProvider>
54
+ <App />
55
+ </HelmetProvider>
56
+ )
57
+ ```
58
+
59
+ See https://github.com/staylor/react-helmet-async#usage for details.
60
+
41
61
  ## Publication
42
62
 
43
63
  To release a new version to npmjs.com you need to be a member of the
44
64
  [dracor organization](https://www.npmjs.com/org/dracor).
45
65
 
46
66
  ```sh
47
- yarn release
67
+ pnpm release
48
68
  ```
49
69
 
50
70
  ## License
package/dist/index.d.ts CHANGED
@@ -1,120 +1,211 @@
1
- /// <reference types="react" />
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { ColumnDef, SortingState } from '@tanstack/react-table';
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+ import { JSX } from 'react/jsx-runtime';
3
+ import { JSX as JSX_2 } from 'react';
4
+ import { SortingState } from '@tanstack/react-table';
5
+
6
+ /**
7
+ * Renders a Swagger UI page for the provided OpenAPI specification.
8
+ *
9
+ * This component requires `swagger-ui-react` and `@types/swagger-ui-react` to
10
+ * be installed as peer dependencies.
11
+ *
12
+ * For proper styling the Swagger UI stylesheet needs to be imported:
13
+ *
14
+ * ```
15
+ * import {ApiDoc} from '@dracor/react';
16
+ * import 'swagger-ui-react/swagger-ui.css';
17
+ *
18
+ * <ApiDoc url="/api.yaml" />
19
+ * ```
20
+ */
21
+ export declare function ApiDoc({ url, title }: Props): JSX.Element;
22
+
23
+ declare interface Author {
24
+ name: string;
25
+ pseudonym?: string;
26
+ ref?: string;
27
+ }
28
+
29
+ export declare function AuthorInfo({ wikidataId, name: fullname, birthLabel, deathLabel, unknownLabel, }: Props_2): JSX.Element;
30
+
31
+ export declare const Authors: ({ data }: Props_3) => JSX.Element;
32
+
33
+ export declare function DebouncedInput({ value: initialValue, onChange, debounce, ...props }: {
34
+ value: string | number;
35
+ onChange: (value: string | number) => void;
36
+ debounce?: number;
37
+ } & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'>): JSX.Element;
38
+
39
+ export declare function DocPage({ url, match }: Props_4): JSX.Element;
40
+
41
+ /**
42
+ * The download button displays an icon for the supported file types. If the
43
+ * type is omitted the download file name is displayed as link text.
44
+ */
45
+ export declare function DownloadButton({ href, type, name }: Props_5): JSX.Element;
46
+
47
+ export declare function formatEra(year: string, ceBefore?: number): string;
48
+
49
+ export declare function formatYear(year: number | string, locale?: string): string;
50
+
51
+ export declare function IdCopy({ children, className, uri, prefix, icon, }: Props_6): JSX.Element;
52
+
53
+ export declare function IdLink({ showLabel, children, className }: Props_7): JSX.Element;
54
+
55
+ declare interface Item {
56
+ label: string;
57
+ href: string;
58
+ selected?: boolean;
59
+ }
60
+
61
+ export declare function LanguageMenu({ languages, current, onSelect, }: Props_8): JSX.Element;
62
+
63
+ export declare function NavBar({ title, logo, logoClass, version, gitHubUrl, gitHubIcon, gitHubTitle, addItem, navItems, }: NavBarProps): JSX.Element;
64
+
65
+ declare interface NavBarProps {
66
+ title: string;
67
+ logo?: string;
68
+ logoClass?: string;
69
+ version?: string;
70
+ gitHubUrl?: string;
71
+ gitHubIcon?: JSX_2.Element;
72
+ gitHubTitle?: string;
73
+ navItems?: (Props_9 | Props_10)[];
74
+ addItem?: JSX_2.Element;
75
+ }
76
+
77
+ declare interface Props {
78
+ /**
79
+ * URL to OpenAPI specification
80
+ */
81
+ url: string;
82
+ /**
83
+ * Optional page title passed to `Helmet`
84
+ */
85
+ title?: string;
86
+ }
87
+
88
+ declare interface Props_10 {
89
+ label: string;
90
+ items: Item[];
91
+ menuClass?: string;
92
+ }
93
+
94
+ declare interface Props_11<TData = unknown> {
95
+ data: TData[];
96
+ columns: ColumnDef<TData>[];
97
+ defaultSort?: SortingState;
98
+ }
99
+
100
+ declare interface Props_12 {
101
+ data: TabData[];
102
+ }
103
+
104
+ declare interface Props_13 {
105
+ /**
106
+ * URL to a TEI document
107
+ */
108
+ url: string;
109
+ }
110
+
111
+ declare interface Props_14 {
112
+ written?: number;
113
+ premiere?: number;
114
+ print?: number;
115
+ locale?: string;
116
+ labelWritten?: string;
117
+ labelPremiered?: string;
118
+ labelPrinted?: string;
119
+ }
120
+
121
+ declare interface Props_2 {
122
+ wikidataId: string;
123
+ name?: string;
124
+ birthLabel?: string;
125
+ deathLabel?: string;
126
+ unknownLabel?: string;
127
+ }
128
+
129
+ declare interface Props_3 {
130
+ data: Author[];
131
+ }
132
+
133
+ declare interface Props_4 {
134
+ url?: string;
135
+ match?: () => string | null;
136
+ }
137
+
138
+ declare interface Props_5 {
139
+ /**
140
+ * URL to download
141
+ */
142
+ href: string;
143
+ /**
144
+ * Download file name
145
+ *
146
+ * The name needs to start with an ASCII character or a digit. Otherwise the
147
+ * name "download" will be used.
148
+ */
149
+ name: string;
150
+ /**
151
+ * File type of the download
152
+ */
153
+ type?: 'bibtex' | 'csv' | 'gexf' | 'graphml' | 'json' | 'rdf' | 'ris' | 'tei' | 'txt';
154
+ }
155
+
156
+ declare interface Props_6 {
157
+ children: string;
158
+ prefix?: string;
159
+ uri?: string;
160
+ className?: string;
161
+ icon?: 'ein' | 'dracor';
162
+ }
163
+
164
+ declare interface Props_7 {
165
+ button?: boolean;
166
+ showLabel?: boolean;
167
+ className?: string;
168
+ children: string;
169
+ }
170
+
171
+ declare interface Props_8 {
172
+ languages: string[];
173
+ current?: string;
174
+ onSelect: (lang: string) => void;
175
+ }
176
+
177
+ declare interface Props_9 {
178
+ label: string;
179
+ href: string;
180
+ active?: boolean;
181
+ className?: string;
182
+ }
183
+
184
+ declare interface TabData {
185
+ label: string;
186
+ href: string;
187
+ active?: boolean;
188
+ }
189
+
190
+ export declare function Table<T>({ columns, data: initialData, defaultSort }: Props_11<T>): JSX.Element;
191
+
192
+ export declare function Tabs({ data: tabs }: Props_12): JSX.Element;
193
+
194
+ /**
195
+ * Component rendering a TEI document using [CETEIcean](https://github.com/TEIC/CETEIcean)
196
+ *
197
+ * The DraCor Tailwind theme provides some styling for the TEI elements. Import
198
+ * the theme adding `@import "@dracor/react/dracor.css";` to your index.css.
199
+ */
200
+ export declare function TEIText({ url }: Props_13): JSX.Element;
201
+
202
+ export declare function Years({ written, premiere, print, locale, labelPremiered, labelPrinted, labelWritten, }: Props_14): JSX.Element;
203
+
204
+ export { }
4
205
 
5
- interface Props$9 {
6
- wikidataId: string;
7
- name?: string;
8
- birthLabel?: string;
9
- deathLabel?: string;
10
- }
11
- declare function AuthorInfo({ wikidataId, name: fullname, birthLabel, deathLabel }: Props$9): react_jsx_runtime.JSX.Element;
12
-
13
- interface Author {
14
- name: string;
15
- pseudonym?: string;
16
- ref?: string;
17
- }
18
- interface Props$8 {
19
- data: Author[];
20
- }
21
- declare const Authors: ({ data }: Props$8) => react_jsx_runtime.JSX.Element;
22
-
23
- declare function DebouncedInput({ value: initialValue, onChange, debounce, ...props }: {
24
- value: string | number;
25
- onChange: (value: string | number) => void;
26
- debounce?: number;
27
- } & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'>): react_jsx_runtime.JSX.Element;
28
-
29
- interface Props$7 {
30
- children: string;
31
- prefix?: string;
32
- uri?: string;
33
- className?: string;
34
- }
35
- declare function IdCopy({ children, className, uri, prefix }: Props$7): react_jsx_runtime.JSX.Element;
36
206
 
37
- interface Props$6 {
38
- button?: boolean;
39
- showLabel?: boolean;
40
- className?: string;
41
- children: string;
207
+ declare module '@tanstack/react-router' {
208
+ interface Register {
209
+ router: typeof dummyRouter;
210
+ }
42
211
  }
43
- declare function IdLink({ showLabel, children, className }: Props$6): react_jsx_runtime.JSX.Element;
44
-
45
- interface Props$5 {
46
- label: string;
47
- href: string;
48
- active?: boolean;
49
- className?: string;
50
- }
51
-
52
- interface Item {
53
- label: string;
54
- href: string;
55
- selected?: boolean;
56
- }
57
- interface Props$4 {
58
- label: string;
59
- items: Item[];
60
- menuClass?: string;
61
- }
62
-
63
- interface NavBarProps {
64
- title: string;
65
- logo?: string;
66
- logoClass?: string;
67
- version?: string;
68
- gitHubUrl?: string;
69
- gitHubIcon?: JSX.Element;
70
- navItems?: (Props$5 | Props$4)[];
71
- }
72
- declare function NavBar({ title, logo, logoClass, version, gitHubUrl, gitHubIcon, navItems }: NavBarProps): react_jsx_runtime.JSX.Element;
73
-
74
- interface Props$3 {
75
- data: any[];
76
- columns: ColumnDef<any>[];
77
- defaultSort?: SortingState;
78
- }
79
- declare const Table: ({ columns, data: initialData, defaultSort }: Props$3) => react_jsx_runtime.JSX.Element;
80
-
81
- interface TabData {
82
- label: string;
83
- href: string;
84
- active?: boolean;
85
- }
86
- interface Props$2 {
87
- data: TabData[];
88
- }
89
- declare function Tabs({ data: tabs }: Props$2): react_jsx_runtime.JSX.Element;
90
-
91
- interface Props$1 {
92
- /**
93
- * URL to a TEI document
94
- */
95
- url: string;
96
- }
97
- /**
98
- * Component rendering a TEI document using [CETEIcean](https://github.com/TEIC/CETEIcean)
99
- *
100
- * Styling of the TEI elements is supported via the `ceteicean` tailwindcss
101
- * plugin. Add `require('@dracor/react/ceteicean')` to the plugins array of your
102
- * tailwind.config.js.
103
- */
104
- declare function TEIText({ url }: Props$1): react_jsx_runtime.JSX.Element;
105
-
106
- interface Props {
107
- written?: number;
108
- premiere?: number;
109
- print?: number;
110
- locale?: string;
111
- labelWritten?: string;
112
- labelPremiered?: string;
113
- labelPrinted?: string;
114
- }
115
- declare function Years({ written, premiere, print, locale, labelPremiered, labelPrinted, labelWritten, }: Props): react_jsx_runtime.JSX.Element;
116
-
117
- declare function formatEra(year: string, ceBefore?: number): string;
118
- declare function formatYear(year: number | string, locale?: string): string;
119
-
120
- export { AuthorInfo, Authors, DebouncedInput, IdCopy, IdLink, NavBar, TEIText, Table, Tabs, Years, formatEra, formatYear };