@dracor/react 0.8.0 → 1.0.0-alpha.2

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