@linzjs/windows 8.2.1 → 8.3.0

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.
@@ -0,0 +1,65 @@
1
+ import { LuiFileInputBox } from '@linzjs/lui';
2
+ import { LuiFileInputBoxProps } from '@linzjs/lui/dist/components/LuiFormElements/LuiFileInputBox/LuiFileInputBox';
3
+ import clsx from 'clsx';
4
+ import React, { PropsWithChildren, ReactElement, useCallback, useMemo, useState } from 'react';
5
+
6
+ import { LuiModalAsync } from './LuiModalAsync';
7
+ import { LuiModalAsyncCallback, PromiseWithResolve } from './LuiModalAsyncContext';
8
+ import { useShowAsyncModal } from './useShowAsyncModal';
9
+
10
+ export interface useLuiModalUploadProps<RT>
11
+ extends Omit<LuiFileInputBoxProps, 'onValidFileSelected'>,
12
+ LuiModalAsyncCallback<RT> {
13
+ validateFile?: (file: File) => string;
14
+ }
15
+
16
+ /**
17
+ * A generic template for common types of modals.
18
+ */
19
+ export const LuiModalUpload = (props: PropsWithChildren<useLuiModalUploadProps<File>>): ReactElement => {
20
+ const { validateFile, resolve } = props;
21
+ const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);
22
+
23
+ const uploadFile = useCallback(
24
+ (file: File) => {
25
+ const error = validateFile?.(file);
26
+ if (error) {
27
+ setErrorMessage(error);
28
+ } else {
29
+ resolve(file);
30
+ }
31
+ },
32
+ [resolve, validateFile],
33
+ );
34
+
35
+ return (
36
+ <LuiModalAsync className={clsx('LuiModalPrefab', `LuiModalPrefab-file`)} closeOnOverlayClick={true}>
37
+ <LuiFileInputBox
38
+ {...props}
39
+ width={props.width ?? 512}
40
+ showMustSelectFileError={!!errorMessage}
41
+ customFileErrorMessage={errorMessage}
42
+ onValidFileSelected={uploadFile}
43
+ />
44
+ </LuiModalAsync>
45
+ );
46
+ };
47
+
48
+ export const useLuiModalUpload = () => {
49
+ const { showModal, modalOwnerRef } = useShowAsyncModal();
50
+
51
+ const showUploadModal = useCallback(
52
+ (props: Omit<LuiFileInputBoxProps, 'onValidFileSelected'>): PromiseWithResolve<File> => {
53
+ return showModal(LuiModalUpload, props) as PromiseWithResolve<File>;
54
+ },
55
+ [showModal],
56
+ );
57
+
58
+ return useMemo(
59
+ () => ({
60
+ modalOwnerRef,
61
+ showUploadModal,
62
+ }),
63
+ [modalOwnerRef, showUploadModal],
64
+ );
65
+ };
package/package.json CHANGED
@@ -13,9 +13,9 @@
13
13
  "popout"
14
14
  ],
15
15
  "main": "./dist/index.ts",
16
- "version": "8.2.1",
16
+ "version": "8.3.0",
17
17
  "peerDependencies": {
18
- "@linzjs/lui": ">=21",
18
+ "@linzjs/lui": ">=23",
19
19
  "lodash-es": ">=4",
20
20
  "react": ">=18",
21
21
  "react-dom": ">=18"
@@ -31,21 +31,20 @@
31
31
  "node": ">=22"
32
32
  },
33
33
  "scripts": {
34
- "build": "run-s clean stylelint lint lint-circular-deps bundle",
34
+ "build": "run-s clean lintall bundle",
35
35
  "yalc": "run-s clean bundle && yalc push",
36
36
  "clean": "rimraf dist && mkdirp ./dist",
37
37
  "bundle": "tsc --noEmit && rollup -c",
38
38
  "test": "vitest run",
39
39
  "test:watch": "vitest --watch",
40
- "stylelint": "stylelint src/**/*.scss src/**/*.css --fix",
41
- "lint": "eslint ./src --ext .js,.ts,.tsx --cache --ignore-path .gitignore",
40
+ "lintall": "run-s lint:style lint:eslint lint:circular-deps",
41
+ "lint:style": "stylelint src/**/*.scss src/**/*.css --fix",
42
+ "lint:eslint": "eslint ./src --ext .js,.ts,.tsx --cache --ignore-path .gitignore",
42
43
  "lint:fix": "eslint ./src --ext .js,.ts,.tsx --fix --cache --ignore-path .gitignore",
43
- "lint-circular-deps": "npx madge --circular --extensions ts,tsx ./",
44
+ "lint:circular-deps": "npx madge --circular --extensions ts,tsx ./",
44
45
  "storybook": "storybook dev -p 6006",
45
46
  "build-storybook": "storybook build",
46
- "deploy-storybook": "npx --yes -p @storybook/storybook-deployer storybook-to-ghpages",
47
47
  "chromatic": "chromatic --exit-zero-on-changes",
48
- "semantic-release": "semantic-release",
49
48
  "upgrade": "npx ncu -i --format group"
50
49
  },
51
50
  "dependencies": {
@@ -53,15 +52,17 @@
53
52
  "@emotion/react": "^11.14.0",
54
53
  "@emotion/styled": "11.14.1",
55
54
  "@types/uuid": "^11.0.0",
55
+ "ag-grid-community": "34.2.0",
56
+ "ag-grid-react": "34.2.0",
56
57
  "lodash-es": ">=4",
57
58
  "react-rnd": "^10.5.2",
58
59
  "usehooks-ts": "^3.1.1",
59
60
  "uuid": "^13.0.0"
60
61
  },
61
62
  "devDependencies": {
62
- "@chromatic-com/storybook": "^4.1.2",
63
- "@linzjs/lui": "^23.14.4",
64
- "@linzjs/step-ag-grid": "^29.5.1",
63
+ "@chromatic-com/storybook": "^4.1.3",
64
+ "@linzjs/lui": "^24.3.1",
65
+ "@linzjs/step-ag-grid": "^29.14.1",
65
66
  "@linzjs/style": "^5.4.0",
66
67
  "@rollup/plugin-commonjs": "^28.0.9",
67
68
  "@rollup/plugin-json": "^6.1.0",
@@ -73,43 +74,40 @@
73
74
  "@testing-library/react": "^16.3.0",
74
75
  "@testing-library/user-event": "^14.6.1",
75
76
  "@types/lodash-es": "^4.17.12",
76
- "@types/node": "^22.18.12",
77
- "@types/react": "^19.2.2",
78
- "@types/react-dom": "^19.2.2",
79
- "@vitejs/plugin-react-swc": "^4.2.0",
80
- "@vitest/ui": "^4.0.5",
81
- "ag-grid-community": "^34.3.1",
82
- "ag-grid-react": "^34.3.1",
77
+ "@types/node": "^22.19.2",
78
+ "@types/react": "^19.2.7",
79
+ "@types/react-dom": "^19.2.3",
80
+ "@vitejs/plugin-react-swc": "^4.2.2",
81
+ "@vitest/ui": "^4.0.15",
83
82
  "eslint-plugin-react": "^7.37.5",
84
83
  "eslint-plugin-storybook": "^9.1.16",
85
- "jsdom": "^27.0.1",
84
+ "jsdom": "^27.3.0",
86
85
  "mkdirp": "^3.0.1",
87
86
  "npm-run-all": "^4.1.5",
88
87
  "react": "18.3.1",
89
88
  "react-app-polyfill": "^3.0.0",
90
89
  "react-dom": "18.3.1",
91
- "rollup": "^4.52.5",
90
+ "rollup": "^4.53.3",
92
91
  "rollup-plugin-copy": "^3.5.0",
93
- "sass": "^1.93.2",
92
+ "sass": "^1.96.0",
94
93
  "sass-loader": "^16.0.6",
95
- "semantic-release": "^24.2.9",
96
94
  "storybook": "^9.1.16",
97
95
  "style-loader": "^4.0.0",
98
- "stylelint": "^16.25.0",
96
+ "stylelint": "^16.26.1",
99
97
  "stylelint-config-recommended": "^17.0.0",
100
98
  "stylelint-config-recommended-scss": "^16.0.2",
101
99
  "stylelint-config-standard": "^39.0.1",
102
100
  "stylelint-prettier": "5.0.3",
103
- "stylelint-scss": "6.12.1",
101
+ "stylelint-scss": "6.13.0",
104
102
  "typescript": "^5.9.3",
105
- "vite": "^7.1.12",
103
+ "vite": "^7.2.7",
106
104
  "vite-plugin-html": "^3.2.2",
107
105
  "vite-tsconfig-paths": "^5.1.4",
108
- "vitest": "^4.0.5"
106
+ "vitest": "^4.0.15"
109
107
  },
110
108
  "optionalDependencies": {
111
- "@rollup/rollup-linux-x64-gnu": "^4.52.5",
112
- "@swc/core-linux-x64-gnu": "^1.14.0"
109
+ "@rollup/rollup-linux-x64-gnu": "^4.53.3",
110
+ "@swc/core-linux-x64-gnu": "^1.15.3"
113
111
  },
114
112
  "browserslist": {
115
113
  "production": [