@abgov/react-components 4.0.0-alpha.1 → 4.0.0-alpha.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.d.ts CHANGED
@@ -8,6 +8,7 @@ import { GoAButton } from './lib/button/button';
8
8
  import { GoAButtonGroup } from './lib/button-group/button-group';
9
9
  import { GoACallout } from './lib/callout/callout';
10
10
  import { GoACheckbox } from './lib/checkbox/checkbox';
11
+ import { GoAChip } from './lib/chip/chip';
11
12
  import { GoACircularProgress } from './lib/circular-progress/circular-progress';
12
13
  import { GoAContainer } from './lib/container/container';
13
14
  import { GoADropdown, GoADropdownOption } from './lib/dropdown/dropdown';
@@ -29,4 +30,4 @@ import type { GoAIconType } from './lib/icons';
29
30
  import type { GoABadgeType } from './lib/badge/badge';
30
31
  export type { GoAIconType };
31
32
  export type { GoABadgeType };
32
- export { GoAAppHeader, GoABadge, GoAButton, GoAButtonGroup, GoACallout, GoACheckbox, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownOption, GoAEmergencyBadge, GoAFlexRow, GoAFormItem, GoAHeroBanner, GoAHeroBannerActions, GoAIcon, GoAIconButton, GoAInfoBadge, GoAInput, GoAInputDate, GoAInputDateTime, GoAInputEmail, GoAInputFile, GoAInputMonth, GoAInputNumber, GoAInputPassword, GoAInputRange, GoAInputSearch, GoAInputTel, GoAInputText, GoAInputTime, GoAInputUrl, GoAMicrositeHeader, GoAModal, GoANotification, GoAPageBlock, GoARadioGroup, GoARadioItem, GoASkeleton, GoASpinner, GoASuccessBadge, GoATextArea, GoAWarningBadge, };
33
+ export { GoAAppHeader, GoABadge, GoAButton, GoAButtonGroup, GoACallout, GoACheckbox, GoAChip, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownOption, GoAEmergencyBadge, GoAFlexRow, GoAFormItem, GoAHeroBanner, GoAHeroBannerActions, GoAIcon, GoAIconButton, GoAInfoBadge, GoAInput, GoAInputDate, GoAInputDateTime, GoAInputEmail, GoAInputFile, GoAInputMonth, GoAInputNumber, GoAInputPassword, GoAInputRange, GoAInputSearch, GoAInputTel, GoAInputText, GoAInputTime, GoAInputUrl, GoAMicrositeHeader, GoAModal, GoANotification, GoAPageBlock, GoARadioGroup, GoARadioItem, GoASkeleton, GoASpinner, GoASuccessBadge, GoATextArea, GoAWarningBadge, };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ interface WCProps {
3
+ ref: React.RefObject<HTMLElement>;
4
+ leadingicon: string;
5
+ error: boolean;
6
+ deletable: boolean;
7
+ content: string;
8
+ }
9
+ declare global {
10
+ namespace JSX {
11
+ interface IntrinsicElements {
12
+ 'goa-chip': WCProps & React.HTMLAttributes<HTMLElement>;
13
+ }
14
+ }
15
+ }
16
+ export interface Props {
17
+ onDeleteIconClick?: () => void;
18
+ leadingIcon?: string;
19
+ error?: boolean;
20
+ content: string;
21
+ }
22
+ export declare const GoAChip: ({ leadingIcon, error, content, onDeleteIconClick }: Props) => JSX.Element;
23
+ export default GoAChip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/react-components",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.2",
4
4
  "description": "Government of Alberta - UI components for React",
5
5
  "bugs": {
6
6
  "url": "https://github.com/GovAlta/ui-components/issues"
@@ -213,6 +213,36 @@ const GoACheckbox = ({
213
213
  }), void 0);
214
214
  };
215
215
 
216
+ const GoAChip = ({
217
+ leadingIcon: _leadingIcon = "",
218
+ error: _error = false,
219
+ content,
220
+ onDeleteIconClick
221
+ }) => {
222
+ const el = useRef(null);
223
+ useEffect(() => {
224
+ if (!el.current) return;
225
+ if (!onDeleteIconClick) return;
226
+ const current = el.current;
227
+
228
+ const listener = e => {
229
+ onDeleteIconClick();
230
+ };
231
+
232
+ current.addEventListener('_onDeleteIconClick', listener);
233
+ return () => {
234
+ current.removeEventListener('_onDeleteIconClick', listener);
235
+ };
236
+ }, [el, onDeleteIconClick]);
237
+ return jsx("goa-chip", {
238
+ ref: el,
239
+ leadingicon: _leadingIcon,
240
+ error: _error,
241
+ deletable: !!onDeleteIconClick,
242
+ content: content
243
+ }, void 0);
244
+ };
245
+
216
246
  const GoACircularProgress = ({
217
247
  type,
218
248
  visible,
@@ -797,4 +827,4 @@ const GoATextArea = ({
797
827
  }, void 0);
798
828
  };
799
829
 
800
- export { GoAAppHeader, GoABadge, GoAButton, GoAButtonGroup, GoACallout, GoACheckbox, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownOption, GoAEmergencyBadge, GoAFlexRow, GoAFormItem, GoAHeroBanner, GoAHeroBannerActions, GoAIcon, GoAIconButton, GoAInfoBadge, GoAInput, GoAInputDate, GoAInputDateTime, GoAInputEmail, GoAInputFile, GoAInputMonth, GoAInputNumber, GoAInputPassword, GoAInputRange, GoAInputSearch, GoAInputTel, GoAInputText, GoAInputTime, GoAInputUrl, GoAMicrositeHeader, GoAModal, GoANotification, GoAPageBlock, GoARadioGroup, GoARadioItem, GoASkeleton, GoASpinner, GoASuccessBadge, GoATextArea, GoAWarningBadge };
830
+ export { GoAAppHeader, GoABadge, GoAButton, GoAButtonGroup, GoACallout, GoACheckbox, GoAChip, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownOption, GoAEmergencyBadge, GoAFlexRow, GoAFormItem, GoAHeroBanner, GoAHeroBannerActions, GoAIcon, GoAIconButton, GoAInfoBadge, GoAInput, GoAInputDate, GoAInputDateTime, GoAInputEmail, GoAInputFile, GoAInputMonth, GoAInputNumber, GoAInputPassword, GoAInputRange, GoAInputSearch, GoAInputTel, GoAInputText, GoAInputTime, GoAInputUrl, GoAMicrositeHeader, GoAModal, GoANotification, GoAPageBlock, GoARadioGroup, GoARadioItem, GoASkeleton, GoASpinner, GoASuccessBadge, GoATextArea, GoAWarningBadge };
@@ -252,6 +252,37 @@
252
252
  }), void 0);
253
253
  };
254
254
 
255
+ var GoAChip = function GoAChip(_a) {
256
+ var _b = _a.leadingIcon,
257
+ leadingIcon = _b === void 0 ? "" : _b,
258
+ _c = _a.error,
259
+ error = _c === void 0 ? false : _c,
260
+ content = _a.content,
261
+ onDeleteIconClick = _a.onDeleteIconClick;
262
+ var el = React.useRef(null);
263
+ React.useEffect(function () {
264
+ if (!el.current) return;
265
+ if (!onDeleteIconClick) return;
266
+ var current = el.current;
267
+
268
+ var listener = function listener(e) {
269
+ onDeleteIconClick();
270
+ };
271
+
272
+ current.addEventListener('_onDeleteIconClick', listener);
273
+ return function () {
274
+ current.removeEventListener('_onDeleteIconClick', listener);
275
+ };
276
+ }, [el, onDeleteIconClick]);
277
+ return jsxRuntime.jsx("goa-chip", {
278
+ ref: el,
279
+ leadingicon: leadingIcon,
280
+ error: error,
281
+ deletable: !!onDeleteIconClick,
282
+ content: content
283
+ }, void 0);
284
+ };
285
+
255
286
  var GoACircularProgress = function GoACircularProgress(_a) {
256
287
  var type = _a.type,
257
288
  visible = _a.visible,
@@ -808,6 +839,7 @@
808
839
  exports.GoAButtonGroup = GoAButtonGroup;
809
840
  exports.GoACallout = GoACallout;
810
841
  exports.GoACheckbox = GoACheckbox;
842
+ exports.GoAChip = GoAChip;
811
843
  exports.GoACircularProgress = GoACircularProgress;
812
844
  exports.GoAContainer = GoAContainer;
813
845
  exports.GoADropdown = GoADropdown;