@edenapp/solid-kit 0.11.0 → 0.12.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edenapp/solid-kit",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "High-level SolidJS UI primitives for Eden apps",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -21,14 +21,14 @@
21
21
  "src"
22
22
  ],
23
23
  "peerDependencies": {
24
- "solid-js": "^1.9.0"
24
+ "solid-js": "^1.9.14"
25
25
  },
26
26
  "dependencies": {
27
- "solid-icons": "^1.1.0"
27
+ "solid-icons": "^1.2.0"
28
28
  },
29
29
  "devDependencies": {
30
- "typescript": "^5.3.0",
31
- "@edenapp/types": "0.11.0"
30
+ "typescript": "^6.0.3",
31
+ "@edenapp/types": "0.12.0"
32
32
  },
33
33
  "keywords": [
34
34
  "eden",
@@ -42,7 +42,7 @@ export const DialogHost: Component<DialogHostProps> = (props) => {
42
42
  setValue: dialog.setValue as Setter<unknown>,
43
43
  canSubmit: dialog.canSubmit,
44
44
  setCanSubmit: dialog.setCanSubmit,
45
- submit: (result) => dialogs.submit(result),
45
+ submit: (...args) => dialogs.submit(...args),
46
46
  cancel: dialogs.cancel,
47
47
  setPrimaryActionRef: (el) => {
48
48
  primaryActionRef = el;
@@ -89,7 +89,11 @@ export const DialogHost: Component<DialogHostProps> = (props) => {
89
89
  const handleKeyDown = (e: KeyboardEvent) => {
90
90
  e.stopPropagation();
91
91
 
92
- if (e.key === "Escape" && current.dismissOnEscape) {
92
+ if (
93
+ e.key === "Escape" &&
94
+ current.dismissable &&
95
+ current.dismissOnEscape
96
+ ) {
93
97
  e.preventDefault();
94
98
  dialogs.cancel();
95
99
  return;
@@ -107,7 +111,7 @@ export const DialogHost: Component<DialogHostProps> = (props) => {
107
111
  };
108
112
 
109
113
  const handleMouseDown = (e: MouseEvent) => {
110
- if (!current.dismissOnBackdrop) return;
114
+ if (!current.dismissable || !current.dismissOnBackdrop) return;
111
115
 
112
116
  const target = e.target as Node | null;
113
117
  if (!target || !modalRef) return;
@@ -137,23 +141,30 @@ export const DialogHost: Component<DialogHostProps> = (props) => {
137
141
  }
138
142
 
139
143
  const renderContext = createRenderContext(dialog);
144
+ const titleId = `eden-dialog-title-${dialog.id}`;
140
145
 
141
146
  return (
147
+ // biome-ignore lint/a11y/useAriaPropsSupportedByRole: the typed dynamic role is always dialog or alertdialog.
142
148
  <div
143
149
  ref={modalRef}
144
150
  class={`eden-modal ${sizeClass(dialog.size)}`}
145
- role="dialog"
151
+ role={dialog.role}
146
152
  aria-modal="true"
153
+ aria-labelledby={titleId}
147
154
  >
148
155
  <div class="eden-modal-header">
149
- <h3 class="eden-modal-title">{dialog.title}</h3>
150
- <button
151
- type="button"
152
- class="eden-modal-close"
153
- onClick={() => dialogs.cancel()}
154
- >
155
- ×
156
- </button>
156
+ <h3 id={titleId} class="eden-modal-title">
157
+ {dialog.title}
158
+ </h3>
159
+ {dialog.dismissable && (
160
+ <button
161
+ type="button"
162
+ class="eden-modal-close"
163
+ onClick={() => dialogs.cancel()}
164
+ >
165
+ ×
166
+ </button>
167
+ )}
157
168
  </div>
158
169
 
159
170
  <div class="eden-modal-body">
@@ -121,6 +121,8 @@ export const createDialogs = (): DialogController => {
121
121
  title: options.title,
122
122
  message: options.message,
123
123
  size: options.size ?? "sm",
124
+ role: options.role ?? "dialog",
125
+ dismissable: options.dismissable ?? true,
124
126
  dismissOnBackdrop: options.dismissOnBackdrop ?? true,
125
127
  dismissOnEscape: options.dismissOnEscape ?? true,
126
128
  onEnter: options.onEnter ?? "submit",
@@ -148,7 +150,7 @@ export const createDialogs = (): DialogController => {
148
150
 
149
151
  const submit: DialogRuntimeController["submit"] = async (...args) => {
150
152
  const current = active();
151
- if (!current || !current.canSubmit()) return;
153
+ if (!current?.canSubmit()) return;
152
154
 
153
155
  const hasExplicitResult = args.length > 0;
154
156
  const result = args[0];
@@ -194,6 +196,8 @@ export const createDialogs = (): DialogController => {
194
196
  title: options.title,
195
197
  message: options.message,
196
198
  size: options.size,
199
+ role: options.role,
200
+ dismissable: options.dismissable,
197
201
  dismissOnBackdrop: options.dismissOnBackdrop,
198
202
  dismissOnEscape: options.dismissOnEscape,
199
203
  onEnter: options.onEnter,
@@ -219,6 +223,8 @@ export const createDialogs = (): DialogController => {
219
223
  title: options.title,
220
224
  message: options.message,
221
225
  size: options.size,
226
+ role: options.role,
227
+ dismissable: options.dismissable,
222
228
  dismissOnBackdrop: options.dismissOnBackdrop,
223
229
  dismissOnEscape: options.dismissOnEscape,
224
230
  onEnter: options.onEnter,
@@ -251,6 +257,8 @@ export const createDialogs = (): DialogController => {
251
257
  title: options.title,
252
258
  message: options.message,
253
259
  size: options.size,
260
+ role: options.role,
261
+ dismissable: options.dismissable,
254
262
  dismissOnBackdrop: options.dismissOnBackdrop,
255
263
  dismissOnEscape: options.dismissOnEscape,
256
264
  onEnter: options.onEnter,
@@ -311,6 +319,8 @@ export const createDialogs = (): DialogController => {
311
319
  title: options.title,
312
320
  message: options.message,
313
321
  size: options.size,
322
+ role: options.role,
323
+ dismissable: options.dismissable,
314
324
  dismissOnBackdrop: options.dismissOnBackdrop,
315
325
  dismissOnEscape: options.dismissOnEscape,
316
326
  onEnter: options.onEnter,
@@ -12,9 +12,11 @@ interface DialogRequestMeta {
12
12
  title: string;
13
13
  message?: JSX.Element | string;
14
14
  size: DialogSize;
15
+ role: "dialog" | "alertdialog";
15
16
  }
16
17
 
17
18
  interface DialogRequestBehavior {
19
+ dismissable: boolean;
18
20
  dismissOnBackdrop: boolean;
19
21
  dismissOnEscape: boolean;
20
22
  onEnter: DialogEnterBehavior;
@@ -24,9 +24,13 @@ interface DialogBaseOptions {
24
24
  message?: JSX.Element | string;
25
25
  /** Optional width preset. Defaults to `"sm"`. */
26
26
  size?: DialogSize;
27
+ /** Accessible dialog role. Defaults to `"dialog"`. */
28
+ role?: "dialog" | "alertdialog";
29
+ /** Allow passive dismissal via the close button, backdrop, or Escape. Defaults to `true`. */
30
+ dismissable?: boolean;
27
31
  /** Close when clicking the backdrop. Defaults to `true`. */
28
32
  dismissOnBackdrop?: boolean;
29
- /** Close on Escape key. Defaults to `true`. */
33
+ /** Close on Escape when the dialog is dismissable. Defaults to `true`. */
30
34
  dismissOnEscape?: boolean;
31
35
  /** Enter key behavior. Defaults to `"submit"`. */
32
36
  onEnter?: DialogEnterBehavior;