ranui 0.1.4-alpha.7 → 0.1.6
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.
- package/dist/components/button/index.d.ts +1 -331
- package/dist/components/button/index.js +2 -2
- package/dist/components/input/index.d.ts +1 -435
- package/dist/components/input/index.js +2 -2
- package/dist/components/preview/colz.d.ts +1 -1
- package/dist/components/preview/index.js +2 -2
- package/dist/components/preview/pptx/process_pptx.d.ts +1 -1
- package/dist/components/radar/index.d.ts +2 -0
- package/dist/components/radar/index.js +5 -0
- package/dist/components/tab/index.d.ts +47 -27
- package/dist/components/tab/index.js +2 -2
- package/dist/components/tabpane/index.d.ts +47 -27
- package/dist/components/video/index.d.ts +56 -36
- package/dist/{index-ac3f8c4f.js → index-07c8e518.js} +5 -2
- package/dist/{index-c61cbf56.js → index-4459fbd0.js} +34 -0
- package/dist/{index-03e90266.js → index-57d3be68.js} +17 -22
- package/dist/index-64d03ac1.js +18693 -0
- package/dist/{index-714a1eb8.js → index-a55c2dff.js} +1 -0
- package/dist/{index-db03e134.js → index-a7db1b7b.js} +7 -9
- package/dist/index-b99ac79f.js +353 -0
- package/dist/{index-9861f093.js → index-c558bde2.js} +8 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -5
- package/dist/{pdf-bd9a47ff.js → pdf-6e38f826.js} +1 -1
- package/dist/playwright.config.d.ts +1 -1
- package/dist/plugins/auto-import-file.d.ts +0 -10
- package/dist/umd/components/button/index.d.ts +1 -331
- package/dist/umd/components/input/index.d.ts +1 -435
- package/dist/umd/components/preview/colz.d.ts +1 -1
- package/dist/umd/components/preview/pptx/process_pptx.d.ts +1 -1
- package/dist/umd/components/radar/index.d.ts +2 -0
- package/dist/umd/components/tab/index.d.ts +47 -27
- package/dist/umd/components/tabpane/index.d.ts +47 -27
- package/dist/umd/components/video/index.d.ts +56 -36
- package/dist/umd/index.d.ts +1 -0
- package/dist/umd/index.umd.cjs +6 -6
- package/dist/umd/playwright.config.d.ts +1 -1
- package/dist/umd/plugins/auto-import-file.d.ts +0 -10
- package/dist/umd/utils/index.d.ts +18 -0
- package/dist/utils/index.d.ts +18 -0
- package/package.json +17 -2
- package/readme.md +80 -51
- package/dist/index-1ffff466.js +0 -23077
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
interface Options {
|
|
3
|
-
ignore?: Array<string>;
|
|
4
|
-
path: Array<string>;
|
|
5
|
-
extensions: Array<string>;
|
|
6
|
-
defaultImport?: string;
|
|
7
|
-
output?: string;
|
|
8
|
-
}
|
|
9
|
-
export default function autoImportFilePlugin(options: Options): Plugin;
|
|
10
|
-
export {};
|
|
@@ -34,4 +34,22 @@ interface Url2FileOption {
|
|
|
34
34
|
body: string;
|
|
35
35
|
}
|
|
36
36
|
export declare const requestFile: (url: string, options?: Partial<Url2FileOption>) => Promise<File>;
|
|
37
|
+
interface Context {
|
|
38
|
+
backingStorePixelRatio: number;
|
|
39
|
+
webkitBackingStorePixelRatio: number;
|
|
40
|
+
mozBackingStorePixelRatio: number;
|
|
41
|
+
msBackingStorePixelRatio: number;
|
|
42
|
+
oBackingStorePixelRatio: number;
|
|
43
|
+
}
|
|
44
|
+
export declare const getPixelRatio: (context: CanvasRenderingContext2D & Partial<Context>) => number;
|
|
45
|
+
export interface CustomErrorType {
|
|
46
|
+
new (m: string): void;
|
|
47
|
+
}
|
|
48
|
+
export declare function createCustomError(msg: string): CustomErrorType;
|
|
49
|
+
/**
|
|
50
|
+
* @description: 判断当前设备
|
|
51
|
+
* @param {*} function
|
|
52
|
+
* @return {*}
|
|
53
|
+
*/
|
|
54
|
+
export declare const presentDevice: string;
|
|
37
55
|
export {};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -34,4 +34,22 @@ interface Url2FileOption {
|
|
|
34
34
|
body: string;
|
|
35
35
|
}
|
|
36
36
|
export declare const requestFile: (url: string, options?: Partial<Url2FileOption>) => Promise<File>;
|
|
37
|
+
interface Context {
|
|
38
|
+
backingStorePixelRatio: number;
|
|
39
|
+
webkitBackingStorePixelRatio: number;
|
|
40
|
+
mozBackingStorePixelRatio: number;
|
|
41
|
+
msBackingStorePixelRatio: number;
|
|
42
|
+
oBackingStorePixelRatio: number;
|
|
43
|
+
}
|
|
44
|
+
export declare const getPixelRatio: (context: CanvasRenderingContext2D & Partial<Context>) => number;
|
|
45
|
+
export interface CustomErrorType {
|
|
46
|
+
new (m: string): void;
|
|
47
|
+
}
|
|
48
|
+
export declare function createCustomError(msg: string): CustomErrorType;
|
|
49
|
+
/**
|
|
50
|
+
* @description: 判断当前设备
|
|
51
|
+
* @param {*} function
|
|
52
|
+
* @return {*}
|
|
53
|
+
*/
|
|
54
|
+
export declare const presentDevice: string;
|
|
37
55
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "UI Component library based on `Web Component`",
|
|
5
5
|
"main": "dist/umd/index.umd.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -24,7 +24,12 @@
|
|
|
24
24
|
"component",
|
|
25
25
|
"components",
|
|
26
26
|
"ui",
|
|
27
|
-
"design"
|
|
27
|
+
"design",
|
|
28
|
+
"web-components",
|
|
29
|
+
"web components",
|
|
30
|
+
"webComponents",
|
|
31
|
+
"ranui",
|
|
32
|
+
"@ranui/react"
|
|
28
33
|
],
|
|
29
34
|
"exports": {
|
|
30
35
|
".": {
|
|
@@ -72,6 +77,16 @@
|
|
|
72
77
|
"import": "./dist/components/tab/index.js",
|
|
73
78
|
"require": "./dist/umd/index.umd.cjs"
|
|
74
79
|
},
|
|
80
|
+
"./tabpane": {
|
|
81
|
+
"types": "./dist/components/tabpane/index.d.ts",
|
|
82
|
+
"import": "./dist/components/tabpane/index.js",
|
|
83
|
+
"require": "./dist/umd/index.umd.cjs"
|
|
84
|
+
},
|
|
85
|
+
"./radar": {
|
|
86
|
+
"types": "./dist/components/radar/index.d.ts",
|
|
87
|
+
"import": "./dist/components/radar/index.js",
|
|
88
|
+
"require": "./dist/umd/index.umd.cjs"
|
|
89
|
+
},
|
|
75
90
|
"./style": {
|
|
76
91
|
"types": "./dist/index.d.ts",
|
|
77
92
|
"import": "./dist/style.css",
|
package/readme.md
CHANGED
|
@@ -28,19 +28,20 @@ npm install ranui --save
|
|
|
28
28
|
|
|
29
29
|
[See components and use examples](https://chaxus.github.io/ran/src/ranui/)
|
|
30
30
|
|
|
31
|
-
## Import
|
|
31
|
+
## Import
|
|
32
32
|
|
|
33
33
|
Support for on-demand import, which can reduce the size of loaded js
|
|
34
34
|
|
|
35
35
|
```js
|
|
36
|
-
import 'ranui/button'
|
|
36
|
+
import 'ranui/button';
|
|
37
37
|
```
|
|
38
|
-
|
|
38
|
+
- `style`
|
|
39
|
+
|
|
39
40
|
For global components like `preview` and `message`, you need to import global styles
|
|
40
41
|
|
|
41
42
|
```js
|
|
42
|
-
import 'ranui/preview'
|
|
43
|
-
import 'ranui/style'
|
|
43
|
+
import 'ranui/preview';
|
|
44
|
+
import 'ranui/style';
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
Support global import
|
|
@@ -48,7 +49,7 @@ Support global import
|
|
|
48
49
|
- ES module
|
|
49
50
|
|
|
50
51
|
```js
|
|
51
|
-
import 'ranui'
|
|
52
|
+
import 'ranui';
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
- UMD, IIFE, CJS
|
|
@@ -84,102 +85,130 @@ Here are some examples:
|
|
|
84
85
|
### js
|
|
85
86
|
|
|
86
87
|
```js
|
|
87
|
-
import 'ranui'
|
|
88
|
+
import 'ranui';
|
|
88
89
|
|
|
89
|
-
const Button = document.createElement('r-button')
|
|
90
|
-
Button.appendChild('this is button text')
|
|
91
|
-
document.body.appendChild(Button)
|
|
90
|
+
const Button = document.createElement('r-button');
|
|
91
|
+
Button.appendChild('this is button text');
|
|
92
|
+
document.body.appendChild(Button);
|
|
92
93
|
```
|
|
93
94
|
|
|
94
95
|
### jsx
|
|
95
96
|
|
|
97
|
+
Since `react` has composite events, for more convenient use, `ranui` is encapsulated through `react` high-level components to form [@ranui/react](https://www.npmjs.com/package/@ranui/react).
|
|
98
|
+
|
|
99
|
+
In react, it is recommended to use [@ranui/react](https://www.npmjs.com/package/@ranui/react).
|
|
100
|
+
|
|
101
|
+
However, `ranui` can still be used in any `js` or `ts` framework.
|
|
102
|
+
|
|
96
103
|
```jsx
|
|
97
|
-
import 'ranui'
|
|
104
|
+
import 'ranui';
|
|
105
|
+
|
|
98
106
|
const App = () => {
|
|
99
107
|
return (
|
|
100
108
|
<>
|
|
101
109
|
<r-button>Button</r-button>
|
|
102
110
|
</>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
105
113
|
```
|
|
106
114
|
|
|
107
|
-
### vue
|
|
115
|
+
### vue
|
|
108
116
|
|
|
109
117
|
```vue
|
|
110
118
|
<template>
|
|
111
119
|
<r-button></r-button>
|
|
112
120
|
</template>
|
|
113
121
|
<script>
|
|
114
|
-
|
|
122
|
+
import 'ranui';
|
|
115
123
|
</script>
|
|
116
|
-
|
|
117
124
|
```
|
|
118
125
|
|
|
119
126
|
### tsx
|
|
120
127
|
|
|
128
|
+
Since `react` has composite events, for more convenient use, [ranui](https://www.npmjs.com/package/ranui) is encapsulated through `react` high-level components, so there is [@ranui/react](https://www.npmjs.com/package/@ranui/react).
|
|
129
|
+
|
|
130
|
+
In `react`, using [@ranui/react](https://www.npmjs.com/package/@ranui/react) is silky and fully integrated into the `react` ecosystem after being wrapped in higher-order functions.
|
|
131
|
+
|
|
132
|
+
However, [ranui](https://www.npmjs.com/package/ranui) can still be used in any `js` or `ts`.
|
|
133
|
+
|
|
121
134
|
```tsx
|
|
122
|
-
// react 18
|
|
135
|
+
// react 18
|
|
123
136
|
import type { SyntheticEvent } from 'react';
|
|
124
|
-
import React, { useRef } from 'react'
|
|
125
|
-
import 'ranui'
|
|
137
|
+
import React, { useRef } from 'react';
|
|
138
|
+
import 'ranui';
|
|
126
139
|
|
|
127
140
|
const FilePreview = () => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
}
|
|
141
|
+
const ref = useRef<HTMLDivElement | null>(null);
|
|
142
|
+
const uploadFile = (e: SyntheticEvent<HTMLDivElement>) => {
|
|
143
|
+
if (ref.current) {
|
|
144
|
+
const uploadFile = document.createElement('input');
|
|
145
|
+
uploadFile.setAttribute('type', 'file');
|
|
146
|
+
uploadFile.click();
|
|
147
|
+
uploadFile.onchange = (e) => {
|
|
148
|
+
const { files = [] } = uploadFile;
|
|
149
|
+
if (files && files?.length > 0 && ref.current) {
|
|
150
|
+
ref.current.setAttribute('src', '');
|
|
151
|
+
const file = files[0];
|
|
152
|
+
const url = URL.createObjectURL(file);
|
|
153
|
+
ref.current.setAttribute('src', url);
|
|
143
154
|
}
|
|
155
|
+
};
|
|
144
156
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
};
|
|
158
|
+
return (
|
|
159
|
+
<div>
|
|
160
|
+
<r-preview ref={ref}></r-preview>
|
|
161
|
+
<r-button type="primary" onClick={uploadFile}>
|
|
162
|
+
choose file to preview
|
|
163
|
+
</r-button>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
152
167
|
```
|
|
153
168
|
|
|
154
|
-
`jsx` defines the types of all `HTML-native` components in `TypeScript`.
|
|
169
|
+
`jsx` defines the types of all `HTML-native` components in `TypeScript`.
|
|
155
170
|
|
|
156
|
-
The `web component` type is not in the `jsx` definition.
|
|
171
|
+
The `web component` type is not in the `jsx` definition.
|
|
157
172
|
|
|
158
|
-
You need to add it manually.
|
|
173
|
+
You need to add it manually.
|
|
159
174
|
|
|
160
175
|
Otherwise you'll have type problems, but it actually works.
|
|
161
176
|
|
|
162
177
|
```ts
|
|
163
178
|
// typings.d.ts
|
|
164
179
|
interface RButton {
|
|
165
|
-
type?: string
|
|
166
|
-
onClick?: React.MouseEventHandler<HTMLDivElement> | undefined
|
|
180
|
+
type?: string;
|
|
181
|
+
onClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
|
|
167
182
|
}
|
|
168
183
|
|
|
169
184
|
interface RPreview {
|
|
170
|
-
src?: string | Blob | ArrayBuffer
|
|
171
|
-
onClick?: React.MouseEventHandler<HTMLDivElement> | undefined
|
|
172
|
-
ref?: React.MutableRefObject<HTMLDivElement | null
|
|
185
|
+
src?: string | Blob | ArrayBuffer;
|
|
186
|
+
onClick?: React.MouseEventHandler<HTMLDivElement> | undefined;
|
|
187
|
+
ref?: React.MutableRefObject<HTMLDivElement | null>;
|
|
173
188
|
}
|
|
174
189
|
|
|
175
190
|
declare namespace JSX {
|
|
176
191
|
interface IntrinsicElements {
|
|
177
|
-
'r-preview': React.DetailedHTMLProps<
|
|
178
|
-
|
|
192
|
+
'r-preview': React.DetailedHTMLProps<
|
|
193
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
194
|
+
HTMLDivElement
|
|
195
|
+
> &
|
|
196
|
+
RPreview;
|
|
197
|
+
'r-button': React.DetailedHTMLProps<
|
|
198
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
199
|
+
HTMLDivElement
|
|
200
|
+
> &
|
|
201
|
+
RButton;
|
|
179
202
|
}
|
|
180
203
|
}
|
|
181
204
|
```
|
|
182
205
|
|
|
206
|
+
## Contributors
|
|
207
|
+
|
|
208
|
+
<a href="https://github.com/chaxus/ran/graphs/contributors">
|
|
209
|
+
<img src="https://contrib.rocks/image?repo=chaxus/ran" />
|
|
210
|
+
</a>
|
|
211
|
+
|
|
183
212
|
## Meta
|
|
184
213
|
|
|
185
214
|
[LICENSE (MIT)](/LICENSE)
|