@kaizen/components 1.70.23 → 1.71.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
- export * from './fixtures/mockRangeForBoundingRect';
2
1
  export * from './addMark';
3
2
  export * from './getMarkAttrs';
4
3
  export * from './getMarkRange';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "1.70.23",
3
+ "version": "1.71.0",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -17,3 +17,11 @@
17
17
  padding: $spacing-24;
18
18
  }
19
19
  }
20
+
21
+ // Overrides for if the browser supports popovers. The inset unset is to fix a bug with RTL positioning https://github.com/floating-ui/floating-ui/issues/3221
22
+ // Margin 0 because default styling for [popover] is margin: auto to center it.
23
+ .calendarPopover[popover]:popover-open {
24
+ z-index: unset;
25
+ margin: 0;
26
+ inset: unset;
27
+ }
@@ -1,4 +1,4 @@
1
- import React, { useState, type HTMLAttributes } from 'react'
1
+ import React, { useEffect, useState, type HTMLAttributes } from 'react'
2
2
  import {
3
3
  autoPlacement,
4
4
  autoUpdate,
@@ -30,7 +30,7 @@ export const CalendarPopover = ({
30
30
  }: CalendarPopoverProps): JSX.Element => {
31
31
  const [floatingElement, setFloatingElement] = useState<HTMLDivElement | null>(null)
32
32
 
33
- const { floatingStyles } = useFloating({
33
+ const { floatingStyles, update } = useFloating({
34
34
  placement: 'bottom-start',
35
35
  elements: {
36
36
  reference: referenceElement,
@@ -57,6 +57,15 @@ export const CalendarPopover = ({
57
57
  ...floatingOptions,
58
58
  })
59
59
 
60
+ useEffect(() => {
61
+ if (floatingElement && referenceElement) {
62
+ // @ts-expect-error this can be removed when we update to react 19
63
+ referenceElement.popoverTargetElement = floatingElement
64
+ floatingElement.showPopover?.()
65
+ update()
66
+ }
67
+ }, [referenceElement, floatingElement, update])
68
+
60
69
  return (
61
70
  <div
62
71
  ref={setFloatingElement}
@@ -64,6 +73,8 @@ export const CalendarPopover = ({
64
73
  className={classnames(styles.calendarPopover, classNameOverride)}
65
74
  role="dialog"
66
75
  aria-modal="true"
76
+ // @ts-expect-error this can be removed when we update to react 19
77
+ popover="manual"
67
78
  {...restProps}
68
79
  >
69
80
  {children}
@@ -1,7 +1,6 @@
1
1
  import React from 'react'
2
2
  import { autoPlacement, offset, size } from '@floating-ui/react-dom'
3
3
  import { type Meta } from '@storybook/react'
4
- import { Text } from '~components/Text'
5
4
  import { StickerSheet, type StickerSheetStory } from '~storybook/components/StickerSheet'
6
5
  import { CalendarRange } from '../../CalendarRange'
7
6
  import { CalendarSingle } from '../../CalendarSingle'
@@ -150,56 +149,3 @@ export const StickerSheetRTL: StickerSheetStory = {
150
149
  textDirection: 'rtl',
151
150
  },
152
151
  }
153
-
154
- export const StickerSheetResponsive: StickerSheetStory = {
155
- name: 'Sticker Sheet (Responsive)',
156
- render: () => (
157
- <>
158
- <Text variant="intro-lede" classNameOverride="mb-12 ">
159
- CalendarSingle scaled to availableHeight
160
- </Text>
161
- <div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative">
162
- <CalendarPopoverExample strategy="absolute">
163
- <CalendarSingle selected={new Date('2022-02-19')} />
164
- </CalendarPopoverExample>
165
- </div>
166
- <Text variant="intro-lede" classNameOverride="mb-12 ">
167
- CalendarRange scaled to availableHeight
168
- </Text>
169
- <div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative">
170
- <CalendarPopoverExample strategy="absolute">
171
- <CalendarRange
172
- selected={{
173
- from: new Date('2022-02-19'),
174
- to: new Date('2022-03-04'),
175
- }}
176
- hasDivider
177
- />
178
- </CalendarPopoverExample>
179
- </div>
180
- <Text variant="intro-lede" classNameOverride="mb-12 mt-24">
181
- CalendarSingle scaled to availableWidth
182
- </Text>
183
- <div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative w-[250px]">
184
- <CalendarPopoverExample strategy="absolute">
185
- <CalendarSingle selected={new Date('2022-03-19')} />
186
- </CalendarPopoverExample>
187
- </div>
188
- <Text variant="intro-lede" classNameOverride="mb-12 mt-24">
189
- CalendarRanger scaled to availableWidth
190
- </Text>
191
- <div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative w-[250px]">
192
- <CalendarPopoverExample strategy="absolute">
193
- <CalendarRange
194
- data-testid="sb-final-calendar"
195
- selected={{
196
- from: new Date('2022-02-19'),
197
- to: new Date('2022-03-04'),
198
- }}
199
- hasDivider
200
- />
201
- </CalendarPopoverExample>
202
- </div>
203
- </>
204
- ),
205
- }
@@ -1,4 +1,3 @@
1
- export * from './fixtures/mockRangeForBoundingRect'
2
1
  export * from './addMark'
3
2
  export * from './getMarkAttrs'
4
3
  export * from './getMarkRange'
@@ -114,7 +114,6 @@ $tab-container-height-medium-and-small-collapsed: 0;
114
114
  display: flex;
115
115
  align-items: center;
116
116
  min-width: 0; // this is an important trick to prevent flexbox items from overflowing
117
- z-index: $ca-z-index-dropdown; // this ensures the page switcher dropdown sits over nav tabs
118
117
  transform: translateY(-0.0833em);
119
118
 
120
119
  .hasSubtitle & {
@@ -434,7 +433,7 @@ $tab-container-height-medium-and-small-collapsed: 0;
434
433
  width: $tab-container-height-small;
435
434
  height: $tab-container-height-small;
436
435
  background: linear-gradient(0deg, $color-purple-600, rgba($color-purple-600-rgb, 0));
437
- z-index: $ca-z-index-sticky;
436
+ z-index: 1;
438
437
  }
439
438
 
440
439
  .adminVariant & {
@@ -503,7 +502,6 @@ $tab-container-height-medium-and-small-collapsed: 0;
503
502
  cursor: pointer;
504
503
  display: flex;
505
504
  position: absolute;
506
- z-index: $ca-z-index-sticky;
507
505
  align-items: center;
508
506
  top: 50%;
509
507
  transform: translateY(-50%);
@@ -573,9 +571,6 @@ $tab-container-height-medium-and-small-collapsed: 0;
573
571
  // We are using visually hidden here instead of display:none so that a screen reader
574
572
  // navigating via 'read mode' (which doesn't trigger hover/focus) will still hear this link name
575
573
  @include visually-hidden;
576
-
577
- z-index: $ca-z-index-sticky - 1;
578
-
579
574
  @include ca-position($start: -2 * $ca-grid);
580
575
 
581
576
  position: absolute;
@@ -1,40 +0,0 @@
1
- 'use strict';
2
-
3
- var vitest = require('vitest');
4
-
5
- // eslint-disable-next-line import/no-extraneous-dependencies
6
- /*
7
- ** This is used handle the JSDom type error issue you may encounter in testing
8
- ** See https://github.com/jsdom/jsdom/issues/3002
9
- */
10
- var mockRangeForBoundingRect = function () {
11
- vitest.vi.spyOn(document, 'createRange').mockImplementation(function () {
12
- var range = new Range();
13
- range.getBoundingClientRect = function () {
14
- return {
15
- x: 0,
16
- y: 0,
17
- bottom: 0,
18
- height: 0,
19
- left: 0,
20
- right: 0,
21
- top: 0,
22
- width: 0,
23
- toJSON: function () {
24
- return undefined;
25
- }
26
- };
27
- };
28
- range.getClientRects = function () {
29
- var _a;
30
- return _a = {
31
- item: function () {
32
- return null;
33
- },
34
- length: 0
35
- }, _a[Symbol.iterator] = vitest.vi.fn(), _a;
36
- };
37
- return range;
38
- });
39
- };
40
- exports.mockRangeForBoundingRect = mockRangeForBoundingRect;
@@ -1,38 +0,0 @@
1
- import { vi } from 'vitest';
2
-
3
- // eslint-disable-next-line import/no-extraneous-dependencies
4
- /*
5
- ** This is used handle the JSDom type error issue you may encounter in testing
6
- ** See https://github.com/jsdom/jsdom/issues/3002
7
- */
8
- var mockRangeForBoundingRect = function () {
9
- vi.spyOn(document, 'createRange').mockImplementation(function () {
10
- var range = new Range();
11
- range.getBoundingClientRect = function () {
12
- return {
13
- x: 0,
14
- y: 0,
15
- bottom: 0,
16
- height: 0,
17
- left: 0,
18
- right: 0,
19
- top: 0,
20
- width: 0,
21
- toJSON: function () {
22
- return undefined;
23
- }
24
- };
25
- };
26
- range.getClientRects = function () {
27
- var _a;
28
- return _a = {
29
- item: function () {
30
- return null;
31
- },
32
- length: 0
33
- }, _a[Symbol.iterator] = vi.fn(), _a;
34
- };
35
- return range;
36
- });
37
- };
38
- export { mockRangeForBoundingRect };