@bolttech/ob-atoms-backdrop 1.0.1 → 1.0.2

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/index.cjs.js CHANGED
@@ -1,20 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  var classNames = require('classnames');
4
5
  var react = require('react');
5
6
  var reactDom = require('react-dom');
6
7
  var uiUtils = require('@bolttech/ui-utils');
7
- var jsxDevRuntime = require('react/jsx-dev-runtime');
8
-
9
- function _objectWithoutPropertiesLoose(r, e) {
10
- if (null == r) return {};
11
- var t = {};
12
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
13
- if (-1 !== e.indexOf(n)) continue;
14
- t[n] = r[n];
15
- }
16
- return t;
17
- }
18
8
 
19
9
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
20
10
 
@@ -1077,24 +1067,56 @@ $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign },
1077
1067
  assign: assign
1078
1068
  });
1079
1069
 
1080
- const _excluded = ["id", "dataTestId", "onClick", "appendTo", "className", "children"];
1081
- var _jsxFileName = "/home/silas-silva/Documents/projects/bgs-frontend-ui/libs/ob/atoms/backdrop/src/lib/backdrop.tsx";
1082
- const Backdrop = /*#__PURE__*/react.forwardRef((_ref, ref) => {
1083
- let {
1070
+ /******************************************************************************
1071
+ Copyright (c) Microsoft Corporation.
1072
+
1073
+ Permission to use, copy, modify, and/or distribute this software for any
1074
+ purpose with or without fee is hereby granted.
1075
+
1076
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1077
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1078
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1079
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1080
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1081
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1082
+ PERFORMANCE OF THIS SOFTWARE.
1083
+ ***************************************************************************** */
1084
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1085
+
1086
+
1087
+ function __rest(s, e) {
1088
+ var t = {};
1089
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1090
+ t[p] = s[p];
1091
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1092
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1093
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1094
+ t[p[i]] = s[p[i]];
1095
+ }
1096
+ return t;
1097
+ }
1098
+
1099
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1100
+ var e = new Error(message);
1101
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1102
+ };
1103
+
1104
+ const Backdrop = /*#__PURE__*/react.forwardRef((_a, ref) => {
1105
+ var {
1084
1106
  id = 'backdrop-id',
1085
1107
  dataTestId = 'backdrop-data-testid',
1086
1108
  onClick,
1087
1109
  appendTo,
1088
1110
  className,
1089
1111
  children
1090
- } = _ref,
1091
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
1112
+ } = _a,
1113
+ props = __rest(_a, ["id", "dataTestId", "onClick", "appendTo", "className", "children"]);
1092
1114
  const handleClick = event => {
1093
1115
  if (!onClick || event.currentTarget !== event.target) return;
1094
1116
  onClick(event);
1095
1117
  return;
1096
1118
  };
1097
- const backdrop = react.useMemo(() => /*#__PURE__*/jsxDevRuntime.jsxDEV("div", Object.assign({
1119
+ const backdrop = react.useMemo(() => jsxRuntime.jsx("div", Object.assign({
1098
1120
  ref: ref,
1099
1121
  id: id,
1100
1122
  "data-testid": dataTestId,
@@ -1102,11 +1124,7 @@ const Backdrop = /*#__PURE__*/react.forwardRef((_ref, ref) => {
1102
1124
  className: classNames('w-screen h-screen fixed inset-0 bg-black/30 z-4', className)
1103
1125
  }, uiUtils.applyDataAttributes(props), {
1104
1126
  children: children
1105
- }), void 0, false, {
1106
- fileName: _jsxFileName,
1107
- lineNumber: 30,
1108
- columnNumber: 9
1109
- }, undefined), [className, children, onClick, id]);
1127
+ })), [className, children, onClick, id]);
1110
1128
  if (!appendTo) return backdrop;
1111
1129
  return /*#__PURE__*/reactDom.createPortal(backdrop, appendTo);
1112
1130
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/ob-atoms-backdrop",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "dependencies": {
5
5
  "@bolttech/ui-utils": "0.6.7",
6
6
  "react": "19.1.2",
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/backdrop';
@@ -0,0 +1,2 @@
1
+ import { IBackdropProps } from './backdrop.interface';
2
+ export declare const Backdrop: import("react").ForwardRefExoticComponent<IBackdropProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,37 @@
1
+ import { DefaultProps } from '@bolttech/ui-utils';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * @interface IBackdropProps Backdrop component props
5
+ * @property {string | undefined} id - component identification
6
+ * @property {string | undefined} dataTestId - react-testing-library identification
7
+ * @property {HTMLElement | undefined} appendTo - html element reference that the backdrop will be attached to using react portal
8
+ * @property {function | undefined} onClick - function that will run when user clicks on backdrop
9
+ * @property {string | undefined} className - classname for allowing customization
10
+ * @property {string | React.ReactElement | React.ReactElement[] | undefined} children - children component that will render inside the backdrop
11
+ */
12
+ export interface IBackdropProps extends DefaultProps {
13
+ /** Component identification */
14
+ id?: string;
15
+ /** React-testing-library identification */
16
+ dataTestId?: string;
17
+ /** HTML Element reference that the backdrop will be attached to using react portal */
18
+ appendTo?: HTMLElement;
19
+ /** Function that will run when user clicks on backdrop
20
+ *
21
+ * NOTE: this function will not run when clicking on the content of the children component, only when clicking on the `Backdrop`
22
+ *
23
+ *
24
+ * @example
25
+ * ```ts
26
+ *<Backdrop onClick={(event) => setIsOpen(false)}>
27
+ <h1>Backdrop content</h1>
28
+ </Backdrop>
29
+ * ```
30
+ *
31
+ */
32
+ onClick?: (event: React.MouseEvent) => void;
33
+ /** Classname for allowing customization */
34
+ className?: string;
35
+ /** Children component that will render inside the backdrop */
36
+ children?: ReactNode;
37
+ }
@@ -0,0 +1,5 @@
1
+ import type { Meta } from '@storybook/react';
2
+ import { Backdrop } from './backdrop';
3
+ declare const Story: Meta<typeof Backdrop>;
4
+ export default Story;
5
+ export declare const Primary: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./backdrop.interface").IBackdropProps & import("react").RefAttributes<HTMLDivElement>>;