@jackcrane/ui 0.1.20 → 0.1.22

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,10 +1,11 @@
1
- export default function Card({ children, variant, chamfer, size, collapsed, footerHeight, footer, title, ...props }: {
1
+ export default function Card({ children, variant, chamfer, size, collapsed, onCollapseChange, footerHeight, footer, title, ...props }: {
2
2
  [x: string]: any;
3
3
  children: any;
4
4
  variant: any;
5
5
  chamfer?: boolean;
6
6
  size: any;
7
7
  collapsed: any;
8
+ onCollapseChange: any;
8
9
  footerHeight?: number;
9
10
  footer: any;
10
11
  title: any;
package/dist/jcui.cjs.js CHANGED
@@ -217,7 +217,7 @@ div.jcui_chamfer:not(.jcui_disabled):focus-within {
217
217
  transform: rotate(360deg);
218
218
  }
219
219
  }
220
- ._card_1db6q_1 {
220
+ ._card_1wvfe_1 {
221
221
  border-width: var(--border-thickness);
222
222
  border-style: solid;
223
223
  font-size: 1rem;
@@ -226,27 +226,30 @@ div.jcui_chamfer:not(.jcui_disabled):focus-within {
226
226
  display: flex;
227
227
  flex-direction: column;
228
228
  }
229
- ._pageBackground_1db6q_11 {
229
+ ._pageBackground_1wvfe_11 {
230
230
  --card-bg: var(--body-bg);
231
231
  --button-bg: var(--body-bg);
232
232
  --card-color: var(--body-color);
233
233
  background-color: var(--body-bg);
234
234
  }
235
- ._card_1db6q_1 ._title_1db6q_18 {
235
+ ._card_1wvfe_1 ._title_1wvfe_18 {
236
236
  font-size: 1.25rem;
237
237
  padding: 0.5rem 1rem;
238
238
  border-bottom: var(--border-thickness) solid var(--border-color);
239
239
  background-color: var(--card-bg);
240
240
  }
241
- ._card_1db6q_1 ._titleCollapsed_1db6q_25 {
241
+ ._card_1wvfe_1 ._titleCollapsed_1wvfe_25 {
242
242
  border-bottom: 0;
243
243
  }
244
- ._card_1db6q_1 ._titleContent_1db6q_29 {
244
+ ._card_1wvfe_1 ._titleContent_1wvfe_29 {
245
245
  display: flex;
246
246
  align-items: center;
247
247
  gap: 0.5rem;
248
248
  }
249
- ._card_1db6q_1 ._chevron_1db6q_35 {
249
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35 {
250
+ cursor: pointer;
251
+ }
252
+ ._card_1wvfe_1 ._chevron_1wvfe_39 {
250
253
  margin-left: auto;
251
254
  width: 0.5rem;
252
255
  height: 0.5rem;
@@ -254,82 +257,91 @@ div.jcui_chamfer:not(.jcui_disabled):focus-within {
254
257
  border-bottom: 2px solid currentColor;
255
258
  transition: transform 0.2s ease;
256
259
  flex-shrink: 0;
260
+ cursor: inherit;
257
261
  }
258
- ._card_1db6q_1 ._chevronExpanded_1db6q_45 {
262
+ ._card_1wvfe_1 ._chevronExpanded_1wvfe_50 {
259
263
  transform: rotate(45deg);
260
264
  }
261
- ._card_1db6q_1 ._chevronCollapsed_1db6q_49 {
265
+ ._card_1wvfe_1 ._chevronCollapsed_1wvfe_54 {
262
266
  transform: rotate(-45deg);
263
267
  }
264
- ._card_1db6q_1 ._content_1db6q_53 {
268
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:hover ._chevronExpanded_1wvfe_50,
269
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:focus-visible ._chevronExpanded_1wvfe_50 {
270
+ transform: rotate(30deg);
271
+ }
272
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:hover ._chevronCollapsed_1wvfe_54,
273
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:focus-visible ._chevronCollapsed_1wvfe_54 {
274
+ transform: rotate(-30deg);
275
+ }
276
+ ._card_1wvfe_1 ._content_1wvfe_68 {
265
277
  display: grid;
266
278
  grid-template-rows: 1fr;
267
279
  transition:
268
280
  grid-template-rows 0.2s ease,
269
281
  opacity 0.2s ease;
270
282
  }
271
- ._card_1db6q_1 ._contentInner_1db6q_61 {
283
+ ._card_1wvfe_1 ._contentInner_1wvfe_76 {
272
284
  overflow: hidden;
273
285
  min-height: 0;
274
286
  display: flex;
275
287
  flex-direction: column;
276
288
  }
277
- ._card_1db6q_1 ._contentCollapsed_1db6q_68 {
289
+ ._card_1wvfe_1 ._contentCollapsed_1wvfe_83 {
278
290
  grid-template-rows: 0fr;
279
291
  opacity: 0;
280
292
  }
281
- ._card_1db6q_1 ._body_1db6q_73 {
293
+ ._card_1wvfe_1 ._body_1wvfe_88 {
282
294
  padding: 0.5rem 1rem;
283
295
  width: 100%;
284
296
  }
285
- ._card_1db6q_1 ._footer_1db6q_78 {
297
+ ._card_1wvfe_1 ._footer_1wvfe_93 {
286
298
  border-top: var(--border-thickness) solid var(--border-color);
287
299
  flex: 1;
288
300
  background-color: var(--card-bg);
289
301
  padding: 0.5rem 1rem;
290
302
  }
291
- ._large_1db6q_85 ._body_1db6q_73,
292
- ._large_1db6q_85 ._title_1db6q_18 {
303
+ ._large_1wvfe_100 ._body_1wvfe_88,
304
+ ._large_1wvfe_100 ._title_1wvfe_18 {
293
305
  font-size: 1.25rem;
294
306
  padding: 0.75rem 1.25rem;
295
307
  }
296
- ._small_1db6q_91 ._body_1db6q_73,
297
- ._small_1db6q_91 ._title_1db6q_18 {
308
+ ._small_1wvfe_106 ._body_1wvfe_88,
309
+ ._small_1wvfe_106 ._title_1wvfe_18 {
298
310
  font-size: 0.75rem;
299
311
  padding: 0.25rem 0.5rem;
300
312
  }
301
313
  /* Variants */
302
- ._primary_1db6q_99 {
314
+ ._primary_1wvfe_114 {
303
315
  --card-bg: var(--primary-color-100);
304
316
  --border-color: var(--primary-color-300);
305
317
  --border-accent-color: var(--primary-color-600);
306
318
  --card-color: var(--primary-color-800);
307
319
  }
308
- ._success_1db6q_106 {
320
+ ._success_1wvfe_121 {
309
321
  --card-bg: var(--success-color-100);
310
322
  --border-color: var(--success-color-300);
311
323
  --border-accent-color: var(--success-color-600);
312
324
  --card-color: var(--success-color-800);
313
325
  }
314
- ._warning_1db6q_113 {
326
+ ._warning_1wvfe_128 {
315
327
  --card-bg: var(--warning-color-100);
316
328
  --border-color: var(--warning-color-300);
317
329
  --border-accent-color: var(--warning-color-600);
318
330
  --card-color: var(--warning-color-800);
319
331
  }
320
- ._danger_1db6q_120 {
332
+ ._danger_1wvfe_135 {
321
333
  --card-bg: var(--danger-color-100);
322
334
  --border-color: var(--danger-color-300);
323
335
  --border-accent-color: var(--danger-color-600);
324
336
  --card-color: var(--danger-color-800);
325
337
  }
326
- ._info_1db6q_127 {
338
+ ._info_1wvfe_142 {
327
339
  --card-bg: var(--info-color-100);
328
340
  --border-color: var(--info-color-300);
329
341
  --border-accent-color: var(--info-color-600);
330
342
  --card-color: var(--info-color-800);
331
343
  }
332
- ._secondary_1db6q_134 {
344
+ ._secondary_1wvfe_149 {
333
345
  --card-bg: var(--secondary-color-100);
334
346
  --border-color: var(--secondary-color-300);
335
347
  --border-accent-color: var(--secondary-color-600);
@@ -2655,33 +2667,35 @@ function requireClassnames() {
2655
2667
  }
2656
2668
  var classnamesExports = requireClassnames();
2657
2669
  const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
2658
- const card = "_card_1db6q_1";
2659
- const pageBackground$3 = "_pageBackground_1db6q_11";
2660
- const title$1 = "_title_1db6q_18";
2661
- const titleCollapsed = "_titleCollapsed_1db6q_25";
2662
- const titleContent = "_titleContent_1db6q_29";
2663
- const chevron = "_chevron_1db6q_35";
2664
- const chevronExpanded = "_chevronExpanded_1db6q_45";
2665
- const chevronCollapsed = "_chevronCollapsed_1db6q_49";
2666
- const content$4 = "_content_1db6q_53";
2667
- const contentInner = "_contentInner_1db6q_61";
2668
- const contentCollapsed = "_contentCollapsed_1db6q_68";
2669
- const body$1 = "_body_1db6q_73";
2670
- const footer$1 = "_footer_1db6q_78";
2671
- const large$7 = "_large_1db6q_85";
2672
- const small$7 = "_small_1db6q_91";
2673
- const primary$9 = "_primary_1db6q_99";
2674
- const success$9 = "_success_1db6q_106";
2675
- const warning$9 = "_warning_1db6q_113";
2676
- const danger$9 = "_danger_1db6q_120";
2677
- const info$9 = "_info_1db6q_127";
2678
- const secondary$9 = "_secondary_1db6q_134";
2670
+ const card = "_card_1wvfe_1";
2671
+ const pageBackground$3 = "_pageBackground_1wvfe_11";
2672
+ const title$1 = "_title_1wvfe_18";
2673
+ const titleCollapsed = "_titleCollapsed_1wvfe_25";
2674
+ const titleContent = "_titleContent_1wvfe_29";
2675
+ const titleInteractive = "_titleInteractive_1wvfe_35";
2676
+ const chevron = "_chevron_1wvfe_39";
2677
+ const chevronExpanded = "_chevronExpanded_1wvfe_50";
2678
+ const chevronCollapsed = "_chevronCollapsed_1wvfe_54";
2679
+ const content$4 = "_content_1wvfe_68";
2680
+ const contentInner = "_contentInner_1wvfe_76";
2681
+ const contentCollapsed = "_contentCollapsed_1wvfe_83";
2682
+ const body$1 = "_body_1wvfe_88";
2683
+ const footer$1 = "_footer_1wvfe_93";
2684
+ const large$7 = "_large_1wvfe_100";
2685
+ const small$7 = "_small_1wvfe_106";
2686
+ const primary$9 = "_primary_1wvfe_114";
2687
+ const success$9 = "_success_1wvfe_121";
2688
+ const warning$9 = "_warning_1wvfe_128";
2689
+ const danger$9 = "_danger_1wvfe_135";
2690
+ const info$9 = "_info_1wvfe_142";
2691
+ const secondary$9 = "_secondary_1wvfe_149";
2679
2692
  const styles$b = {
2680
2693
  card,
2681
2694
  pageBackground: pageBackground$3,
2682
2695
  title: title$1,
2683
2696
  titleCollapsed,
2684
2697
  titleContent,
2698
+ titleInteractive,
2685
2699
  chevron,
2686
2700
  chevronExpanded,
2687
2701
  chevronCollapsed,
@@ -2705,6 +2719,7 @@ function Card({
2705
2719
  chamfer: chamfer2 = true,
2706
2720
  size: size2,
2707
2721
  collapsed,
2722
+ onCollapseChange,
2708
2723
  footerHeight = 0,
2709
2724
  footer: footer2,
2710
2725
  // I hardly know her
@@ -2713,6 +2728,21 @@ function Card({
2713
2728
  }) {
2714
2729
  const isCollapsible = collapsed !== void 0;
2715
2730
  const isCollapsed2 = Boolean(collapsed);
2731
+ const handleCollapseToggle = () => {
2732
+ if (!isCollapsible) {
2733
+ return;
2734
+ }
2735
+ onCollapseChange?.(!isCollapsed2);
2736
+ };
2737
+ const handleKeyDown = (event) => {
2738
+ if (!isCollapsible) {
2739
+ return;
2740
+ }
2741
+ if (event.key === "Enter" || event.key === " ") {
2742
+ event.preventDefault();
2743
+ handleCollapseToggle();
2744
+ }
2745
+ };
2716
2746
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2717
2747
  "div",
2718
2748
  {
@@ -2732,8 +2762,15 @@ function Card({
2732
2762
  className: classNames(
2733
2763
  styles$b.title,
2734
2764
  hatchStyles.hatch,
2735
- isCollapsed2 && styles$b.titleCollapsed
2765
+ isCollapsed2 && styles$b.titleCollapsed,
2766
+ isCollapsible && styles$b.titleInteractive
2736
2767
  ),
2768
+ onClick: isCollapsible ? handleCollapseToggle : void 0,
2769
+ onKeyDown: isCollapsible ? handleKeyDown : void 0,
2770
+ role: isCollapsible ? "button" : void 0,
2771
+ tabIndex: isCollapsible ? 0 : void 0,
2772
+ "aria-expanded": isCollapsible ? !isCollapsed2 : void 0,
2773
+ "aria-label": isCollapsible ? isCollapsed2 ? "Expand card" : "Collapse card" : void 0,
2737
2774
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$b.titleContent, children: [
2738
2775
  title2,
2739
2776
  isCollapsible && /* @__PURE__ */ jsxRuntimeExports.jsx(
package/dist/jcui.es.js CHANGED
@@ -217,7 +217,7 @@ div.jcui_chamfer:not(.jcui_disabled):focus-within {
217
217
  transform: rotate(360deg);
218
218
  }
219
219
  }
220
- ._card_1db6q_1 {
220
+ ._card_1wvfe_1 {
221
221
  border-width: var(--border-thickness);
222
222
  border-style: solid;
223
223
  font-size: 1rem;
@@ -226,27 +226,30 @@ div.jcui_chamfer:not(.jcui_disabled):focus-within {
226
226
  display: flex;
227
227
  flex-direction: column;
228
228
  }
229
- ._pageBackground_1db6q_11 {
229
+ ._pageBackground_1wvfe_11 {
230
230
  --card-bg: var(--body-bg);
231
231
  --button-bg: var(--body-bg);
232
232
  --card-color: var(--body-color);
233
233
  background-color: var(--body-bg);
234
234
  }
235
- ._card_1db6q_1 ._title_1db6q_18 {
235
+ ._card_1wvfe_1 ._title_1wvfe_18 {
236
236
  font-size: 1.25rem;
237
237
  padding: 0.5rem 1rem;
238
238
  border-bottom: var(--border-thickness) solid var(--border-color);
239
239
  background-color: var(--card-bg);
240
240
  }
241
- ._card_1db6q_1 ._titleCollapsed_1db6q_25 {
241
+ ._card_1wvfe_1 ._titleCollapsed_1wvfe_25 {
242
242
  border-bottom: 0;
243
243
  }
244
- ._card_1db6q_1 ._titleContent_1db6q_29 {
244
+ ._card_1wvfe_1 ._titleContent_1wvfe_29 {
245
245
  display: flex;
246
246
  align-items: center;
247
247
  gap: 0.5rem;
248
248
  }
249
- ._card_1db6q_1 ._chevron_1db6q_35 {
249
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35 {
250
+ cursor: pointer;
251
+ }
252
+ ._card_1wvfe_1 ._chevron_1wvfe_39 {
250
253
  margin-left: auto;
251
254
  width: 0.5rem;
252
255
  height: 0.5rem;
@@ -254,82 +257,91 @@ div.jcui_chamfer:not(.jcui_disabled):focus-within {
254
257
  border-bottom: 2px solid currentColor;
255
258
  transition: transform 0.2s ease;
256
259
  flex-shrink: 0;
260
+ cursor: inherit;
257
261
  }
258
- ._card_1db6q_1 ._chevronExpanded_1db6q_45 {
262
+ ._card_1wvfe_1 ._chevronExpanded_1wvfe_50 {
259
263
  transform: rotate(45deg);
260
264
  }
261
- ._card_1db6q_1 ._chevronCollapsed_1db6q_49 {
265
+ ._card_1wvfe_1 ._chevronCollapsed_1wvfe_54 {
262
266
  transform: rotate(-45deg);
263
267
  }
264
- ._card_1db6q_1 ._content_1db6q_53 {
268
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:hover ._chevronExpanded_1wvfe_50,
269
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:focus-visible ._chevronExpanded_1wvfe_50 {
270
+ transform: rotate(30deg);
271
+ }
272
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:hover ._chevronCollapsed_1wvfe_54,
273
+ ._card_1wvfe_1 ._titleInteractive_1wvfe_35:focus-visible ._chevronCollapsed_1wvfe_54 {
274
+ transform: rotate(-30deg);
275
+ }
276
+ ._card_1wvfe_1 ._content_1wvfe_68 {
265
277
  display: grid;
266
278
  grid-template-rows: 1fr;
267
279
  transition:
268
280
  grid-template-rows 0.2s ease,
269
281
  opacity 0.2s ease;
270
282
  }
271
- ._card_1db6q_1 ._contentInner_1db6q_61 {
283
+ ._card_1wvfe_1 ._contentInner_1wvfe_76 {
272
284
  overflow: hidden;
273
285
  min-height: 0;
274
286
  display: flex;
275
287
  flex-direction: column;
276
288
  }
277
- ._card_1db6q_1 ._contentCollapsed_1db6q_68 {
289
+ ._card_1wvfe_1 ._contentCollapsed_1wvfe_83 {
278
290
  grid-template-rows: 0fr;
279
291
  opacity: 0;
280
292
  }
281
- ._card_1db6q_1 ._body_1db6q_73 {
293
+ ._card_1wvfe_1 ._body_1wvfe_88 {
282
294
  padding: 0.5rem 1rem;
283
295
  width: 100%;
284
296
  }
285
- ._card_1db6q_1 ._footer_1db6q_78 {
297
+ ._card_1wvfe_1 ._footer_1wvfe_93 {
286
298
  border-top: var(--border-thickness) solid var(--border-color);
287
299
  flex: 1;
288
300
  background-color: var(--card-bg);
289
301
  padding: 0.5rem 1rem;
290
302
  }
291
- ._large_1db6q_85 ._body_1db6q_73,
292
- ._large_1db6q_85 ._title_1db6q_18 {
303
+ ._large_1wvfe_100 ._body_1wvfe_88,
304
+ ._large_1wvfe_100 ._title_1wvfe_18 {
293
305
  font-size: 1.25rem;
294
306
  padding: 0.75rem 1.25rem;
295
307
  }
296
- ._small_1db6q_91 ._body_1db6q_73,
297
- ._small_1db6q_91 ._title_1db6q_18 {
308
+ ._small_1wvfe_106 ._body_1wvfe_88,
309
+ ._small_1wvfe_106 ._title_1wvfe_18 {
298
310
  font-size: 0.75rem;
299
311
  padding: 0.25rem 0.5rem;
300
312
  }
301
313
  /* Variants */
302
- ._primary_1db6q_99 {
314
+ ._primary_1wvfe_114 {
303
315
  --card-bg: var(--primary-color-100);
304
316
  --border-color: var(--primary-color-300);
305
317
  --border-accent-color: var(--primary-color-600);
306
318
  --card-color: var(--primary-color-800);
307
319
  }
308
- ._success_1db6q_106 {
320
+ ._success_1wvfe_121 {
309
321
  --card-bg: var(--success-color-100);
310
322
  --border-color: var(--success-color-300);
311
323
  --border-accent-color: var(--success-color-600);
312
324
  --card-color: var(--success-color-800);
313
325
  }
314
- ._warning_1db6q_113 {
326
+ ._warning_1wvfe_128 {
315
327
  --card-bg: var(--warning-color-100);
316
328
  --border-color: var(--warning-color-300);
317
329
  --border-accent-color: var(--warning-color-600);
318
330
  --card-color: var(--warning-color-800);
319
331
  }
320
- ._danger_1db6q_120 {
332
+ ._danger_1wvfe_135 {
321
333
  --card-bg: var(--danger-color-100);
322
334
  --border-color: var(--danger-color-300);
323
335
  --border-accent-color: var(--danger-color-600);
324
336
  --card-color: var(--danger-color-800);
325
337
  }
326
- ._info_1db6q_127 {
338
+ ._info_1wvfe_142 {
327
339
  --card-bg: var(--info-color-100);
328
340
  --border-color: var(--info-color-300);
329
341
  --border-accent-color: var(--info-color-600);
330
342
  --card-color: var(--info-color-800);
331
343
  }
332
- ._secondary_1db6q_134 {
344
+ ._secondary_1wvfe_149 {
333
345
  --card-bg: var(--secondary-color-100);
334
346
  --border-color: var(--secondary-color-300);
335
347
  --border-accent-color: var(--secondary-color-600);
@@ -2637,33 +2649,35 @@ function requireClassnames() {
2637
2649
  }
2638
2650
  var classnamesExports = requireClassnames();
2639
2651
  const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
2640
- const card = "_card_1db6q_1";
2641
- const pageBackground$3 = "_pageBackground_1db6q_11";
2642
- const title$1 = "_title_1db6q_18";
2643
- const titleCollapsed = "_titleCollapsed_1db6q_25";
2644
- const titleContent = "_titleContent_1db6q_29";
2645
- const chevron = "_chevron_1db6q_35";
2646
- const chevronExpanded = "_chevronExpanded_1db6q_45";
2647
- const chevronCollapsed = "_chevronCollapsed_1db6q_49";
2648
- const content$4 = "_content_1db6q_53";
2649
- const contentInner = "_contentInner_1db6q_61";
2650
- const contentCollapsed = "_contentCollapsed_1db6q_68";
2651
- const body$1 = "_body_1db6q_73";
2652
- const footer$1 = "_footer_1db6q_78";
2653
- const large$7 = "_large_1db6q_85";
2654
- const small$7 = "_small_1db6q_91";
2655
- const primary$9 = "_primary_1db6q_99";
2656
- const success$9 = "_success_1db6q_106";
2657
- const warning$9 = "_warning_1db6q_113";
2658
- const danger$9 = "_danger_1db6q_120";
2659
- const info$9 = "_info_1db6q_127";
2660
- const secondary$9 = "_secondary_1db6q_134";
2652
+ const card = "_card_1wvfe_1";
2653
+ const pageBackground$3 = "_pageBackground_1wvfe_11";
2654
+ const title$1 = "_title_1wvfe_18";
2655
+ const titleCollapsed = "_titleCollapsed_1wvfe_25";
2656
+ const titleContent = "_titleContent_1wvfe_29";
2657
+ const titleInteractive = "_titleInteractive_1wvfe_35";
2658
+ const chevron = "_chevron_1wvfe_39";
2659
+ const chevronExpanded = "_chevronExpanded_1wvfe_50";
2660
+ const chevronCollapsed = "_chevronCollapsed_1wvfe_54";
2661
+ const content$4 = "_content_1wvfe_68";
2662
+ const contentInner = "_contentInner_1wvfe_76";
2663
+ const contentCollapsed = "_contentCollapsed_1wvfe_83";
2664
+ const body$1 = "_body_1wvfe_88";
2665
+ const footer$1 = "_footer_1wvfe_93";
2666
+ const large$7 = "_large_1wvfe_100";
2667
+ const small$7 = "_small_1wvfe_106";
2668
+ const primary$9 = "_primary_1wvfe_114";
2669
+ const success$9 = "_success_1wvfe_121";
2670
+ const warning$9 = "_warning_1wvfe_128";
2671
+ const danger$9 = "_danger_1wvfe_135";
2672
+ const info$9 = "_info_1wvfe_142";
2673
+ const secondary$9 = "_secondary_1wvfe_149";
2661
2674
  const styles$b = {
2662
2675
  card,
2663
2676
  pageBackground: pageBackground$3,
2664
2677
  title: title$1,
2665
2678
  titleCollapsed,
2666
2679
  titleContent,
2680
+ titleInteractive,
2667
2681
  chevron,
2668
2682
  chevronExpanded,
2669
2683
  chevronCollapsed,
@@ -2687,6 +2701,7 @@ function Card({
2687
2701
  chamfer: chamfer2 = true,
2688
2702
  size: size2,
2689
2703
  collapsed,
2704
+ onCollapseChange,
2690
2705
  footerHeight = 0,
2691
2706
  footer: footer2,
2692
2707
  // I hardly know her
@@ -2695,6 +2710,21 @@ function Card({
2695
2710
  }) {
2696
2711
  const isCollapsible = collapsed !== void 0;
2697
2712
  const isCollapsed2 = Boolean(collapsed);
2713
+ const handleCollapseToggle = () => {
2714
+ if (!isCollapsible) {
2715
+ return;
2716
+ }
2717
+ onCollapseChange?.(!isCollapsed2);
2718
+ };
2719
+ const handleKeyDown = (event) => {
2720
+ if (!isCollapsible) {
2721
+ return;
2722
+ }
2723
+ if (event.key === "Enter" || event.key === " ") {
2724
+ event.preventDefault();
2725
+ handleCollapseToggle();
2726
+ }
2727
+ };
2698
2728
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
2699
2729
  "div",
2700
2730
  {
@@ -2714,8 +2744,15 @@ function Card({
2714
2744
  className: classNames(
2715
2745
  styles$b.title,
2716
2746
  hatchStyles.hatch,
2717
- isCollapsed2 && styles$b.titleCollapsed
2747
+ isCollapsed2 && styles$b.titleCollapsed,
2748
+ isCollapsible && styles$b.titleInteractive
2718
2749
  ),
2750
+ onClick: isCollapsible ? handleCollapseToggle : void 0,
2751
+ onKeyDown: isCollapsible ? handleKeyDown : void 0,
2752
+ role: isCollapsible ? "button" : void 0,
2753
+ tabIndex: isCollapsible ? 0 : void 0,
2754
+ "aria-expanded": isCollapsible ? !isCollapsed2 : void 0,
2755
+ "aria-label": isCollapsible ? isCollapsed2 ? "Expand card" : "Collapse card" : void 0,
2719
2756
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$b.titleContent, children: [
2720
2757
  title2,
2721
2758
  isCollapsible && /* @__PURE__ */ jsxRuntimeExports.jsx(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackcrane/ui",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "dist/jcui.cjs.js",