@react95/core 9.1.0 → 9.2.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.
@@ -1,4 +1,3 @@
1
1
  require('./GlobalStyle.css.ts.vanilla.css');
2
2
  "use strict";
3
- require("../themes/contract.css.ts.vanilla.css.cjs");
4
3
  /* empty css */
@@ -13,6 +13,25 @@ const events = require("../shared/events.cjs");
13
13
  const ModalContent = Frame.fixedForwardRef(
14
14
  (rest, ref) => /* @__PURE__ */ React.createElement(Frame.Frame, { ...rest, ref, className: cn(Modal_css.content, rest.className) })
15
15
  );
16
+ const ModalMinimize = Frame.fixedForwardRef(
17
+ (props, ref) => {
18
+ const [id, setId] = React.useState("");
19
+ React.useEffect(() => {
20
+ const handleVisibilityChange = ({ id: activeId }) => {
21
+ setId(activeId);
22
+ };
23
+ events.modals.on(events.ModalEvents.ModalVisibilityChanged, handleVisibilityChange);
24
+ return () => {
25
+ events.modals.off(events.ModalEvents.ModalVisibilityChanged, handleVisibilityChange);
26
+ };
27
+ }, []);
28
+ const handleMinimize = () => {
29
+ events.modals.emit(events.ModalEvents.MinimizeModal, { id });
30
+ events.modals.emit(events.ModalEvents.ModalVisibilityChanged, { id: "no id" });
31
+ };
32
+ return /* @__PURE__ */ React.createElement(TitleBar.TitleBar.Minimize, { ...props, ref, onClick: handleMinimize });
33
+ }
34
+ );
16
35
  const ModalRenderer = ({
17
36
  hasWindowButton: hasButton = true,
18
37
  buttons = [],
@@ -29,6 +48,7 @@ const ModalRenderer = ({
29
48
  const [id] = React.useState(nanoid.nanoid());
30
49
  const [menuOpened, setMenuOpened] = React.useState("");
31
50
  const [isActive, setIsActive] = React.useState(false);
51
+ const [isModalMinimized, setIsModalMinimized] = React.useState(false);
32
52
  const draggableRef = React.useRef(null);
33
53
  react.useDraggable(draggableRef, {
34
54
  ...dragOptions,
@@ -53,6 +73,24 @@ const ModalRenderer = ({
53
73
  events.modals.emit(events.ModalEvents.RemoveModal, { id });
54
74
  };
55
75
  }, []);
76
+ React.useEffect(() => {
77
+ events.modals.on(events.ModalEvents.MinimizeModal, ({ id: activeId }) => {
78
+ if (activeId === id) {
79
+ setIsModalMinimized(true);
80
+ }
81
+ });
82
+ events.modals.on(events.ModalEvents.RestoreModal, ({ id: activeId }) => {
83
+ if (activeId === id) {
84
+ setIsModalMinimized(false);
85
+ }
86
+ });
87
+ return () => {
88
+ events.modals.off(events.ModalEvents.MinimizeModal, () => {
89
+ });
90
+ events.modals.off(events.ModalEvents.RestoreModal, () => {
91
+ });
92
+ };
93
+ }, [id]);
56
94
  React.useImperativeHandle(ref, () => {
57
95
  return draggableRef.current;
58
96
  });
@@ -60,7 +98,12 @@ const ModalRenderer = ({
60
98
  Frame.Frame,
61
99
  {
62
100
  ...rest,
63
- className: cn(Modal_css.modalWrapper({ active: isActive }), className),
101
+ className: cn(
102
+ Modal_css.modalWrapper({ active: isActive, minimized: isModalMinimized }),
103
+ className
104
+ ),
105
+ role: "dialog",
106
+ "aria-hidden": isModalMinimized,
64
107
  ref: draggableRef,
65
108
  onMouseDown: () => {
66
109
  events.modals.emit(events.ModalEvents.ModalVisibilityChanged, { id });
@@ -111,7 +154,8 @@ const ModalRenderer = ({
111
154
  const Modal = Object.assign(
112
155
  Frame.fixedForwardRef(ModalRenderer),
113
156
  {
114
- Content: ModalContent
157
+ Content: ModalContent,
158
+ Minimize: ModalMinimize
115
159
  }
116
160
  );
117
161
  exports.Modal = Modal;
@@ -2,11 +2,11 @@ require('./Modal.css.ts.vanilla.css');
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  /* empty css */const createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
5
- var modalWrapper = createRuntimeFn.createRuntimeFn({ defaultClassName: "r95_1txblt60", variantClassNames: { active: { true: "r95_1txblt61" } }, defaultVariants: {}, compoundVariants: [] });
6
- var buttonWrapper = "r95_1txblt62";
7
- var content = "r95_1txblt63";
8
- var menuWrapper = "r95_1txblt64";
9
- var menuItem = createRuntimeFn.createRuntimeFn({ defaultClassName: "r95_1txblt65", variantClassNames: { active: { true: "r95_1txblt66" } }, defaultVariants: {}, compoundVariants: [] });
5
+ var modalWrapper = createRuntimeFn.createRuntimeFn({ defaultClassName: "r95_1txblt60", variantClassNames: { active: { true: "r95_1txblt61" }, minimized: { true: "r95_1txblt62", false: "r95_1txblt63" } }, defaultVariants: {}, compoundVariants: [] });
6
+ var buttonWrapper = "r95_1txblt64";
7
+ var content = "r95_1txblt65";
8
+ var menuWrapper = "r95_1txblt66";
9
+ var menuItem = createRuntimeFn.createRuntimeFn({ defaultClassName: "r95_1txblt67", variantClassNames: { active: { true: "r95_1txblt68" } }, defaultVariants: {}, compoundVariants: [] });
10
10
  exports.buttonWrapper = buttonWrapper;
11
11
  exports.content = content;
12
12
  exports.menuItem = menuItem;
@@ -11,15 +11,21 @@
11
11
  z-index: var(--r95-zIndex-modal);
12
12
  }
13
13
  .r95_1txblt62 {
14
+ display: none;
15
+ }
16
+ .r95_1txblt63 {
17
+ display: flex;
18
+ }
19
+ .r95_1txblt64 {
14
20
  display: flex;
15
21
  gap: var(--r95-space-6);
16
22
  flex-direction: row;
17
23
  padding: var(--r95-space-6);
18
24
  }
19
- .r95_1txblt62 button {
25
+ .r95_1txblt64 button {
20
26
  min-width: 70px;
21
27
  }
22
- .r95_1txblt63 {
28
+ .r95_1txblt65 {
23
29
  flex-grow: 1;
24
30
  display: flex;
25
31
  flex-direction: column;
@@ -27,7 +33,7 @@
27
33
  margin-block-start: var(--r95-space-4);
28
34
  margin-inline-end: var(--r95-space-1);
29
35
  }
30
- .r95_1txblt64 {
36
+ .r95_1txblt66 {
31
37
  display: flex;
32
38
  flex-direction: row;
33
39
  list-style: none;
@@ -40,17 +46,17 @@
40
46
  border-bottom-color: var(--r95-color-borderDark);
41
47
  box-shadow: 0 1px 0 0 var(--r95-color-borderLighter);
42
48
  }
43
- .r95_1txblt65 {
49
+ .r95_1txblt67 {
44
50
  position: relative;
45
51
  padding-left: 6px;
46
52
  padding-right: 6px;
47
53
  user-select: none;
48
54
  }
49
- .r95_1txblt66 {
55
+ .r95_1txblt68 {
50
56
  background-color: var(--r95-color-material);
51
57
  color: var(--r95-color-materialTextInvert);
52
58
  }
53
- .r95_1txblt65 ul {
59
+ .r95_1txblt67 ul {
54
60
  position: absolute;
55
61
  left: 0;
56
62
  color: var(--r95-color-materialText);
@@ -93,7 +93,13 @@ const TaskBar = React.forwardRef(
93
93
  icon,
94
94
  active: id === activeWindow,
95
95
  onClick: () => {
96
- events.modals.emit(events.ModalEvents.ModalVisibilityChanged, { id });
96
+ if (id === activeWindow) {
97
+ events.modals.emit(events.ModalEvents.MinimizeModal, { id });
98
+ setActiveWindow("Minimize");
99
+ } else {
100
+ events.modals.emit(events.ModalEvents.RestoreModal, { id });
101
+ events.modals.emit(events.ModalEvents.ModalVisibilityChanged, { id });
102
+ }
97
103
  },
98
104
  small: false
99
105
  },
@@ -27,6 +27,8 @@ var ModalEvents = /* @__PURE__ */ ((ModalEvents2) => {
27
27
  ModalEvents2["AddModal"] = "add-modal";
28
28
  ModalEvents2["RemoveModal"] = "remove-modal";
29
29
  ModalEvents2["ModalVisibilityChanged"] = "modal-visibility-changed";
30
+ ModalEvents2["MinimizeModal"] = "minimize-modal";
31
+ ModalEvents2["RestoreModal"] = "restore-modal";
30
32
  return ModalEvents2;
31
33
  })(ModalEvents || {});
32
34
  const modals = new Emitter();
@@ -1,3 +1,4 @@
1
1
  require('./azureOrange.css.ts.vanilla.css');
2
2
  "use strict";
3
+ require("./contract.css.ts.vanilla.css.cjs");
3
4
  /* empty css */
@@ -1,3 +1,2 @@
1
1
  import './GlobalStyle.css.ts.vanilla.css';
2
- import "../themes/contract.css.ts.vanilla.css.mjs";
3
2
  /* empty css */
@@ -1,10 +1,10 @@
1
1
  import './Modal.css.ts.vanilla.css';
2
2
  /* empty css */import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
3
- var modalWrapper = createRuntimeFn({ defaultClassName: "r95_1txblt60", variantClassNames: { active: { true: "r95_1txblt61" } }, defaultVariants: {}, compoundVariants: [] });
4
- var buttonWrapper = "r95_1txblt62";
5
- var content = "r95_1txblt63";
6
- var menuWrapper = "r95_1txblt64";
7
- var menuItem = createRuntimeFn({ defaultClassName: "r95_1txblt65", variantClassNames: { active: { true: "r95_1txblt66" } }, defaultVariants: {}, compoundVariants: [] });
3
+ var modalWrapper = createRuntimeFn({ defaultClassName: "r95_1txblt60", variantClassNames: { active: { true: "r95_1txblt61" }, minimized: { true: "r95_1txblt62", false: "r95_1txblt63" } }, defaultVariants: {}, compoundVariants: [] });
4
+ var buttonWrapper = "r95_1txblt64";
5
+ var content = "r95_1txblt65";
6
+ var menuWrapper = "r95_1txblt66";
7
+ var menuItem = createRuntimeFn({ defaultClassName: "r95_1txblt67", variantClassNames: { active: { true: "r95_1txblt68" } }, defaultVariants: {}, compoundVariants: [] });
8
8
  export {
9
9
  buttonWrapper,
10
10
  content,
@@ -11,15 +11,21 @@
11
11
  z-index: var(--r95-zIndex-modal);
12
12
  }
13
13
  .r95_1txblt62 {
14
+ display: none;
15
+ }
16
+ .r95_1txblt63 {
17
+ display: flex;
18
+ }
19
+ .r95_1txblt64 {
14
20
  display: flex;
15
21
  gap: var(--r95-space-6);
16
22
  flex-direction: row;
17
23
  padding: var(--r95-space-6);
18
24
  }
19
- .r95_1txblt62 button {
25
+ .r95_1txblt64 button {
20
26
  min-width: 70px;
21
27
  }
22
- .r95_1txblt63 {
28
+ .r95_1txblt65 {
23
29
  flex-grow: 1;
24
30
  display: flex;
25
31
  flex-direction: column;
@@ -27,7 +33,7 @@
27
33
  margin-block-start: var(--r95-space-4);
28
34
  margin-inline-end: var(--r95-space-1);
29
35
  }
30
- .r95_1txblt64 {
36
+ .r95_1txblt66 {
31
37
  display: flex;
32
38
  flex-direction: row;
33
39
  list-style: none;
@@ -40,17 +46,17 @@
40
46
  border-bottom-color: var(--r95-color-borderDark);
41
47
  box-shadow: 0 1px 0 0 var(--r95-color-borderLighter);
42
48
  }
43
- .r95_1txblt65 {
49
+ .r95_1txblt67 {
44
50
  position: relative;
45
51
  padding-left: 6px;
46
52
  padding-right: 6px;
47
53
  user-select: none;
48
54
  }
49
- .r95_1txblt66 {
55
+ .r95_1txblt68 {
50
56
  background-color: var(--r95-color-material);
51
57
  color: var(--r95-color-materialTextInvert);
52
58
  }
53
- .r95_1txblt65 ul {
59
+ .r95_1txblt67 ul {
54
60
  position: absolute;
55
61
  left: 0;
56
62
  color: var(--r95-color-materialText);
@@ -1,5 +1,5 @@
1
1
  import { nanoid } from "nanoid";
2
- import React, { useState, useRef, useEffect, useImperativeHandle } from "react";
2
+ import React, { useState, useEffect, useRef, useImperativeHandle } from "react";
3
3
  import { useDraggable } from "@neodrag/react";
4
4
  import { Button } from "../Button/Button.mjs";
5
5
  import { fixedForwardRef, Frame } from "../Frame/Frame.mjs";
@@ -11,6 +11,25 @@ import { modals, ModalEvents } from "../shared/events.mjs";
11
11
  const ModalContent = fixedForwardRef(
12
12
  (rest, ref) => /* @__PURE__ */ React.createElement(Frame, { ...rest, ref, className: cn(content, rest.className) })
13
13
  );
14
+ const ModalMinimize = fixedForwardRef(
15
+ (props, ref) => {
16
+ const [id, setId] = useState("");
17
+ useEffect(() => {
18
+ const handleVisibilityChange = ({ id: activeId }) => {
19
+ setId(activeId);
20
+ };
21
+ modals.on(ModalEvents.ModalVisibilityChanged, handleVisibilityChange);
22
+ return () => {
23
+ modals.off(ModalEvents.ModalVisibilityChanged, handleVisibilityChange);
24
+ };
25
+ }, []);
26
+ const handleMinimize = () => {
27
+ modals.emit(ModalEvents.MinimizeModal, { id });
28
+ modals.emit(ModalEvents.ModalVisibilityChanged, { id: "no id" });
29
+ };
30
+ return /* @__PURE__ */ React.createElement(TitleBar.Minimize, { ...props, ref, onClick: handleMinimize });
31
+ }
32
+ );
14
33
  const ModalRenderer = ({
15
34
  hasWindowButton: hasButton = true,
16
35
  buttons = [],
@@ -27,6 +46,7 @@ const ModalRenderer = ({
27
46
  const [id] = useState(nanoid());
28
47
  const [menuOpened, setMenuOpened] = useState("");
29
48
  const [isActive, setIsActive] = useState(false);
49
+ const [isModalMinimized, setIsModalMinimized] = useState(false);
30
50
  const draggableRef = useRef(null);
31
51
  useDraggable(draggableRef, {
32
52
  ...dragOptions,
@@ -51,6 +71,24 @@ const ModalRenderer = ({
51
71
  modals.emit(ModalEvents.RemoveModal, { id });
52
72
  };
53
73
  }, []);
74
+ useEffect(() => {
75
+ modals.on(ModalEvents.MinimizeModal, ({ id: activeId }) => {
76
+ if (activeId === id) {
77
+ setIsModalMinimized(true);
78
+ }
79
+ });
80
+ modals.on(ModalEvents.RestoreModal, ({ id: activeId }) => {
81
+ if (activeId === id) {
82
+ setIsModalMinimized(false);
83
+ }
84
+ });
85
+ return () => {
86
+ modals.off(ModalEvents.MinimizeModal, () => {
87
+ });
88
+ modals.off(ModalEvents.RestoreModal, () => {
89
+ });
90
+ };
91
+ }, [id]);
54
92
  useImperativeHandle(ref, () => {
55
93
  return draggableRef.current;
56
94
  });
@@ -58,7 +96,12 @@ const ModalRenderer = ({
58
96
  Frame,
59
97
  {
60
98
  ...rest,
61
- className: cn(modalWrapper({ active: isActive }), className),
99
+ className: cn(
100
+ modalWrapper({ active: isActive, minimized: isModalMinimized }),
101
+ className
102
+ ),
103
+ role: "dialog",
104
+ "aria-hidden": isModalMinimized,
62
105
  ref: draggableRef,
63
106
  onMouseDown: () => {
64
107
  modals.emit(ModalEvents.ModalVisibilityChanged, { id });
@@ -109,7 +152,8 @@ const ModalRenderer = ({
109
152
  const Modal = Object.assign(
110
153
  fixedForwardRef(ModalRenderer),
111
154
  {
112
- Content: ModalContent
155
+ Content: ModalContent,
156
+ Minimize: ModalMinimize
113
157
  }
114
158
  );
115
159
  export {
@@ -91,7 +91,13 @@ const TaskBar = forwardRef(
91
91
  icon,
92
92
  active: id === activeWindow,
93
93
  onClick: () => {
94
- modals.emit(ModalEvents.ModalVisibilityChanged, { id });
94
+ if (id === activeWindow) {
95
+ modals.emit(ModalEvents.MinimizeModal, { id });
96
+ setActiveWindow("Minimize");
97
+ } else {
98
+ modals.emit(ModalEvents.RestoreModal, { id });
99
+ modals.emit(ModalEvents.ModalVisibilityChanged, { id });
100
+ }
95
101
  },
96
102
  small: false
97
103
  },
@@ -25,6 +25,8 @@ var ModalEvents = /* @__PURE__ */ ((ModalEvents2) => {
25
25
  ModalEvents2["AddModal"] = "add-modal";
26
26
  ModalEvents2["RemoveModal"] = "remove-modal";
27
27
  ModalEvents2["ModalVisibilityChanged"] = "modal-visibility-changed";
28
+ ModalEvents2["MinimizeModal"] = "minimize-modal";
29
+ ModalEvents2["RestoreModal"] = "restore-modal";
28
30
  return ModalEvents2;
29
31
  })(ModalEvents || {});
30
32
  const modals = new Emitter();
@@ -1,2 +1,3 @@
1
1
  import './azureOrange.css.ts.vanilla.css';
2
+ import "./contract.css.ts.vanilla.css.mjs";
2
3
  /* empty css */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react95/core",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "description": "Windows 95 styleguide",
5
5
  "main": "cjs/index.cjs",
6
6
  "type": "module",
@@ -180,7 +180,7 @@
180
180
  "url": "https://github.com/React95/React95/issues"
181
181
  },
182
182
  "homepage": "https://github.com/React95/React95#readme",
183
- "gitHead": "f0836d6ccf2168ea0a42d8a63815518b4a17b5c5",
183
+ "gitHead": "3ba802ad17cea4901388c828d4a7e51b39fc1fe3",
184
184
  "module": "esm/index.mjs",
185
185
  "private": false,
186
186
  "types": "types/index.d.ts"
@@ -4,6 +4,14 @@ export declare const modalWrapper: import("@vanilla-extract/recipes").RuntimeFn<
4
4
  zIndex: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
5
5
  };
6
6
  };
7
+ minimized: {
8
+ true: {
9
+ display: "none";
10
+ };
11
+ false: {
12
+ display: "flex";
13
+ };
14
+ };
7
15
  }>;
8
16
  export declare const buttonWrapper: string;
9
17
  export declare const content: string;
@@ -2,7 +2,7 @@ import React, { HTMLAttributes, MouseEvent, ReactElement, Ref } from 'react';
2
2
  import { DragOptions } from '@neodrag/react';
3
3
  import { FrameProps } from '../Frame/Frame';
4
4
  import { List } from '../List/List';
5
- import { TitleBar, TitleBarBackgroundProps } from '../TitleBar/TitleBar';
5
+ import { TitleBar, TitleBarBackgroundProps, OptionReturnType } from '../TitleBar/TitleBar';
6
6
  export type ModalButtons = {
7
7
  value: string;
8
8
  onClick(event: MouseEvent): void;
@@ -2270,8 +2270,10 @@ declare const ModalContent: (props: {
2270
2270
  };
2271
2271
  };
2272
2272
  }> & React.RefAttributes<HTMLDivElement>) => React.ReactNode;
2273
+ declare const ModalMinimize: OptionReturnType;
2273
2274
  declare const ModalRenderer: ({ hasWindowButton: hasButton, buttons, buttonsAlignment, children, icon, menu, title, dragOptions, titleBarOptions, className, ...rest }: ModalProps, ref: Ref<HTMLDivElement | null>) => React.JSX.Element;
2274
2275
  export declare const Modal: ModalProps & typeof ModalRenderer & {
2275
2276
  Content: typeof ModalContent;
2277
+ Minimize: typeof ModalMinimize;
2276
2278
  };
2277
2279
  export {};
@@ -2248,24 +2248,17 @@ declare const OptionsBox: (props: {
2248
2248
  };
2249
2249
  }> & React.RefAttributes<HTMLDivElement>) => React.ReactNode;
2250
2250
  export type OptionProps<TAs extends ElementType> = ButtonHTMLAttributes<HTMLButtonElement> & FrameProps<TAs>;
2251
- declare const Option: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2252
- ref?: ForwardedRef<ElementRef<TAs>>;
2253
- }) => ReactElement;
2254
- declare const Help: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2255
- ref?: ForwardedRef<ElementRef<TAs>>;
2256
- }) => ReactElement;
2257
- declare const Close: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2251
+ export type OptionReturnType = <TAs extends ElementType = 'button'>(props: OptionProps<TAs> & {
2258
2252
  ref?: ForwardedRef<ElementRef<TAs>>;
2259
2253
  }) => ReactElement;
2260
- declare const Maximize: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2261
- ref?: ForwardedRef<ElementRef<TAs>>;
2262
- }) => ReactElement;
2263
- declare const Minimize: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2264
- ref?: ForwardedRef<ElementRef<TAs>>;
2265
- }) => ReactElement;
2266
- declare const Restore: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2254
+ declare const Option: <TAs extends ElementType = "button">(props: OptionProps<TAs> & {
2267
2255
  ref?: ForwardedRef<ElementRef<TAs>>;
2268
2256
  }) => ReactElement;
2257
+ declare const Help: OptionReturnType;
2258
+ declare const Close: OptionReturnType;
2259
+ declare const Maximize: OptionReturnType;
2260
+ declare const Minimize: OptionReturnType;
2261
+ declare const Restore: OptionReturnType;
2269
2262
  export interface TitleBarBackgroundProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color'>, FrameProps<'div'> {
2270
2263
  active?: boolean;
2271
2264
  icon?: ReactElement;
@@ -8,7 +8,9 @@ export declare class Emitter<U extends string, T> {
8
8
  export declare enum ModalEvents {
9
9
  AddModal = "add-modal",
10
10
  RemoveModal = "remove-modal",
11
- ModalVisibilityChanged = "modal-visibility-changed"
11
+ ModalVisibilityChanged = "modal-visibility-changed",
12
+ MinimizeModal = "minimize-modal",
13
+ RestoreModal = "restore-modal"
12
14
  }
13
15
  export interface ModalWindow {
14
16
  icon?: ReactElement;