backend.ai-ui 0.0.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 (84) hide show
  1. package/README.md +192 -0
  2. package/dist/__generated__/BAISessionTypeTagFragment.graphql.d.ts +11 -0
  3. package/dist/backend.ai-ui.d.ts +2 -0
  4. package/dist/backend.ai-ui.js +8247 -0
  5. package/dist/backend.ai-ui.js.map +1 -0
  6. package/dist/common-BqeHlhne.js +62 -0
  7. package/dist/common-BqeHlhne.js.map +1 -0
  8. package/dist/common-CMrtHk6c.js +10 -0
  9. package/dist/common-CMrtHk6c.js.map +1 -0
  10. package/dist/components/BAICard.d.ts +12 -0
  11. package/dist/components/BAIConfigProvider.d.ts +7 -0
  12. package/dist/components/BAIResourceWithSteppedProgress.d.ts +11 -0
  13. package/dist/components/Flex.d.ts +12 -0
  14. package/dist/components/Flex.stories.d.ts +7 -0
  15. package/dist/components/fragments/BAISessionTypeTag.d.ts +7 -0
  16. package/dist/components/tests/BAITestButton.d.ts +2 -0
  17. package/dist/index.d.ts +4 -0
  18. package/dist/locale/de_DE.d.ts +3 -0
  19. package/dist/locale/de_DE.js +186 -0
  20. package/dist/locale/de_DE.js.map +1 -0
  21. package/dist/locale/el_GR.d.ts +3 -0
  22. package/dist/locale/el_GR.js +203 -0
  23. package/dist/locale/el_GR.js.map +1 -0
  24. package/dist/locale/en_US.d.ts +3 -0
  25. package/dist/locale/en_US.js +206 -0
  26. package/dist/locale/en_US.js.map +1 -0
  27. package/dist/locale/es_ES.d.ts +3 -0
  28. package/dist/locale/es_ES.js +185 -0
  29. package/dist/locale/es_ES.js.map +1 -0
  30. package/dist/locale/fi_FI.d.ts +3 -0
  31. package/dist/locale/fi_FI.js +105 -0
  32. package/dist/locale/fi_FI.js.map +1 -0
  33. package/dist/locale/fr_FR.d.ts +3 -0
  34. package/dist/locale/fr_FR.js +189 -0
  35. package/dist/locale/fr_FR.js.map +1 -0
  36. package/dist/locale/id_ID.d.ts +3 -0
  37. package/dist/locale/id_ID.js +206 -0
  38. package/dist/locale/id_ID.js.map +1 -0
  39. package/dist/locale/index.d.ts +6 -0
  40. package/dist/locale/it_IT.d.ts +3 -0
  41. package/dist/locale/it_IT.js +184 -0
  42. package/dist/locale/it_IT.js.map +1 -0
  43. package/dist/locale/ja_JP.d.ts +3 -0
  44. package/dist/locale/ja_JP.js +210 -0
  45. package/dist/locale/ja_JP.js.map +1 -0
  46. package/dist/locale/ko_KR.d.ts +3 -0
  47. package/dist/locale/ko_KR.js +206 -0
  48. package/dist/locale/ko_KR.js.map +1 -0
  49. package/dist/locale/mn_MN.d.ts +3 -0
  50. package/dist/locale/mn_MN.js +180 -0
  51. package/dist/locale/mn_MN.js.map +1 -0
  52. package/dist/locale/ms_MY.d.ts +3 -0
  53. package/dist/locale/ms_MY.js +196 -0
  54. package/dist/locale/ms_MY.js.map +1 -0
  55. package/dist/locale/pl_PL.d.ts +3 -0
  56. package/dist/locale/pl_PL.js +188 -0
  57. package/dist/locale/pl_PL.js.map +1 -0
  58. package/dist/locale/pt_BR.d.ts +3 -0
  59. package/dist/locale/pt_BR.js +186 -0
  60. package/dist/locale/pt_BR.js.map +1 -0
  61. package/dist/locale/pt_PT.d.ts +3 -0
  62. package/dist/locale/pt_PT.js +223 -0
  63. package/dist/locale/pt_PT.js.map +1 -0
  64. package/dist/locale/ru_RU.d.ts +3 -0
  65. package/dist/locale/ru_RU.js +205 -0
  66. package/dist/locale/ru_RU.js.map +1 -0
  67. package/dist/locale/th_TH.d.ts +3 -0
  68. package/dist/locale/th_TH.js +203 -0
  69. package/dist/locale/th_TH.js.map +1 -0
  70. package/dist/locale/tr_TR.d.ts +3 -0
  71. package/dist/locale/tr_TR.js +191 -0
  72. package/dist/locale/tr_TR.js.map +1 -0
  73. package/dist/locale/vi_VN.d.ts +3 -0
  74. package/dist/locale/vi_VN.js +197 -0
  75. package/dist/locale/vi_VN.js.map +1 -0
  76. package/dist/locale/zh_CN.d.ts +3 -0
  77. package/dist/locale/zh_CN.js +210 -0
  78. package/dist/locale/zh_CN.js.map +1 -0
  79. package/dist/locale/zh_TW.d.ts +3 -0
  80. package/dist/locale/zh_TW.js +209 -0
  81. package/dist/locale/zh_TW.js.map +1 -0
  82. package/dist/objectSpread2-D0Q_N5dg.js +57 -0
  83. package/dist/objectSpread2-D0Q_N5dg.js.map +1 -0
  84. package/package.json +94 -0
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # backend.ai-ui
2
+
3
+ This is a React component project for WebUI.
4
+
5
+ ## How to setup relay
6
+
7
+ > [!NOTE]
8
+ > This project contains components related to Relay. Before using these components, please ensure that your project is properly set up with a suitable Relay environment, if necessary, by following the steps below.
9
+
10
+ 1. Set up Relay with a multi-project and configure it so that this project can be compiled.
11
+
12
+ ```js
13
+ // relay.config.js or relay.config.json
14
+ module.exports = {
15
+ root: '.',
16
+ sources: {
17
+ 'packages/backend.ai-ui': 'backend.ai-ui',
18
+ 'your-project-path': 'your-project',
19
+ },
20
+ excludes: ['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'],
21
+ projects: {
22
+ 'backend.ai-ui': {
23
+ language: 'typescript',
24
+ schema: 'schema-path',
25
+ output: 'packages/backend.ai-ui/src/__generated__',
26
+ eagerEsModules: true,
27
+ ...options,
28
+ },
29
+ 'your-project': {
30
+ language: 'your language',
31
+ schema: 'schema-path',
32
+ output: 'your-project-path/output-path',
33
+ base: 'backend.ai-ui', // to use backend.ai-ui's fragment
34
+ ...options,
35
+ },
36
+ },
37
+ };
38
+ ```
39
+
40
+ 2. Run the relay-compiler and make sure that the `backend.ai-ui` project compiles successfully.
41
+
42
+ ```console
43
+ $ relay-compiler
44
+ ```
45
+
46
+ 3. Depending on the bundler environment, you may need to set up an `alias` for `__generated__`. With the following configuration, relay-compiler will be able to correctly resolve the `__generated__` path.
47
+
48
+ ```ts
49
+ // vite.config.ts
50
+ export default defineConfig({
51
+ resolve: {
52
+ alias: {
53
+ // This is used to resolve the __generated__ directory for Relay
54
+ // Since relay uses the directory './__generated__' internally, map this to your-project-path/__generated__.
55
+ './__generated__': resolve(__dirname, 'your-project-path/__generated__'),
56
+ },
57
+ },
58
+
59
+ // craco.config.js or webpack.config.js
60
+ resolve: {
61
+ ...webpackConfig.resolve,
62
+ alias: {
63
+ ...webpackConfig.resolve.alias,
64
+ './__generated__': path.resolve(__dirname, 'your-project-path/__generated__'),
65
+ },
66
+ ```
67
+
68
+ ## How to create a component
69
+
70
+ 1. Please create a React component file under `src/components`.
71
+ 2. Export your component in `src/index.ts`.
72
+ ```ts
73
+ // index.ts
74
+ export { default as YourComponent } from './components/YourComponent';
75
+ ```
76
+ 3. You can use your component in your project by importing it.
77
+ ```tsx
78
+ // in your project
79
+ import { YourComponent } from 'backend.ai-ui';
80
+ ```
81
+ 4. If you’ve created a fragment component, you need to spread it into the parent component and pass it as a prop.
82
+
83
+ ```tsx
84
+ // relay component in backendai-ui
85
+ import { FragmentComponent$key } from '../__generated__/FragmentComponent.graphql';
86
+ import { useFragment, graphql } from 'react-relay';
87
+
88
+ export interface RelayComponentProps {
89
+ fragment: RelayComponent$key;
90
+ }
91
+ const FragmentComponent = ({ fragment }: FragmentComponentProps) => {
92
+ ...
93
+ const data = useFragment(
94
+ graphql`
95
+ fragment FragmentComponent on AnyNode {
96
+ ...fields
97
+ }
98
+ `,
99
+ fragment,
100
+ )
101
+ };
102
+ ```
103
+
104
+ ```tsx
105
+ // in your project
106
+ import { FragmentComponent } from 'backend.ai-ui';
107
+
108
+ const ParentComponent = () => {
109
+ const { data } = useQueryLoader(
110
+ graphql`
111
+ query ParentComponentQuery {
112
+ ...fields
113
+ node {
114
+ ...FragmentComponent // spread fragment component
115
+ }
116
+ }
117
+ `,
118
+ );
119
+
120
+ return <FragmentComponent fragment={data.node} />;
121
+ };
122
+ ```
123
+
124
+ ## How to build
125
+
126
+ ### Building a Vite app
127
+
128
+ ```console
129
+ $ pnpm run build
130
+ ```
131
+
132
+ ### Building a Storybook
133
+
134
+ ```console
135
+ $ pnpm run build-storybook
136
+ ```
137
+
138
+ ## How to test
139
+
140
+ > [!NOTE]
141
+ > Currently, Relay-related components cannot be tested independently within this project due to their dependency on the Relay environment and GraphQL schema. To test these components, please import them into the main application where the Relay environment is properly configured, and test them there.
142
+
143
+ Components that are not related to Relay can be tested using Storybook.
144
+
145
+ 1. Please write Storybook stories for the components you develop in the `src/components` directory, using the `component-name.stories.tsx` format.
146
+ 2. Please run Storybook and go to [http://localhost:6006](http://localhost:6006).
147
+ ```console
148
+ $ pnpm run storybook
149
+ ```
150
+
151
+ ## Localization
152
+
153
+ We provide locale options for `backend.ai-ui`. Locale files are located in `src/locale`, and you can use them with `BAIConfigProvider` as follows:
154
+
155
+ ```tsx
156
+ import { BAIConfigProvider } from 'backend.ai-ui';
157
+ // select your language
158
+ import en_US from 'backend.ai-ui/dist/locale/en_US';
159
+
160
+ const App = ({ children }) => {
161
+ // please use BAIConfigProvider at the top-level root
162
+ return <BAIConfigProvider locale={en_US}>{children}</BAIConfigProvider>;
163
+ };
164
+ ```
165
+
166
+ ### Adding i18n strings
167
+
168
+ In `backend.ai-ui`, keys are separated and used at the component level. If you want to add a key that will be used in multiple places, please add it to `common`.
169
+
170
+ ```json
171
+ // en.json or {country_code}.json
172
+ {
173
+ "MyComponent": {
174
+ "translatedText": "translatedText"
175
+ }
176
+ }
177
+ ```
178
+
179
+ ### VSCode Extension for i18n
180
+
181
+ To improve the development environment, we are using [i18n-ally](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally). Below are the configurations related to this extension.
182
+
183
+ ```json
184
+ // backend.ai-ui/.vscode/settings.json
185
+ {
186
+ "i18n-ally.localesPaths": ["src/locale"],
187
+ "i18n-ally.enabledFrameworks": ["react"],
188
+ "i18n-ally.keystyle": "nested"
189
+ }
190
+ ```
191
+
192
+ If you want to develop alongside the webui project, please use the `backend.ai-webui.code-workspace` file to take advantage of VSCode’s [Multi-root Workspaces](https://code.visualstudio.com/docs/editing/workspaces/multi-root-workspaces) feature.
@@ -0,0 +1,11 @@
1
+ import { ReaderFragment, FragmentRefs } from 'relay-runtime';
2
+ export type BAISessionTypeTagFragment$data = {
3
+ readonly type: string | null | undefined;
4
+ readonly " $fragmentType": "BAISessionTypeTagFragment";
5
+ };
6
+ export type BAISessionTypeTagFragment$key = {
7
+ readonly " $data"?: BAISessionTypeTagFragment$data;
8
+ readonly " $fragmentSpreads": FragmentRefs<"BAISessionTypeTagFragment">;
9
+ };
10
+ declare const node: ReaderFragment;
11
+ export default node;
@@ -0,0 +1,2 @@
1
+ export * from './index'
2
+ export {}