@raystack/apsara 0.21.0 → 0.21.1

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,8 +1,15 @@
1
- import { DayPickerProps } from "react-day-picker";
1
+ import { DayPickerProps } from 'react-day-picker';
2
2
  interface OnDropdownOpen {
3
3
  onDropdownOpen?: VoidFunction;
4
4
  }
5
- export type CalendarProps = DayPickerProps & OnDropdownOpen;
6
- export declare const Calendar: ({ className, classNames, showOutsideDays, onDropdownOpen, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
5
+ interface CalendarPropsExtended {
6
+ showTooltip?: boolean;
7
+ tooltipMessages?: {
8
+ [key: string]: any;
9
+ };
10
+ loadingData?: boolean;
11
+ }
12
+ export type CalendarProps = DayPickerProps & OnDropdownOpen & CalendarPropsExtended;
13
+ export declare const Calendar: ({ className, classNames, showOutsideDays, onDropdownOpen, showTooltip, tooltipMessages, loadingData, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
7
14
  export {};
8
15
  //# sourceMappingURL=calendar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../calendar/calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAa5E,UAAU,cAAc;IACtB,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,cAAc,CAAC;AAmE5D,eAAO,MAAM,QAAQ,yEAMlB,aAAa,4CA2Cf,CAAC"}
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../calendar/calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAe1B,UAAU,cAAc;IACtB,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED,UAAU,qBAAqB;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,GACxC,cAAc,GACd,qBAAqB,CAAC;AAmExB,eAAO,MAAM,QAAQ,oHASlB,aAAa,4CAsEf,CAAC"}
package/dist/index.cjs CHANGED
@@ -10428,6 +10428,20 @@ const $cb5cc270b50c6fcd$var$PopoverContentNonModal = /*#__PURE__*/ React.forward
10428
10428
  }
10429
10429
  }))));
10430
10430
  });
10431
+ /* -------------------------------------------------------------------------------------------------
10432
+ * PopoverClose
10433
+ * -----------------------------------------------------------------------------------------------*/ const $cb5cc270b50c6fcd$var$CLOSE_NAME = 'PopoverClose';
10434
+ const $cb5cc270b50c6fcd$export$d6ac43ebaa40d53e = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
10435
+ const { __scopePopover: __scopePopover , ...closeProps } = props;
10436
+ const context = $cb5cc270b50c6fcd$var$usePopoverContext($cb5cc270b50c6fcd$var$CLOSE_NAME, __scopePopover);
10437
+ return /*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034$1.button, _extends({
10438
+ type: "button"
10439
+ }, closeProps, {
10440
+ ref: forwardedRef,
10441
+ onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10$1(props.onClick, ()=>context.onOpenChange(false)
10442
+ )
10443
+ }));
10444
+ });
10431
10445
  /* -----------------------------------------------------------------------------------------------*/ function $cb5cc270b50c6fcd$var$getState(open) {
10432
10446
  return open ? 'open' : 'closed';
10433
10447
  }
@@ -10435,6 +10449,7 @@ const $cb5cc270b50c6fcd$export$be92b6f5f03c0fe9 = $cb5cc270b50c6fcd$export$5b6b1
10435
10449
  const $cb5cc270b50c6fcd$export$41fb9f06171c75f4 = $cb5cc270b50c6fcd$export$7dacb05d26466c3;
10436
10450
  const $cb5cc270b50c6fcd$export$602eac185826482c = $cb5cc270b50c6fcd$export$dd679ffb4362d2d4;
10437
10451
  const $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2 = $cb5cc270b50c6fcd$export$d7e1f420b25549ff;
10452
+ const $cb5cc270b50c6fcd$export$f39c2d165cd861fe = $cb5cc270b50c6fcd$export$d6ac43ebaa40d53e;
10438
10453
 
10439
10454
  var styles$i = {"popover":"popover-module_popover__Jh8Hg"};
10440
10455
 
@@ -10443,6 +10458,7 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
10443
10458
  PopoverContent.displayName = $cb5cc270b50c6fcd$export$7c6e2c02157bb7d2.displayName;
10444
10459
  const Popover = Object.assign($cb5cc270b50c6fcd$export$be92b6f5f03c0fe9, {
10445
10460
  Trigger: $cb5cc270b50c6fcd$export$41fb9f06171c75f4,
10461
+ Close: $cb5cc270b50c6fcd$export$f39c2d165cd861fe,
10446
10462
  Content: PopoverContent,
10447
10463
  });
10448
10464
 
@@ -28060,6 +28076,97 @@ function DayPicker(props) {
28060
28076
 
28061
28077
  var styles$6 = {"calendarRoot":"calendar-module_calendarRoot__KnBz-","caption_label":"calendar-module_caption_label__C5Ys7","dropdowns":"calendar-module_dropdowns__Wn53e","dropdown_trigger":"calendar-module_dropdown_trigger__dsyaq","dropdown_item_text":"calendar-module_dropdown_item_text__Tudqv","nav_button":"calendar-module_nav_button__8W5py","nav_button_previous":"calendar-module_nav_button_previous__lWJYm","nav_button_next":"calendar-module_nav_button_next__1MzRT","months":"calendar-module_months__IN75k","nav":"calendar-module_nav__aGeze","month_caption":"calendar-module_month_caption__Ws6Hx","day":"calendar-module_day__rQFGK","disabled":"calendar-module_disabled__jqgRB","outside":"calendar-module_outside__nq5XC","selected":"calendar-module_selected__kiiAZ","range_middle":"calendar-module_range_middle__PmzFi","range_start":"calendar-module_range_start__ZUooG","range_end":"calendar-module_range_end__PKrm7","week":"calendar-module_week__kCvKJ","day_button":"calendar-module_day_button__vCKP1","today":"calendar-module_today__iXQIQ","weekday":"calendar-module_weekday__xzf6F","hidden":"calendar-module_hidden__wqJVo","calendarPopover":"calendar-module_calendarPopover__PY4sa","dropdown_icon":"calendar-module_dropdown_icon__rDTbz","dropdown_content":"calendar-module_dropdown_content__ajJ5V"};
28062
28078
 
28079
+ /**
28080
+ * @internal
28081
+ */
28082
+ const SkeletonThemeContext = React.createContext({});
28083
+
28084
+ /* eslint-disable react/no-array-index-key */
28085
+ const defaultEnableAnimation = true;
28086
+ // For performance & cleanliness, don't add any inline styles unless we have to
28087
+ function styleOptionsToCssProperties({ baseColor, highlightColor, width, height, borderRadius, circle, direction, duration, enableAnimation = defaultEnableAnimation, }) {
28088
+ const style = {};
28089
+ if (direction === 'rtl')
28090
+ style['--animation-direction'] = 'reverse';
28091
+ if (typeof duration === 'number')
28092
+ style['--animation-duration'] = `${duration}s`;
28093
+ if (!enableAnimation)
28094
+ style['--pseudo-element-display'] = 'none';
28095
+ if (typeof width === 'string' || typeof width === 'number')
28096
+ style.width = width;
28097
+ if (typeof height === 'string' || typeof height === 'number')
28098
+ style.height = height;
28099
+ if (typeof borderRadius === 'string' || typeof borderRadius === 'number')
28100
+ style.borderRadius = borderRadius;
28101
+ if (circle)
28102
+ style.borderRadius = '50%';
28103
+ if (typeof baseColor !== 'undefined')
28104
+ style['--base-color'] = baseColor;
28105
+ if (typeof highlightColor !== 'undefined')
28106
+ style['--highlight-color'] = highlightColor;
28107
+ return style;
28108
+ }
28109
+ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, containerClassName, containerTestId, circle = false, style: styleProp, ...originalPropsStyleOptions }) {
28110
+ var _a, _b, _c;
28111
+ const contextStyleOptions = React.useContext(SkeletonThemeContext);
28112
+ const propsStyleOptions = { ...originalPropsStyleOptions };
28113
+ // DO NOT overwrite style options from the context if `propsStyleOptions`
28114
+ // has properties explicity set to undefined
28115
+ for (const [key, value] of Object.entries(originalPropsStyleOptions)) {
28116
+ if (typeof value === 'undefined') {
28117
+ delete propsStyleOptions[key];
28118
+ }
28119
+ }
28120
+ // Props take priority over context
28121
+ const styleOptions = {
28122
+ ...contextStyleOptions,
28123
+ ...propsStyleOptions,
28124
+ circle,
28125
+ };
28126
+ // `styleProp` has the least priority out of everything
28127
+ const style = {
28128
+ ...styleProp,
28129
+ ...styleOptionsToCssProperties(styleOptions),
28130
+ };
28131
+ let className = 'react-loading-skeleton';
28132
+ if (customClassName)
28133
+ className += ` ${customClassName}`;
28134
+ const inline = (_a = styleOptions.inline) !== null && _a !== void 0 ? _a : false;
28135
+ const elements = [];
28136
+ const countCeil = Math.ceil(count);
28137
+ for (let i = 0; i < countCeil; i++) {
28138
+ let thisStyle = style;
28139
+ if (countCeil > count && i === countCeil - 1) {
28140
+ // count is not an integer and we've reached the last iteration of
28141
+ // the loop, so add a "fractional" skeleton.
28142
+ //
28143
+ // For example, if count is 3.5, we've already added 3 full
28144
+ // skeletons, so now we add one more skeleton that is 0.5 times the
28145
+ // original width.
28146
+ const width = (_b = thisStyle.width) !== null && _b !== void 0 ? _b : '100%'; // 100% is the default since that's what's in the CSS
28147
+ const fractionalPart = count % 1;
28148
+ const fractionalWidth = typeof width === 'number'
28149
+ ? width * fractionalPart
28150
+ : `calc(${width} * ${fractionalPart})`;
28151
+ thisStyle = { ...thisStyle, width: fractionalWidth };
28152
+ }
28153
+ const skeletonSpan = (React.createElement("span", { className: className, style: thisStyle, key: i }, "\u200C"));
28154
+ if (inline) {
28155
+ elements.push(skeletonSpan);
28156
+ }
28157
+ else {
28158
+ // Without the <br />, the skeleton lines will all run together if
28159
+ // `width` is specified
28160
+ elements.push(React.createElement(React.Fragment, { key: i },
28161
+ skeletonSpan,
28162
+ React.createElement("br", null)));
28163
+ }
28164
+ }
28165
+ return (React.createElement("span", { className: containerClassName, "data-testid": containerTestId, "aria-live": "polite", "aria-busy": (_c = styleOptions.enableAnimation) !== null && _c !== void 0 ? _c : defaultEnableAnimation }, Wrapper
28166
+ ? elements.map((el, i) => React.createElement(Wrapper, { key: i }, el))
28167
+ : elements));
28168
+ }
28169
+
28063
28170
  const root$1 = cva(styles$6.calendarRoot);
28064
28171
  function DropDown({ options = [], value, onChange, onDropdownOpen, }) {
28065
28172
  const [open, setOpen] = React.useState(false);
@@ -28074,19 +28181,25 @@ function DropDown({ options = [], value, onChange, onDropdownOpen, }) {
28074
28181
  }
28075
28182
  return (jsxRuntimeExports.jsxs(Select$1, { value: value?.toString(), onValueChange: handleChange, open: open, onOpenChange: setOpen, children: [jsxRuntimeExports.jsx(Select$1.Trigger, { className: styles$6.dropdown_trigger, iconProps: {
28076
28183
  className: styles$6.dropdown_icon,
28077
- }, children: jsxRuntimeExports.jsx(Select$1.Value, {}) }), jsxRuntimeExports.jsxs(Select$1.Content, { className: styles$6.dropdown_content, children: [jsxRuntimeExports.jsx(Select$1.ScrollUpButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: "center", children: jsxRuntimeExports.jsx(ChevronUpIcon, {}) }) }), jsxRuntimeExports.jsx(Select$1.Viewport, { children: options.map((opt) => (jsxRuntimeExports.jsx(Select$1.Item, { value: opt.value.toString(), disabled: opt.disabled, textProps: {
28184
+ }, children: jsxRuntimeExports.jsx(Select$1.Value, {}) }), jsxRuntimeExports.jsxs(Select$1.Content, { className: styles$6.dropdown_content, children: [jsxRuntimeExports.jsx(Select$1.ScrollUpButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: 'center', children: jsxRuntimeExports.jsx(ChevronUpIcon, {}) }) }), jsxRuntimeExports.jsx(Select$1.Viewport, { children: options.map((opt) => (jsxRuntimeExports.jsx(Select$1.Item, { value: opt.value.toString(), disabled: opt.disabled, textProps: {
28078
28185
  className: styles$6.dropdown_item_text,
28079
- }, children: opt.label }, opt.value))) }), jsxRuntimeExports.jsx(Select$1.ScrollDownButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: "center", children: jsxRuntimeExports.jsx(ChevronDownIcon, {}) }) })] })] }));
28186
+ }, children: opt.label }, opt.value))) }), jsxRuntimeExports.jsx(Select$1.ScrollDownButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: 'center', children: jsxRuntimeExports.jsx(ChevronDownIcon, {}) }) })] })] }));
28080
28187
  }
28081
- const Calendar = function ({ className, classNames, showOutsideDays = true, onDropdownOpen, ...props }) {
28188
+ const Calendar = function ({ className, classNames, showOutsideDays = true, onDropdownOpen, showTooltip = false, tooltipMessages = {}, loadingData = false, ...props }) {
28082
28189
  return (jsxRuntimeExports.jsx(DayPicker, { showOutsideDays: showOutsideDays, components: {
28083
28190
  Chevron: (props) => {
28084
- if (props.orientation === "left") {
28191
+ if (props.orientation === 'left') {
28085
28192
  return jsxRuntimeExports.jsx(ChevronLeftIcon, { ...props });
28086
28193
  }
28087
28194
  return jsxRuntimeExports.jsx(ChevronRightIcon, { ...props });
28088
28195
  },
28089
28196
  Dropdown: (props) => (jsxRuntimeExports.jsx(DropDown, { ...props, onDropdownOpen: onDropdownOpen })),
28197
+ DayButton: (props) => {
28198
+ const { day, ...buttonProps } = props;
28199
+ const message = tooltipMessages[dateLib.format(day.date, 'dd-MM-yyyy')];
28200
+ return (jsxRuntimeExports.jsx(Tooltip, { side: "top", disabled: loadingData || !showTooltip || !message, message: message, children: jsxRuntimeExports.jsx("button", { ...buttonProps }) }));
28201
+ },
28202
+ MonthGrid: (props) => loadingData ? (jsxRuntimeExports.jsx(Skeleton, { count: 6, height: '12px', width: '252px', style: { marginBottom: 'var(--space-5)' }, highlightColor: "var(--background-base)", baseColor: "var(--background-base-hover)" })) : (jsxRuntimeExports.jsx("table", { ...props })),
28090
28203
  }, classNames: {
28091
28204
  caption_label: styles$6.caption_label,
28092
28205
  button_previous: `${styles$6.nav_button} ${styles$6.nav_button_previous}`,
@@ -32144,97 +32257,6 @@ const Table = Object.assign(TableRoot, {
32144
32257
  Caption: TableCaption,
32145
32258
  });
32146
32259
 
32147
- /**
32148
- * @internal
32149
- */
32150
- const SkeletonThemeContext = React.createContext({});
32151
-
32152
- /* eslint-disable react/no-array-index-key */
32153
- const defaultEnableAnimation = true;
32154
- // For performance & cleanliness, don't add any inline styles unless we have to
32155
- function styleOptionsToCssProperties({ baseColor, highlightColor, width, height, borderRadius, circle, direction, duration, enableAnimation = defaultEnableAnimation, }) {
32156
- const style = {};
32157
- if (direction === 'rtl')
32158
- style['--animation-direction'] = 'reverse';
32159
- if (typeof duration === 'number')
32160
- style['--animation-duration'] = `${duration}s`;
32161
- if (!enableAnimation)
32162
- style['--pseudo-element-display'] = 'none';
32163
- if (typeof width === 'string' || typeof width === 'number')
32164
- style.width = width;
32165
- if (typeof height === 'string' || typeof height === 'number')
32166
- style.height = height;
32167
- if (typeof borderRadius === 'string' || typeof borderRadius === 'number')
32168
- style.borderRadius = borderRadius;
32169
- if (circle)
32170
- style.borderRadius = '50%';
32171
- if (typeof baseColor !== 'undefined')
32172
- style['--base-color'] = baseColor;
32173
- if (typeof highlightColor !== 'undefined')
32174
- style['--highlight-color'] = highlightColor;
32175
- return style;
32176
- }
32177
- function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, containerClassName, containerTestId, circle = false, style: styleProp, ...originalPropsStyleOptions }) {
32178
- var _a, _b, _c;
32179
- const contextStyleOptions = React.useContext(SkeletonThemeContext);
32180
- const propsStyleOptions = { ...originalPropsStyleOptions };
32181
- // DO NOT overwrite style options from the context if `propsStyleOptions`
32182
- // has properties explicity set to undefined
32183
- for (const [key, value] of Object.entries(originalPropsStyleOptions)) {
32184
- if (typeof value === 'undefined') {
32185
- delete propsStyleOptions[key];
32186
- }
32187
- }
32188
- // Props take priority over context
32189
- const styleOptions = {
32190
- ...contextStyleOptions,
32191
- ...propsStyleOptions,
32192
- circle,
32193
- };
32194
- // `styleProp` has the least priority out of everything
32195
- const style = {
32196
- ...styleProp,
32197
- ...styleOptionsToCssProperties(styleOptions),
32198
- };
32199
- let className = 'react-loading-skeleton';
32200
- if (customClassName)
32201
- className += ` ${customClassName}`;
32202
- const inline = (_a = styleOptions.inline) !== null && _a !== void 0 ? _a : false;
32203
- const elements = [];
32204
- const countCeil = Math.ceil(count);
32205
- for (let i = 0; i < countCeil; i++) {
32206
- let thisStyle = style;
32207
- if (countCeil > count && i === countCeil - 1) {
32208
- // count is not an integer and we've reached the last iteration of
32209
- // the loop, so add a "fractional" skeleton.
32210
- //
32211
- // For example, if count is 3.5, we've already added 3 full
32212
- // skeletons, so now we add one more skeleton that is 0.5 times the
32213
- // original width.
32214
- const width = (_b = thisStyle.width) !== null && _b !== void 0 ? _b : '100%'; // 100% is the default since that's what's in the CSS
32215
- const fractionalPart = count % 1;
32216
- const fractionalWidth = typeof width === 'number'
32217
- ? width * fractionalPart
32218
- : `calc(${width} * ${fractionalPart})`;
32219
- thisStyle = { ...thisStyle, width: fractionalWidth };
32220
- }
32221
- const skeletonSpan = (React.createElement("span", { className: className, style: thisStyle, key: i }, "\u200C"));
32222
- if (inline) {
32223
- elements.push(skeletonSpan);
32224
- }
32225
- else {
32226
- // Without the <br />, the skeleton lines will all run together if
32227
- // `width` is specified
32228
- elements.push(React.createElement(React.Fragment, { key: i },
32229
- skeletonSpan,
32230
- React.createElement("br", null)));
32231
- }
32232
- }
32233
- return (React.createElement("span", { className: containerClassName, "data-testid": containerTestId, "aria-live": "polite", "aria-busy": (_c = styleOptions.enableAnimation) !== null && _c !== void 0 ? _c : defaultEnableAnimation }, Wrapper
32234
- ? elements.map((el, i) => React.createElement(Wrapper, { key: i }, el))
32235
- : elements));
32236
- }
32237
-
32238
32260
  function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow = 2, onRowClick, onStateChange = () => { }, onLoadMore, ...props }) {
32239
32261
  const [tableCustomFilter, setTableCustomFilter] = React.useState({});
32240
32262
  const convertedChildren = React.Children.toArray(children);