@bigstack-oss/cube-ui 0.1.0 → 0.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ForwardRefExoticComponent, SVGProps, RefAttributes, ReactElement, JSX, ButtonHTMLAttributes, InputHTMLAttributes, RefObject, PropsWithChildren, AnchorHTMLAttributes, MouseEvent, ReactNode, DetailedHTMLProps, TextareaHTMLAttributes } from 'react';
2
+ import { ForwardRefExoticComponent, SVGProps, RefAttributes, ReactElement, JSX, ButtonHTMLAttributes, InputHTMLAttributes, RefObject, PropsWithChildren, ReactNode, AnchorHTMLAttributes, MouseEvent, Ref, DetailedHTMLProps, TextareaHTMLAttributes, FocusEvent } from 'react';
3
3
  import { BorderColorClass } from './theme.cjs';
4
4
  export { BackgroundColorClass, CubeThemeName, CubeThemeProvider, CubeThemeProviderProps, FillColorClass, StrokeColorClass, TextColorClass, Typography, TypographyClassName, cubePreset, cubeTheme, getTypography } from './theme.cjs';
5
5
  import { useTranslation } from 'react-i18next';
@@ -121,6 +121,84 @@ declare const CubeCheckbox: {
121
121
  Grid: (props: CubeCheckboxGridProps) => react.JSX.Element;
122
122
  };
123
123
 
124
+ declare const cubeDropdownSizes: readonly ["sm", "md"];
125
+ declare const cubeDropdownTypes: readonly ["radio", "checkbox"];
126
+ declare const cubeDropdownVariants: readonly ["regular", "withFilter"];
127
+ type CubeDropdownSize = (typeof cubeDropdownSizes)[number];
128
+ type CubeDropdownType = (typeof cubeDropdownTypes)[number];
129
+ type CubeDropdownVariant = (typeof cubeDropdownVariants)[number];
130
+ type OnAllCheckChange = (checked: boolean) => void;
131
+ type OnClearSelection = () => void;
132
+ type CubeDropdownBaseProps<Item> = {
133
+ /**
134
+ * @default 'md'
135
+ */
136
+ size?: CubeDropdownSize;
137
+ type: CubeDropdownType;
138
+ /**
139
+ * @default "regular"
140
+ */
141
+ variant?: CubeDropdownVariant;
142
+ selectedItems: Item[];
143
+ /**
144
+ * @default false
145
+ */
146
+ isLoading?: boolean;
147
+ /**
148
+ * @default false
149
+ */
150
+ disabled?: boolean;
151
+ label?: string;
152
+ skeletonClassName?: string;
153
+ children: ReactNode;
154
+ };
155
+ type CheckboxPropsWithFilter<Item> = CubeDropdownBaseProps<Item> & {
156
+ type: 'checkbox';
157
+ variant: 'withFilter';
158
+ onAllCheckChange: OnAllCheckChange;
159
+ onClearSelection: OnClearSelection;
160
+ };
161
+ type CheckboxPropsRegular<Item> = CubeDropdownBaseProps<Item> & {
162
+ type: 'checkbox';
163
+ variant?: Exclude<CubeDropdownVariant, 'withFilter'>;
164
+ onAllCheckChange: OnAllCheckChange;
165
+ onClearSelection?: never;
166
+ };
167
+ type RadioProps<Item> = CubeDropdownBaseProps<Item> & {
168
+ type: 'radio';
169
+ variant?: CubeDropdownVariant;
170
+ onAllCheckChange?: never;
171
+ onClearSelection?: never;
172
+ };
173
+ type CubeDropdownProps<Item> = CheckboxPropsWithFilter<Item> | CheckboxPropsRegular<Item> | RadioProps<Item>;
174
+
175
+ type CubeDropdownItemProps<Item> = {
176
+ children: string;
177
+ item: Item;
178
+ /**
179
+ * @default false
180
+ */
181
+ disabled?: boolean;
182
+ onClick: () => void;
183
+ };
184
+
185
+ type CubeDropdownMenuProps = {
186
+ children: ReactNode;
187
+ className?: string;
188
+ };
189
+
190
+ type CubeDropdownTriggerProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled'> & {
191
+ children?: string;
192
+ placeholder?: string;
193
+ };
194
+
195
+ declare const CubeDropdown: {
196
+ <Item>(props: CubeDropdownProps<Item>): react.JSX.Element;
197
+ Trigger: (props: CubeDropdownTriggerProps) => react.JSX.Element;
198
+ Menu: (props: CubeDropdownMenuProps) => react.ReactPortal;
199
+ Item: <Item>(props: CubeDropdownItemProps<Item>) => react.JSX.Element;
200
+ };
201
+
124
202
  type PropsWithClassName = {
125
203
  className?: string | undefined;
126
204
  };
@@ -204,6 +282,97 @@ type CubeLoadingSpinnerProps = PropsWithClassName & {
204
282
 
205
283
  declare const CubeLoadingSpinner: (props: CubeLoadingSpinnerProps) => react.JSX.Element;
206
284
 
285
+ type CubeToggleProps = PropsWithClassName & {
286
+ /**
287
+ * Whether the toggle is on. Always controlled by the caller —
288
+ * pair with `onCheckedChange` to update this value when the user toggles.
289
+ */
290
+ checked: boolean;
291
+ /**
292
+ * Called with the next on/off value when the user toggles. Required so the
293
+ * caller can update `checked`.
294
+ */
295
+ onCheckedChange: (checked: boolean) => void;
296
+ /**
297
+ * Visible text shown next to the toggle. Also provides the accessible name
298
+ * via `aria-labelledby` / `<label htmlFor>`.
299
+ */
300
+ label?: string;
301
+ /**
302
+ * Accessible name when no visible `label` is rendered. Prefer `label` when
303
+ * the name should also appear on screen.
304
+ */
305
+ 'aria-label'?: string;
306
+ /**
307
+ * When true, the toggle cannot be interacted with.
308
+ * @default false
309
+ */
310
+ disabled?: boolean;
311
+ };
312
+ declare const CubeToggle: (props: CubeToggleProps) => react.JSX.Element;
313
+
314
+ declare const cubeOverflowMenuItemTypes: readonly ["plain", "menu-icon", "check-mark", "toggle", "trailing-icon", "custom-leading-element"];
315
+ type CubeOverflowMenuItemType = (typeof cubeOverflowMenuItemTypes)[number];
316
+ type CubeOverflowMenuTriggerProps = {
317
+ ref?: Ref<HTMLElement>;
318
+ onClick?: (e: MouseEvent<HTMLElement>) => void;
319
+ };
320
+ type CubeOverflowMenuProps = {
321
+ /**
322
+ * The element that toggles the menu. It receives a `ref` and an `onClick`;
323
+ * its own `ref` and `onClick` are still called.
324
+ */
325
+ triggerElement: ReactElement<CubeOverflowMenuTriggerProps>;
326
+ children: ReactNode;
327
+ };
328
+ type ClickableItemProps = {
329
+ /**
330
+ * @default false
331
+ */
332
+ disabled?: boolean;
333
+ onClick?: () => void;
334
+ };
335
+ type PlainItem = {
336
+ type: 'plain';
337
+ } & ClickableItemProps;
338
+ type ItemWithMenuIcon = {
339
+ type: 'menu-icon';
340
+ MenuIcon: SvgComponent;
341
+ } & ClickableItemProps;
342
+ type ItemWithCheckMark = {
343
+ type: 'check-mark';
344
+ isChecked: boolean;
345
+ } & ClickableItemProps;
346
+ type ItemWithToggle = {
347
+ type: 'toggle';
348
+ } & Pick<CubeToggleProps, 'checked'> & Partial<Pick<CubeToggleProps, 'onCheckedChange'>> & ClickableItemProps;
349
+ type ItemWithTrailingIcon = {
350
+ type: 'trailing-icon';
351
+ TrailingIcon: SvgComponent;
352
+ } & ClickableItemProps;
353
+ type ItemWithCustomLeadingElement = {
354
+ type: 'custom-leading-element';
355
+ element: ReactNode;
356
+ } & ClickableItemProps;
357
+ type CubeOverflowMenuItemProps = {
358
+ title: string;
359
+ /**
360
+ * @default false
361
+ */
362
+ boldTitle?: boolean;
363
+ subText?: string;
364
+ } & (PlainItem | ItemWithMenuIcon | ItemWithCheckMark | ItemWithToggle | ItemWithTrailingIcon | ItemWithCustomLeadingElement);
365
+ type CubeOverflowMenuTitleProps = {
366
+ children: string;
367
+ };
368
+
369
+ declare const CubeOverflowMenu: {
370
+ (props: CubeOverflowMenuProps): react.JSX.Element;
371
+ Item: (props: CubeOverflowMenuItemProps) => react.JSX.Element;
372
+ Divider: () => react.JSX.Element;
373
+ Title: (props: CubeOverflowMenuTitleProps) => react.JSX.Element;
374
+ };
375
+
207
376
  type CubePasswordInputProps = Omit<CubeInputProps, 'trailingIcon' | 'type'> & {
208
377
  /**
209
378
  * @default false
@@ -237,6 +406,68 @@ type CubeSkeletonProps = PropsWithClassName & {
237
406
  };
238
407
  declare const CubeSkeleton: (props: CubeSkeletonProps) => react.JSX.Element;
239
408
 
409
+ declare const cubeStatusKnownValues: readonly ["neutral", "in-use", "finished", "ok", "success", "active", "available", "powering on", "warning", "error", "fail", "failed", "stopped", "powering off"];
410
+ declare const cubeStatusTypes: readonly ["neutral", "success", "warning", "others"];
411
+ type CubeStatusKnownValue = (typeof cubeStatusKnownValues)[number];
412
+ type CubeStatusValue = (string & {}) | CubeStatusKnownValue;
413
+ type CubeStatusType = (typeof cubeStatusTypes)[number];
414
+ type CubeStatusProps = {
415
+ status: CubeStatusValue;
416
+ /**
417
+ * Custom display text for the status text.
418
+ * If not specified, the text will be automatically generated
419
+ * based on the built-in logic and i18n translations.
420
+ */
421
+ message?: string;
422
+ };
423
+
424
+ declare const CubeStatus: {
425
+ (props: CubeStatusProps): react.JSX.Element;
426
+ Skeleton: () => react.JSX.Element;
427
+ };
428
+
429
+ declare const cubeStatusReactionStatuses: readonly ["neutral", "success", "available", "done", "error", "duplicate", "failed"];
430
+ declare const cubeStatusReactionTypes: readonly ["neutral", "success", "warning"];
431
+ type CubeStatusReactionStatus = (typeof cubeStatusReactionStatuses)[number];
432
+ type CubeStatusReactionType = (typeof cubeStatusReactionTypes)[number];
433
+ type CubeStatusReactionProps = {
434
+ status: CubeStatusReactionStatus;
435
+ message?: string;
436
+ };
437
+
438
+ declare const CubeStatusReaction: {
439
+ (props: CubeStatusReactionProps): react.JSX.Element;
440
+ Skeleton: () => react.JSX.Element;
441
+ };
442
+
443
+ declare const CubeStepProcessItem: (props: CubeStepProcessItemProps) => react.JSX.Element;
444
+
445
+ type CubeStepProcessProps = PropsWithClassName & {
446
+ isLoading?: boolean;
447
+ children?: ReactElement<typeof CubeStepProcessItem>[] | ReactElement<typeof CubeStepProcessItem>;
448
+ };
449
+ type CubeStepProcessItemProps = {
450
+ /**
451
+ * The step serial number (1-based) that represents this step in the process.
452
+ */
453
+ stepNumber: number;
454
+ label: string;
455
+ isActive: boolean;
456
+ };
457
+
458
+ type CubeStepProcessSkeletonProps = {
459
+ /**
460
+ * @default 5
461
+ */
462
+ length?: number;
463
+ };
464
+
465
+ declare const CubeStepProcess: {
466
+ (props: CubeStepProcessProps): react.JSX.Element;
467
+ Item: (props: CubeStepProcessItemProps) => react.JSX.Element;
468
+ Skeleton: (props: CubeStepProcessSkeletonProps) => react.JSX.Element;
469
+ };
470
+
240
471
  declare const cubeStrokeTypes: readonly ["regular", "dot"];
241
472
  type CubeStrokeType = (typeof cubeStrokeTypes)[number];
242
473
  type CubeStrokeProps = PropsWithClassName & {
@@ -329,38 +560,67 @@ declare const CubeTextarea: {
329
560
  Skeleton: () => react.JSX.Element;
330
561
  };
331
562
 
332
- type CubeToggleProps = PropsWithClassName & {
333
- /**
334
- * Whether the toggle is on. Always controlled by the caller —
335
- * pair with `onCheckedChange` to update this value when the user toggles.
336
- */
337
- checked: boolean;
338
- /**
339
- * Called with the next on/off value when the user toggles. Required so the
340
- * caller can update `checked`.
341
- */
342
- onCheckedChange: (checked: boolean) => void;
563
+ declare const cubeTooltipPlacements: readonly ["top-left", "top-center", "top-right", "top-follow-cursor", "bottom-left", "bottom-center", "bottom-right", "bottom-follow-cursor"];
564
+ type CubeTooltipPlacement = (typeof cubeTooltipPlacements)[number];
565
+ type CubeTooltipInteractiveElementProps = {
566
+ ref?: Ref<HTMLElement>;
567
+ onMouseEnter?: (e: MouseEvent<HTMLElement>) => void;
568
+ onMouseMove?: (e: MouseEvent<HTMLElement>) => void;
569
+ onMouseLeave?: (e: MouseEvent<HTMLElement>) => void;
570
+ onClick?: (e: MouseEvent<HTMLElement>) => void;
571
+ onFocus?: (e: FocusEvent<HTMLElement>) => void;
572
+ onBlur?: (e: FocusEvent<HTMLElement>) => void;
573
+ 'aria-describedby'?: string;
574
+ };
575
+ type CubeTooltipInformation = {
576
+ title?: string;
577
+ subtext?: string;
578
+ message: string;
579
+ };
580
+ type CubeTooltipProps = {
343
581
  /**
344
- * Visible text shown next to the toggle. Also provides the accessible name
345
- * via `aria-labelledby` / `<label htmlFor>`.
582
+ * @default 'top-center'
346
583
  */
347
- label?: string;
584
+ placement?: CubeTooltipPlacement;
585
+ hoverContent?: CubeTooltipInformation;
586
+ clickContent?: CubeTooltipInformation;
348
587
  /**
349
- * Accessible name when no visible `label` is rendered. Prefer `label` when
350
- * the name should also appear on screen.
588
+ * The toggle (anchor) element. Hover content is also shown while it has
589
+ * keyboard focus, so pass a focusable element (e.g. a `<button>`) to make
590
+ * the tooltip reachable by keyboard.
351
591
  */
352
- 'aria-label'?: string;
353
- /**
354
- * When true, the toggle cannot be interacted with.
355
- * @default false
356
- */
357
- disabled?: boolean;
592
+ children: ReactElement<CubeTooltipInteractiveElementProps>;
358
593
  };
359
- declare const CubeToggle: (props: CubeToggleProps) => react.JSX.Element;
594
+
595
+ declare const CubeTooltip: (props: CubeTooltipProps) => react.JSX.Element;
360
596
 
361
597
  var enUS = {
362
598
  "component.common.loading": "Loading",
363
- "component.common.noData": "No Data"
599
+ "component.common.noData": "No Data",
600
+ "component.dropdown.choose": "Choose",
601
+ "component.dropdown.all": "All",
602
+ "component.dropdown.search": "Search",
603
+ "component.status.host.neutral": "Neutral",
604
+ "component.status.host.inUse": "In-Use",
605
+ "component.status.host.finished": "Finished",
606
+ "component.status.host.ok": "Ok",
607
+ "component.status.host.success": "Success",
608
+ "component.status.host.active": "Active",
609
+ "component.status.host.available": "Available",
610
+ "component.status.host.poweringOn": "Powering-On",
611
+ "component.status.host.warning": "Warning",
612
+ "component.status.host.error": "Error",
613
+ "component.status.host.fail": "Fail",
614
+ "component.status.host.failed": "Failed",
615
+ "component.status.host.stopped": "Stopped",
616
+ "component.status.host.poweringOff": "Powering-Off",
617
+ "component.status.reaction.neutral": "Neutral",
618
+ "component.status.reaction.success": "Success",
619
+ "component.status.reaction.available": "Available",
620
+ "component.status.reaction.done": "Done",
621
+ "component.status.reaction.error": "Error",
622
+ "component.status.reaction.duplicate": "Duplicate",
623
+ "component.status.reaction.failed": "Failed"
364
624
  };
365
625
 
366
626
  /**
@@ -412,4 +672,4 @@ declare const CubeUiLocaleProvider: (props: CubeUiLocaleProviderProps) => react.
412
672
  */
413
673
  declare const useCubeUiTranslation: typeof useTranslation;
414
674
 
415
- export { BorderColorClass, CubeButton, type CubeButtonProps, type CubeButtonSize, type CubeButtonSkeletonProps, type CubeButtonType, type CubeButtonUsage, CubeCheckbox, type CubeCheckboxColor, type CubeCheckboxGridDirection, type CubeCheckboxGridProps, type CubeCheckboxLabelSize, type CubeCheckboxProps, CubeHyperlink, type CubeHyperlinkColor, type CubeHyperlinkProps, type CubeHyperlinkSize, type CubeHyperlinkVariant, CubeIconFrame, type CubeIconFrameProps, type CubeIconSize, CubeInput, type CubeInputProps, type CubeInputSkeletonProps, CubeLoadingSpinner, type CubeLoadingSpinnerProps, type CubeLoadingSpinnerVariant, CubePasswordInput, type CubePasswordInputProps, CubeRadioButton, type CubeRadioButtonGridDirection, type CubeRadioButtonGridProps, type CubeRadioButtonProps, CubeSkeleton, type CubeSkeletonProps, CubeStroke, type CubeStrokeProps, type CubeStrokeType, type CubeTabProps, CubeTabs, type CubeTabsProps, CubeTag, type CubeTagColor, type CubeTagProps, type CubeTagSkeletonProps, type CubeTagVariant, CubeTextarea, type CubeTextareaProps, CubeToggle, type CubeToggleProps, type CubeUiLocale, CubeUiLocaleProvider, type CubeUiLocaleProviderProps, type CubeUiTranslationResource, type SvgComponent, type SvgElement, addCubeUiTranslations, useCubeUiTranslation };
675
+ export { BorderColorClass, CubeButton, type CubeButtonProps, type CubeButtonSize, type CubeButtonSkeletonProps, type CubeButtonType, type CubeButtonUsage, CubeCheckbox, type CubeCheckboxColor, type CubeCheckboxGridDirection, type CubeCheckboxGridProps, type CubeCheckboxLabelSize, type CubeCheckboxProps, CubeDropdown, type CubeDropdownItemProps, type CubeDropdownMenuProps, type CubeDropdownProps, type CubeDropdownSize, type CubeDropdownTriggerProps, type CubeDropdownType, type CubeDropdownVariant, CubeHyperlink, type CubeHyperlinkColor, type CubeHyperlinkProps, type CubeHyperlinkSize, type CubeHyperlinkVariant, CubeIconFrame, type CubeIconFrameProps, type CubeIconSize, CubeInput, type CubeInputProps, type CubeInputSkeletonProps, CubeLoadingSpinner, type CubeLoadingSpinnerProps, type CubeLoadingSpinnerVariant, CubeOverflowMenu, type CubeOverflowMenuItemProps, type CubeOverflowMenuItemType, type CubeOverflowMenuProps, type CubeOverflowMenuTitleProps, type CubeOverflowMenuTriggerProps, CubePasswordInput, type CubePasswordInputProps, CubeRadioButton, type CubeRadioButtonGridDirection, type CubeRadioButtonGridProps, type CubeRadioButtonProps, CubeSkeleton, type CubeSkeletonProps, CubeStatus, type CubeStatusKnownValue, type CubeStatusProps, CubeStatusReaction, type CubeStatusReactionProps, type CubeStatusReactionStatus, type CubeStatusReactionType, type CubeStatusType, type CubeStatusValue, CubeStepProcess, type CubeStepProcessItemProps, type CubeStepProcessProps, type CubeStepProcessSkeletonProps, CubeStroke, type CubeStrokeProps, type CubeStrokeType, type CubeTabProps, CubeTabs, type CubeTabsProps, CubeTag, type CubeTagColor, type CubeTagProps, type CubeTagSkeletonProps, type CubeTagVariant, CubeTextarea, type CubeTextareaProps, CubeToggle, type CubeToggleProps, CubeTooltip, type CubeTooltipInformation, type CubeTooltipInteractiveElementProps, type CubeTooltipPlacement, type CubeTooltipProps, type CubeUiLocale, CubeUiLocaleProvider, type CubeUiLocaleProviderProps, type CubeUiTranslationResource, type OnAllCheckChange, type OnClearSelection, type SvgComponent, type SvgElement, addCubeUiTranslations, useCubeUiTranslation };