chop-logic-components 0.4.0 → 0.6.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.
Files changed (47) hide show
  1. package/dist/components/{button → controls/button}/Button.d.ts +3 -2
  2. package/dist/components/{button → controls/button}/__docs__/Button.stories.d.ts +1 -1
  3. package/dist/components/elements/portal/Portal.d.ts +6 -0
  4. package/dist/components/index.d.ts +3 -1
  5. package/dist/components/inputs/checkbox/__docs__/Checkbox.stories.d.ts +1 -1
  6. package/dist/components/inputs/multi-select/__docs__/MultiSelect.stories.d.ts +1 -1
  7. package/dist/components/inputs/select/__docs__/Select.stories.d.ts +1 -1
  8. package/dist/components/inputs/text/__docs__/TextInput.stories.d.ts +1 -1
  9. package/dist/components/modals/dialog/Dialog.d.ts +9 -0
  10. package/dist/components/modals/dialog/__docs__/Dialog.stories.d.ts +7 -0
  11. package/dist/components/modals/dialog/__docs__/DialogExample.d.ts +5 -0
  12. package/dist/components/modals/dialog/elements/Header.d.ts +8 -0
  13. package/dist/components/modals/dialog/elements/Layout.d.ts +9 -0
  14. package/dist/components/modals/tooltip/Tooltip.d.ts +10 -0
  15. package/dist/components/modals/tooltip/__docs__/Tooltip.stories.d.ts +10 -0
  16. package/dist/components/modals/tooltip/__docs__/TooltipExample.d.ts +5 -0
  17. package/dist/components/modals/tooltip/__tests__/Tooltip.test.d.ts +1 -0
  18. package/dist/hooks/__tests__/use-click-outside.test.d.ts +1 -0
  19. package/dist/hooks/__tests__/use-key-press.test.d.ts +1 -0
  20. package/dist/hooks/__tests__/use-modal-focus.test.d.ts +1 -0
  21. package/dist/hooks/__tests__/use-mount.test.d.ts +1 -0
  22. package/dist/hooks/__tests__/use-window-dimensions.test.d.ts +1 -0
  23. package/dist/hooks/index.d.ts +7 -0
  24. package/dist/{utils → hooks}/use-click-outside.d.ts +2 -5
  25. package/dist/hooks/use-container-dimensions.d.ts +8 -0
  26. package/dist/hooks/use-key-press.d.ts +9 -0
  27. package/dist/hooks/use-modal-focus-trap.d.ts +6 -0
  28. package/dist/hooks/use-mount.d.ts +1 -0
  29. package/dist/hooks/use-tooltip-position.d.ts +11 -0
  30. package/dist/hooks/use-window-dimensions.d.ts +5 -0
  31. package/dist/index.cjs.js +183 -10
  32. package/dist/index.cjs.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.es.js +20331 -626
  35. package/dist/index.es.js.map +1 -1
  36. package/dist/style.css +1 -1
  37. package/dist/utils/__tests__/move-focus-on-element-by-id.test.d.ts +1 -0
  38. package/package.json +11 -10
  39. /package/dist/components/{button/__docs__/Example.d.ts → controls/button/__docs__/ButtonExample.d.ts} +0 -0
  40. /package/dist/components/{button → controls/button}/__tests__/Button.test.d.ts +0 -0
  41. /package/dist/components/{misc → elements}/error-message/ErrorMessage.d.ts +0 -0
  42. /package/dist/components/{misc → elements}/label/Label.d.ts +0 -0
  43. /package/dist/components/inputs/checkbox/__docs__/{Example.d.ts → CheckboxExample.d.ts} +0 -0
  44. /package/dist/components/inputs/multi-select/__docs__/{Example.d.ts → MultiSelectExample.d.ts} +0 -0
  45. /package/dist/components/inputs/select/__docs__/{Example.d.ts → SelectExample.d.ts} +0 -0
  46. /package/dist/components/inputs/text/__docs__/{Example.d.ts → TextInputExample.d.ts} +0 -0
  47. /package/dist/{utils/__tests__/use-click-outside.test.d.ts → components/modals/dialog/__tests__/Dialog.test.d.ts} +0 -0
@@ -1,12 +1,13 @@
1
- import { Icon } from '../../../../../../../../src/enums/icon';
1
+ import { Icon } from '../../../../../../../../../src/enums/icon';
2
2
  import { default as React, MouseEventHandler } from 'react';
3
3
 
4
4
  export type ChopLogicButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
5
5
  text?: string;
6
6
  onClick?: MouseEventHandler<HTMLButtonElement> | (() => void);
7
- view?: 'primary' | 'secondary' | 'danger';
7
+ view?: 'primary' | 'secondary' | 'danger' | 'icon';
8
8
  disabled?: boolean;
9
9
  icon?: Icon;
10
+ label?: string;
10
11
  };
11
12
  declare const Button: React.FC<ChopLogicButtonProps>;
12
13
  export default Button;
@@ -1,4 +1,4 @@
1
- import { default as ExampleButton } from './Example';
1
+ import { default as ExampleButton } from './ButtonExample';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  declare const meta: Meta<typeof ExampleButton>;
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const ChopLogicPortal: ({ children }: {
4
+ children: React.ReactElement;
5
+ }) => React.ReactPortal;
6
+ export default ChopLogicPortal;
@@ -1,4 +1,6 @@
1
- export { default as ChopLogicButton } from './button/Button';
1
+ export { default as ChopLogicButton } from './controls/button/Button';
2
2
  export { default as ChopLogicTextInput } from './inputs/text/TextInput';
3
3
  export { default as ChopLogicSelect } from './inputs/select/Select';
4
4
  export { default as ChopLogicCheckbox } from './inputs/checkbox/Checkbox';
5
+ export { default as ChopLogicDialog } from './modals/dialog/Dialog';
6
+ export { default as ChopLogicTooltip } from './modals/tooltip/Tooltip';
@@ -1,4 +1,4 @@
1
- import { default as Example } from './Example';
1
+ import { default as Example } from './CheckboxExample';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  declare const meta: Meta<typeof Example>;
@@ -1,4 +1,4 @@
1
- import { default as Example } from './Example';
1
+ import { default as Example } from './MultiSelectExample';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  declare const meta: Meta<typeof Example>;
@@ -1,4 +1,4 @@
1
- import { default as Example } from './Example';
1
+ import { default as Example } from './SelectExample';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  declare const meta: Meta<typeof Example>;
@@ -1,4 +1,4 @@
1
- import { default as Example } from './Example';
1
+ import { default as Example } from './TextInputExample';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
 
4
4
  declare const meta: Meta<typeof Example>;
@@ -0,0 +1,9 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ export type ChopLogicModalProps = PropsWithChildren & React.HTMLAttributes<HTMLDivElement> & {
4
+ isOpened: boolean;
5
+ onClose: () => void;
6
+ title: string;
7
+ };
8
+ declare const ChopLogicDialog: React.FC<ChopLogicModalProps>;
9
+ export default ChopLogicDialog;
@@ -0,0 +1,7 @@
1
+ import { default as Example } from './DialogExample';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+
4
+ declare const meta: Meta<typeof Example>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof Example>;
7
+ export declare const Default: Story;
@@ -0,0 +1,5 @@
1
+ import { ChopLogicModalProps } from '../Dialog';
2
+ import { default as React } from 'react';
3
+
4
+ declare const Example: React.FC<ChopLogicModalProps>;
5
+ export default Example;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+
3
+ type ChopLogicModalLayoutHeaderProps = {
4
+ title: string;
5
+ onClose: () => void;
6
+ };
7
+ declare const ChopLogicModalLayoutHeader: React.FC<ChopLogicModalLayoutHeaderProps>;
8
+ export default ChopLogicModalLayoutHeader;
@@ -0,0 +1,9 @@
1
+ import { default as React, PropsWithChildren } from 'react';
2
+
3
+ type ModalLayoutProps = PropsWithChildren & React.HTMLAttributes<HTMLDivElement> & {
4
+ title: string;
5
+ onClose: () => void;
6
+ isOpened: boolean;
7
+ };
8
+ declare const ChopLogicModalLayout: React.FC<ModalLayoutProps>;
9
+ export default ChopLogicModalLayout;
@@ -0,0 +1,10 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ export type ChopLogicTooltipProps = PropsWithChildren & React.HTMLAttributes<HTMLElement> & {
4
+ tooltipContent: string | React.ReactElement;
5
+ id: string;
6
+ containerTag?: 'span' | 'div' | 'p' | 'strong' | 'em';
7
+ visibleOn?: 'hover' | 'click' | 'focus' | 'contextmenu';
8
+ };
9
+ declare const ChopLogicTooltip: React.FC<ChopLogicTooltipProps>;
10
+ export default ChopLogicTooltip;
@@ -0,0 +1,10 @@
1
+ import { default as TooltipExample } from './TooltipExample';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+
4
+ declare const meta: Meta<typeof TooltipExample>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof TooltipExample>;
7
+ export declare const Default: Story;
8
+ export declare const ClickToShow: Story;
9
+ export declare const FocusToShow: Story;
10
+ export declare const ContextMenuToShow: Story;
@@ -0,0 +1,5 @@
1
+ import { ChopLogicTooltipProps } from '../Tooltip';
2
+ import { default as React } from 'react';
3
+
4
+ declare const TooltipExample: React.FC<ChopLogicTooltipProps>;
5
+ export default TooltipExample;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export { useMount } from './use-mount';
2
+ export { useClickOutside } from './use-click-outside';
3
+ export { useModalFocusTrap } from './use-modal-focus-trap';
4
+ export { useKeyPress } from './use-key-press';
5
+ export { useContainerDimensions } from './use-container-dimensions';
6
+ export { useWindowDimensions } from './use-window-dimensions';
7
+ export { useTooltipPosition } from './use-tooltip-position';
@@ -1,12 +1,9 @@
1
1
  import { default as React } from 'react';
2
2
 
3
- /**
4
- * Hook that handles clicks outside of the passed ref
5
- */
6
3
  type UseClickOutsideParams = {
7
- ref: React.MutableRefObject<any>;
4
+ ref: React.RefObject<HTMLDivElement>;
8
5
  onClickOutsideHandler: () => void;
9
- dependentRef?: React.MutableRefObject<any>;
6
+ dependentRef?: React.RefObject<HTMLDivElement>;
10
7
  };
11
8
  export declare const useClickOutside: ({ ref, onClickOutsideHandler, dependentRef }: UseClickOutsideParams) => void;
12
9
  export {};
@@ -0,0 +1,8 @@
1
+ import { Dimensions } from './use-window-dimensions';
2
+
3
+ type useContainerDimensionsParams = {
4
+ ref: React.RefObject<HTMLDivElement | HTMLSpanElement>;
5
+ isVisible?: boolean;
6
+ };
7
+ export declare const useContainerDimensions: ({ ref, isVisible }: useContainerDimensionsParams) => Dimensions;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+
3
+ type useKeyPressParams = {
4
+ keyCode: string;
5
+ ref: React.RefObject<HTMLDivElement>;
6
+ onKeyPress: () => void;
7
+ };
8
+ export declare const useKeyPress: ({ ref, keyCode, onKeyPress }: useKeyPressParams) => void;
9
+ export {};
@@ -0,0 +1,6 @@
1
+ type ModalFocusTrapParams = {
2
+ modalRef: React.RefObject<HTMLDivElement>;
3
+ isOpened: boolean;
4
+ };
5
+ export declare const useModalFocusTrap: ({ modalRef, isOpened }: ModalFocusTrapParams) => void;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useMount: (isOpened: boolean, delay?: number) => boolean;
@@ -0,0 +1,11 @@
1
+ type useTooltipPositionParams = {
2
+ wrapperRef: React.RefObject<HTMLSpanElement | HTMLDivElement>;
3
+ tooltipRef: React.RefObject<HTMLSpanElement | HTMLDivElement>;
4
+ isOpened: boolean;
5
+ spacing?: number;
6
+ };
7
+ export declare const useTooltipPosition: ({ wrapperRef, tooltipRef, isOpened, spacing }: useTooltipPositionParams) => {
8
+ top: number;
9
+ left: number;
10
+ };
11
+ export {};
@@ -0,0 +1,5 @@
1
+ export type Dimensions = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ export declare function useWindowDimensions(): Dimensions;