@justfixnyc/component-library 0.60.2 → 0.61.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/README.md +2 -2
- package/dist/src/assets/index.css +642 -6
- package/dist/src/assets/index.es.css +642 -6
- package/dist/src/index.es.js +417 -29
- package/dist/src/index.js +425 -27
- package/dist/typings/Components/Accordion/Accordion.d.ts +11 -0
- package/dist/typings/Components/ButtonStyledLink/ButtonStyledLink.d.ts +15 -0
- package/dist/typings/Components/CalloutBox/CalloutBox.d.ts +9 -0
- package/dist/typings/Components/Dropdown/Dropdown.d.ts +15 -10
- package/dist/typings/Components/GeoSearchDropdown/GeoSearchDropdown.d.ts +53 -0
- package/dist/typings/Components/Heading/Heading.d.ts +8 -0
- package/dist/typings/Components/InfoBox/InfoBox.d.ts +10 -0
- package/dist/typings/Components/LinkStyledButton/LinkStyledButton.d.ts +12 -0
- package/dist/typings/Components/Notice/Notice.d.ts +14 -0
- package/dist/typings/Components/Pill/Pill.d.ts +9 -0
- package/dist/typings/index.d.ts +9 -0
- package/jfcl.scss +235 -2
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var regular = require('@awesome.me/kit-6863e5a21e/icons/classic/regular');
|
|
|
12
12
|
var brands = require('@awesome.me/kit-6863e5a21e/icons/classic/brands');
|
|
13
13
|
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
14
14
|
var custom = require('@awesome.me/kit-6863e5a21e/icons/kit/custom');
|
|
15
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
15
16
|
var Select = require('react-select');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -20,15 +21,16 @@ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
|
20
21
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
21
22
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
22
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
24
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
23
25
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
24
26
|
|
|
25
|
-
const _excluded$
|
|
27
|
+
const _excluded$h = ["className", "icon"];
|
|
26
28
|
const Icon = _ref => {
|
|
27
29
|
let {
|
|
28
30
|
className,
|
|
29
31
|
icon
|
|
30
32
|
} = _ref,
|
|
31
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
33
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$h);
|
|
32
34
|
let faIcon;
|
|
33
35
|
switch (icon) {
|
|
34
36
|
case 'arrowLeft':
|
|
@@ -222,14 +224,14 @@ const Icon = _ref => {
|
|
|
222
224
|
};
|
|
223
225
|
Icon.displayName = 'Icon';
|
|
224
226
|
|
|
225
|
-
const _excluded$
|
|
227
|
+
const _excluded$g = ["icon", "children", "className"];
|
|
226
228
|
const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
227
229
|
let {
|
|
228
230
|
icon,
|
|
229
231
|
children,
|
|
230
232
|
className
|
|
231
233
|
} = _ref,
|
|
232
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
234
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$g);
|
|
233
235
|
const linkClassNames = classNames__default["default"]('jfcl-link', className);
|
|
234
236
|
const opensInNewTab = props.target === '_blank';
|
|
235
237
|
// When using this component within a react-router-dom <Link />, a navigate function is passed through the props us here.
|
|
@@ -255,7 +257,7 @@ const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
255
257
|
});
|
|
256
258
|
Link.displayName = 'Link';
|
|
257
259
|
|
|
258
|
-
const _excluded$
|
|
260
|
+
const _excluded$f = ["type", "variant", "text", "action", "actionHref", "actionLabel", "className"];
|
|
259
261
|
const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
260
262
|
let {
|
|
261
263
|
type = 'info',
|
|
@@ -266,7 +268,7 @@ const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
266
268
|
actionLabel,
|
|
267
269
|
className
|
|
268
270
|
} = _ref,
|
|
269
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
271
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$f);
|
|
270
272
|
const alertClassNames = classNames__default["default"]('jfcl-alert', "jfcl-variant-".concat(variant), "jfcl-type-".concat(type), className);
|
|
271
273
|
const hasAction = !!action;
|
|
272
274
|
const showButton = hasAction && !actionHref;
|
|
@@ -302,7 +304,35 @@ const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
302
304
|
});
|
|
303
305
|
Alert.displayName = 'Alert';
|
|
304
306
|
|
|
305
|
-
const _excluded$
|
|
307
|
+
const _excluded$e = ["summary", "children", "open", "className", "onClick", "id"];
|
|
308
|
+
const Accordion = _ref => {
|
|
309
|
+
let {
|
|
310
|
+
summary,
|
|
311
|
+
children,
|
|
312
|
+
open = false,
|
|
313
|
+
className,
|
|
314
|
+
onClick,
|
|
315
|
+
id
|
|
316
|
+
} = _ref,
|
|
317
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$e);
|
|
318
|
+
return /*#__PURE__*/React__default["default"].createElement("details", _extends__default["default"]({
|
|
319
|
+
className: classNames__default["default"]('jfcl-accordion', className),
|
|
320
|
+
open: open,
|
|
321
|
+
onClick: onClick,
|
|
322
|
+
id: id,
|
|
323
|
+
"data-testid": "jfcl-accordion"
|
|
324
|
+
}, props), /*#__PURE__*/React__default["default"].createElement("summary", {
|
|
325
|
+
className: "jfcl-accordion__summary"
|
|
326
|
+
}, summary, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
327
|
+
icon: "chevronDown",
|
|
328
|
+
className: "jfcl-accordion__chevron",
|
|
329
|
+
"aria-hidden": true
|
|
330
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
331
|
+
className: "jfcl-accordion__content"
|
|
332
|
+
}, children));
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const _excluded$d = ["labelText", "variant", "size", "loading", "labelIcon", "iconOnRight", "iconOnly", "className"];
|
|
306
336
|
/**
|
|
307
337
|
* Accepts all `ButtonHTMLAttributes`
|
|
308
338
|
*/
|
|
@@ -317,7 +347,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
317
347
|
iconOnly,
|
|
318
348
|
className
|
|
319
349
|
} = _ref,
|
|
320
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
350
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$d);
|
|
321
351
|
const buttonClassNames = classNames__default["default"]('jfcl-button', "jfcl-variant-".concat(variant), "jfcl-size-".concat(size), "".concat(loading ? 'jfcl-is-loading' : ''), "".concat(iconOnly ? 'jfcl-btn-icon-only' : ''), className);
|
|
322
352
|
const iconClassNames = classNames__default["default"]('jfcl-button__icon', "".concat(iconOnRight ? 'jfcl-button__icon_right' : ''));
|
|
323
353
|
const arias = {};
|
|
@@ -343,6 +373,80 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
343
373
|
});
|
|
344
374
|
Button.displayName = 'Button';
|
|
345
375
|
|
|
376
|
+
const _excluded$c = ["labelText", "variant", "size", "className"];
|
|
377
|
+
/**
|
|
378
|
+
* Use for navigation actions that should look like a button.
|
|
379
|
+
*/
|
|
380
|
+
const ButtonStyledLink = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
381
|
+
let {
|
|
382
|
+
labelText,
|
|
383
|
+
variant = 'primary',
|
|
384
|
+
size = 'large',
|
|
385
|
+
className
|
|
386
|
+
} = _ref,
|
|
387
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$c);
|
|
388
|
+
const linkClassNames = classNames__default["default"]('jfcl-button', 'jfcl-button-styled-link', "jfcl-variant-".concat(variant), "jfcl-size-".concat(size), className);
|
|
389
|
+
return /*#__PURE__*/React__default["default"].createElement("a", _extends__default["default"]({}, props, {
|
|
390
|
+
ref: ref,
|
|
391
|
+
className: linkClassNames,
|
|
392
|
+
"data-testid": "jfcl-button-styled-link"
|
|
393
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
394
|
+
className: "jfcl-button__label"
|
|
395
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
396
|
+
className: "jfcl-button__text"
|
|
397
|
+
}, labelText)));
|
|
398
|
+
});
|
|
399
|
+
ButtonStyledLink.displayName = 'ButtonStyledLink';
|
|
400
|
+
|
|
401
|
+
const _excluded$b = ["children", "className", "level"];
|
|
402
|
+
function isInteger(value) {
|
|
403
|
+
return Number.isInteger(value);
|
|
404
|
+
}
|
|
405
|
+
function isHeadingLevel(value) {
|
|
406
|
+
return [1, 2, 3, 4, 5, 6].includes(value);
|
|
407
|
+
}
|
|
408
|
+
const Heading = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
409
|
+
let {
|
|
410
|
+
children,
|
|
411
|
+
className,
|
|
412
|
+
level
|
|
413
|
+
} = _ref,
|
|
414
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$b);
|
|
415
|
+
if (!isInteger(level)) {
|
|
416
|
+
console.error('Heading level must be integer');
|
|
417
|
+
}
|
|
418
|
+
const Tag = isHeadingLevel(level) ? "h".concat(level) : 'span';
|
|
419
|
+
const headingClassNames = classNames__default["default"]('jfcl-heading', "jfcl-heading--h".concat(level), className);
|
|
420
|
+
return /*#__PURE__*/React__default["default"].createElement(Tag, _extends__default["default"]({
|
|
421
|
+
ref: ref,
|
|
422
|
+
className: headingClassNames
|
|
423
|
+
}, props), children);
|
|
424
|
+
});
|
|
425
|
+
Heading.displayName = 'Heading';
|
|
426
|
+
|
|
427
|
+
const _excluded$a = ["title", "children", "action", "headingLevel", "className"];
|
|
428
|
+
const CalloutBox = _ref => {
|
|
429
|
+
let {
|
|
430
|
+
title,
|
|
431
|
+
children,
|
|
432
|
+
action,
|
|
433
|
+
headingLevel = 4,
|
|
434
|
+
className
|
|
435
|
+
} = _ref,
|
|
436
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$a);
|
|
437
|
+
return /*#__PURE__*/React__default["default"].createElement("section", _extends__default["default"]({
|
|
438
|
+
className: classNames__default["default"]('jfcl-callout-box', className),
|
|
439
|
+
"data-testid": "jfcl-callout-box"
|
|
440
|
+
}, props), /*#__PURE__*/React__default["default"].createElement(Heading, {
|
|
441
|
+
level: headingLevel,
|
|
442
|
+
className: "jfcl-callout-box__header"
|
|
443
|
+
}, title), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
444
|
+
className: "jfcl-callout-box__content"
|
|
445
|
+
}, children), action && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
446
|
+
className: "jfcl-callout-box__action"
|
|
447
|
+
}, action));
|
|
448
|
+
};
|
|
449
|
+
|
|
346
450
|
const HeaderLabel = _ref => {
|
|
347
451
|
let {
|
|
348
452
|
labelFor,
|
|
@@ -401,7 +505,7 @@ const InputHeader = _ref2 => {
|
|
|
401
505
|
}), invalidText)));
|
|
402
506
|
};
|
|
403
507
|
|
|
404
|
-
const _excluded$
|
|
508
|
+
const _excluded$9 = ["className", "invalidText", "invalidRole", "invalid", "headerText", "helperText", "labelText", "disabled", "id"];
|
|
405
509
|
/**
|
|
406
510
|
* Accepts all `InputHTMLAttributes`
|
|
407
511
|
*/
|
|
@@ -417,7 +521,7 @@ const Checkbox = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
417
521
|
disabled,
|
|
418
522
|
id
|
|
419
523
|
} = _ref,
|
|
420
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
524
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$9);
|
|
421
525
|
const checkboxClassNames = classNames__default["default"]('jfcl-checkbox', {
|
|
422
526
|
['jfcl-checkbox--is-disabled']: disabled
|
|
423
527
|
}, className);
|
|
@@ -456,7 +560,9 @@ const Checkbox = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
456
560
|
});
|
|
457
561
|
Checkbox.displayName = 'Checkbox';
|
|
458
562
|
|
|
459
|
-
const _excluded$
|
|
563
|
+
const _excluded$8 = ["className", "helperText", "invalid", "invalidText", "invalidRole", "disabled", "labelText", "components"];
|
|
564
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
565
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
460
566
|
const DropdownIndicator = props => {
|
|
461
567
|
return /*#__PURE__*/React__default["default"].createElement(Select.components.DropdownIndicator, props, /*#__PURE__*/React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
462
568
|
icon: solid.faChevronDown
|
|
@@ -471,47 +577,41 @@ const Dropdown = _ref => {
|
|
|
471
577
|
invalidRole,
|
|
472
578
|
disabled,
|
|
473
579
|
labelText,
|
|
474
|
-
|
|
475
|
-
options
|
|
580
|
+
components: selectComponents
|
|
476
581
|
} = _ref,
|
|
477
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
478
|
-
const hasOnChange = !!onChange;
|
|
479
|
-
|
|
582
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$8);
|
|
480
583
|
// Randomly generated id
|
|
481
584
|
const instanceId = React.useId();
|
|
482
585
|
|
|
483
586
|
// format of the id on the actual <input /> element created by react-select
|
|
484
587
|
// using the instanceID prop
|
|
485
588
|
const inputId = "react-select-".concat(instanceId, "-input");
|
|
589
|
+
const mergedComponents = _objectSpread({
|
|
590
|
+
DropdownIndicator
|
|
591
|
+
}, selectComponents);
|
|
486
592
|
const dropdownClassNames = classNames__default["default"]('jfcl-dropdown', {
|
|
487
593
|
['jfcl-dropdown--is-invalid']: invalid
|
|
488
594
|
}, className);
|
|
489
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(InputHeader, {
|
|
595
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, labelText || helperText || invalid && invalidText ? /*#__PURE__*/React__default["default"].createElement(InputHeader, {
|
|
490
596
|
headerText: labelText,
|
|
491
597
|
labelFor: inputId,
|
|
492
598
|
helperText: helperText,
|
|
493
599
|
invalid: invalid,
|
|
494
600
|
invalidText: invalidText,
|
|
495
601
|
invalidRole: invalidRole
|
|
496
|
-
}), /*#__PURE__*/React__default["default"].createElement(Select__default["default"], _extends__default["default"]({
|
|
602
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement(Select__default["default"], _extends__default["default"]({
|
|
497
603
|
placeholder: null
|
|
498
604
|
}, props, {
|
|
499
605
|
instanceId: instanceId,
|
|
500
606
|
className: dropdownClassNames,
|
|
501
607
|
classNamePrefix: "jfcl-dropdown",
|
|
502
608
|
isDisabled: disabled,
|
|
503
|
-
|
|
504
|
-
}, hasOnChange && {
|
|
505
|
-
onChange: onChange
|
|
506
|
-
}, {
|
|
507
|
-
components: {
|
|
508
|
-
DropdownIndicator
|
|
509
|
-
}
|
|
609
|
+
components: mergedComponents
|
|
510
610
|
})));
|
|
511
611
|
};
|
|
512
612
|
Dropdown.displayName = 'Dropdown';
|
|
513
613
|
|
|
514
|
-
const _excluded$
|
|
614
|
+
const _excluded$7 = ["className", "children", "invalidText", "invalidRole", "invalid", "helperText", "helperElement", "legendText"];
|
|
515
615
|
/**
|
|
516
616
|
* Accepts all `HTMLFieldSetElement`
|
|
517
617
|
*/
|
|
@@ -526,7 +626,7 @@ const FormGroup = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
526
626
|
helperElement,
|
|
527
627
|
legendText
|
|
528
628
|
} = _ref,
|
|
529
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
629
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$7);
|
|
530
630
|
const fieldsetClassNames = classNames__default["default"]('jfcl-form-group', {
|
|
531
631
|
['jfcl-form-group-is-invalid']: invalid
|
|
532
632
|
}, className);
|
|
@@ -546,6 +646,295 @@ const FormGroup = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
546
646
|
});
|
|
547
647
|
FormGroup.displayName = 'FormGroup';
|
|
548
648
|
|
|
649
|
+
const _excluded$6 = ["initialAddress", "onSelect", "onChange", "onInputChange", "customGeoAutocompleteUrl", "throttleMs", "includeFullResponse", "serviceUnavailableText", "onRequestError", "noOptionsMessage", "className", "invalid", "invalidText"];
|
|
650
|
+
const DEFAULT_THROTTLE_MS = 250;
|
|
651
|
+
const GEO_AUTOCOMPLETE_URL = 'https://geosearch.planninglabs.nyc/v2/autocomplete';
|
|
652
|
+
const toTitleCase = value => value.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase());
|
|
653
|
+
const formatGeosearchAddress = feature => {
|
|
654
|
+
const {
|
|
655
|
+
name,
|
|
656
|
+
borough,
|
|
657
|
+
postalcode
|
|
658
|
+
} = feature.properties;
|
|
659
|
+
const formattedName = toTitleCase(name !== null && name !== void 0 ? name : '');
|
|
660
|
+
const boroughName = borough !== null && borough !== void 0 ? borough : '';
|
|
661
|
+
const zipCode = postalcode !== null && postalcode !== void 0 ? postalcode : '';
|
|
662
|
+
return "".concat(formattedName, ", ").concat(boroughName, ", ").concat(zipCode).trim();
|
|
663
|
+
};
|
|
664
|
+
const normalizeFeature = feature => {
|
|
665
|
+
var _typedFeature$geometr, _typedFeature$geometr2, _typedFeature$geometr3, _typedFeature$propert, _typedFeature$propert2, _typedFeature$propert3, _typedFeature$propert4, _typedFeature$propert5, _typedFeature$propert6, _typedFeature$propert7, _typedFeature$propert8, _typedFeature$propert9;
|
|
666
|
+
const typedFeature = feature;
|
|
667
|
+
return {
|
|
668
|
+
type: typedFeature.type,
|
|
669
|
+
geometry: {
|
|
670
|
+
type: (_typedFeature$geometr = typedFeature.geometry) === null || _typedFeature$geometr === void 0 ? void 0 : _typedFeature$geometr.type,
|
|
671
|
+
coordinates: (_typedFeature$geometr2 = (_typedFeature$geometr3 = typedFeature.geometry) === null || _typedFeature$geometr3 === void 0 ? void 0 : _typedFeature$geometr3.coordinates) !== null && _typedFeature$geometr2 !== void 0 ? _typedFeature$geometr2 : []
|
|
672
|
+
},
|
|
673
|
+
properties: {
|
|
674
|
+
borough: (_typedFeature$propert = typedFeature.properties) === null || _typedFeature$propert === void 0 ? void 0 : _typedFeature$propert.borough,
|
|
675
|
+
borough_gid: (_typedFeature$propert2 = typedFeature.properties) === null || _typedFeature$propert2 === void 0 ? void 0 : _typedFeature$propert2.borough_gid,
|
|
676
|
+
housenumber: (_typedFeature$propert3 = typedFeature.properties) === null || _typedFeature$propert3 === void 0 ? void 0 : _typedFeature$propert3.housenumber,
|
|
677
|
+
street: (_typedFeature$propert4 = typedFeature.properties) === null || _typedFeature$propert4 === void 0 ? void 0 : _typedFeature$propert4.street,
|
|
678
|
+
name: (_typedFeature$propert5 = typedFeature.properties) === null || _typedFeature$propert5 === void 0 ? void 0 : _typedFeature$propert5.name,
|
|
679
|
+
label: (_typedFeature$propert6 = typedFeature.properties) === null || _typedFeature$propert6 === void 0 ? void 0 : _typedFeature$propert6.label,
|
|
680
|
+
addendum: {
|
|
681
|
+
pad: {
|
|
682
|
+
bbl: (_typedFeature$propert7 = typedFeature.properties) === null || _typedFeature$propert7 === void 0 || (_typedFeature$propert7 = _typedFeature$propert7.addendum) === null || _typedFeature$propert7 === void 0 || (_typedFeature$propert7 = _typedFeature$propert7.pad) === null || _typedFeature$propert7 === void 0 ? void 0 : _typedFeature$propert7.bbl,
|
|
683
|
+
bin: (_typedFeature$propert8 = typedFeature.properties) === null || _typedFeature$propert8 === void 0 || (_typedFeature$propert8 = _typedFeature$propert8.addendum) === null || _typedFeature$propert8 === void 0 || (_typedFeature$propert8 = _typedFeature$propert8.pad) === null || _typedFeature$propert8 === void 0 ? void 0 : _typedFeature$propert8.bin
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
postalcode: (_typedFeature$propert9 = typedFeature.properties) === null || _typedFeature$propert9 === void 0 ? void 0 : _typedFeature$propert9.postalcode
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
const normalizeResults = (rawResults, queryText) => {
|
|
691
|
+
var _typedResults$query$t, _typedResults$query, _typedResults$feature;
|
|
692
|
+
const typedResults = rawResults;
|
|
693
|
+
return {
|
|
694
|
+
bbox: typedResults.bbox,
|
|
695
|
+
query: {
|
|
696
|
+
text: (_typedResults$query$t = (_typedResults$query = typedResults.query) === null || _typedResults$query === void 0 ? void 0 : _typedResults$query.text) !== null && _typedResults$query$t !== void 0 ? _typedResults$query$t : queryText
|
|
697
|
+
},
|
|
698
|
+
features: ((_typedResults$feature = typedResults.features) !== null && _typedResults$feature !== void 0 ? _typedResults$feature : []).map(feature => normalizeFeature(feature))
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
const GeoSearchDropdown = _ref => {
|
|
702
|
+
let {
|
|
703
|
+
initialAddress,
|
|
704
|
+
onSelect,
|
|
705
|
+
onChange,
|
|
706
|
+
onInputChange,
|
|
707
|
+
customGeoAutocompleteUrl,
|
|
708
|
+
throttleMs,
|
|
709
|
+
includeFullResponse = false,
|
|
710
|
+
serviceUnavailableText,
|
|
711
|
+
onRequestError,
|
|
712
|
+
noOptionsMessage,
|
|
713
|
+
className,
|
|
714
|
+
invalid,
|
|
715
|
+
invalidText
|
|
716
|
+
} = _ref,
|
|
717
|
+
dropdownProps = _objectWithoutProperties__default["default"](_ref, _excluded$6);
|
|
718
|
+
const [response, setResponse] = React.useState(null);
|
|
719
|
+
const [fullResponse, setFullResponse] = React.useState(null);
|
|
720
|
+
const [options, setOptions] = React.useState([]);
|
|
721
|
+
const [selectedValue, setSelectedValue] = React.useState(null);
|
|
722
|
+
const [isServiceUnavailable, setIsServiceUnavailable] = React.useState(false);
|
|
723
|
+
const requestIdRef = React.useRef(0);
|
|
724
|
+
const timerRef = React.useRef(null);
|
|
725
|
+
const abortRef = React.useRef(null);
|
|
726
|
+
const clearPendingRequests = React.useCallback(() => {
|
|
727
|
+
if (timerRef.current) {
|
|
728
|
+
clearTimeout(timerRef.current);
|
|
729
|
+
timerRef.current = null;
|
|
730
|
+
}
|
|
731
|
+
if (abortRef.current) {
|
|
732
|
+
abortRef.current.abort();
|
|
733
|
+
abortRef.current = null;
|
|
734
|
+
}
|
|
735
|
+
}, []);
|
|
736
|
+
const runSearch = React.useCallback(value => {
|
|
737
|
+
requestIdRef.current += 1;
|
|
738
|
+
const requestId = requestIdRef.current;
|
|
739
|
+
clearPendingRequests();
|
|
740
|
+
if (!value.trim()) {
|
|
741
|
+
setIsServiceUnavailable(false);
|
|
742
|
+
setResponse(null);
|
|
743
|
+
setFullResponse(null);
|
|
744
|
+
setOptions([]);
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
timerRef.current = setTimeout(async () => {
|
|
748
|
+
const controller = new AbortController();
|
|
749
|
+
abortRef.current = controller;
|
|
750
|
+
try {
|
|
751
|
+
const endpoint = customGeoAutocompleteUrl || GEO_AUTOCOMPLETE_URL;
|
|
752
|
+
const result = await fetch("".concat(endpoint, "?text=").concat(encodeURIComponent(value)), {
|
|
753
|
+
signal: controller.signal
|
|
754
|
+
});
|
|
755
|
+
if (result.status !== 200) {
|
|
756
|
+
const requestError = new Error("Received HTTP ".concat(result.status));
|
|
757
|
+
requestError.status = result.status;
|
|
758
|
+
throw requestError;
|
|
759
|
+
}
|
|
760
|
+
const rawJson = await result.json();
|
|
761
|
+
const json = normalizeResults(rawJson, value);
|
|
762
|
+
if (requestIdRef.current !== requestId) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
setIsServiceUnavailable(false);
|
|
766
|
+
setResponse(json);
|
|
767
|
+
setFullResponse(rawJson);
|
|
768
|
+
setOptions(json.features.map(feature => {
|
|
769
|
+
const label = formatGeosearchAddress(feature);
|
|
770
|
+
return {
|
|
771
|
+
value: label,
|
|
772
|
+
label,
|
|
773
|
+
feature
|
|
774
|
+
};
|
|
775
|
+
}));
|
|
776
|
+
} catch (error) {
|
|
777
|
+
const requestError = error;
|
|
778
|
+
if (requestError.name === 'AbortError') {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
if (requestIdRef.current !== requestId) {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const requestIsServiceUnavailable = requestError.status === 503;
|
|
785
|
+
setIsServiceUnavailable(requestIsServiceUnavailable);
|
|
786
|
+
if (requestIsServiceUnavailable) {
|
|
787
|
+
setResponse(null);
|
|
788
|
+
setFullResponse(null);
|
|
789
|
+
setOptions([]);
|
|
790
|
+
}
|
|
791
|
+
onRequestError === null || onRequestError === void 0 || onRequestError(requestError);
|
|
792
|
+
}
|
|
793
|
+
}, throttleMs !== null && throttleMs !== void 0 ? throttleMs : DEFAULT_THROTTLE_MS);
|
|
794
|
+
}, [clearPendingRequests, customGeoAutocompleteUrl, onRequestError, throttleMs]);
|
|
795
|
+
React.useEffect(() => {
|
|
796
|
+
if (initialAddress) {
|
|
797
|
+
const addressValue = toTitleCase(initialAddress);
|
|
798
|
+
setSelectedValue({
|
|
799
|
+
value: addressValue,
|
|
800
|
+
label: addressValue
|
|
801
|
+
});
|
|
802
|
+
runSearch(addressValue);
|
|
803
|
+
}
|
|
804
|
+
}, [initialAddress, runSearch]);
|
|
805
|
+
React.useEffect(() => {
|
|
806
|
+
return () => {
|
|
807
|
+
clearPendingRequests();
|
|
808
|
+
};
|
|
809
|
+
}, [clearPendingRequests]);
|
|
810
|
+
const showServiceUnavailableState = isServiceUnavailable && !!serviceUnavailableText;
|
|
811
|
+
const effectiveInvalid = !!invalid || showServiceUnavailableState;
|
|
812
|
+
const effectiveInvalidText = showServiceUnavailableState ? serviceUnavailableText : invalidText;
|
|
813
|
+
return /*#__PURE__*/React__default["default"].createElement(Dropdown, _extends__default["default"]({}, dropdownProps, {
|
|
814
|
+
className: "jfcl-geosearch-dropdown ".concat(className !== null && className !== void 0 ? className : '').trim(),
|
|
815
|
+
invalid: effectiveInvalid,
|
|
816
|
+
invalidText: effectiveInvalidText,
|
|
817
|
+
options: options,
|
|
818
|
+
value: selectedValue,
|
|
819
|
+
filterOption: null,
|
|
820
|
+
escapeClearsValue: false,
|
|
821
|
+
noOptionsMessage: noOptionsMessage !== null && noOptionsMessage !== void 0 ? noOptionsMessage : () => 'Enter an address to get started',
|
|
822
|
+
onInputChange: (value, meta) => {
|
|
823
|
+
runSearch(value);
|
|
824
|
+
return onInputChange ? onInputChange(value, meta) : value;
|
|
825
|
+
},
|
|
826
|
+
onChange: (newValue, actionMeta) => {
|
|
827
|
+
setSelectedValue(newValue);
|
|
828
|
+
onChange === null || onChange === void 0 || onChange(newValue, actionMeta);
|
|
829
|
+
if (!newValue || !newValue.feature) {
|
|
830
|
+
onSelect === null || onSelect === void 0 || onSelect(null);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
onSelect === null || onSelect === void 0 || onSelect({
|
|
834
|
+
option: newValue,
|
|
835
|
+
feature: newValue.feature,
|
|
836
|
+
response,
|
|
837
|
+
fullResponse: includeFullResponse ? fullResponse : undefined
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
}));
|
|
841
|
+
};
|
|
842
|
+
GeoSearchDropdown.displayName = 'GeoSearchDropdown';
|
|
843
|
+
|
|
844
|
+
const _excluded$5 = ["children", "color", "role", "className"];
|
|
845
|
+
const InfoBox = _ref => {
|
|
846
|
+
let {
|
|
847
|
+
children,
|
|
848
|
+
color = 'white',
|
|
849
|
+
role,
|
|
850
|
+
className
|
|
851
|
+
} = _ref,
|
|
852
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$5);
|
|
853
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({
|
|
854
|
+
className: classNames__default["default"]('jfcl-info-box', "jfcl-info-box--".concat(color), className),
|
|
855
|
+
role: role,
|
|
856
|
+
"data-testid": "jfcl-info-box"
|
|
857
|
+
}, props), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
858
|
+
className: "jfcl-info-box__icon-container"
|
|
859
|
+
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
860
|
+
icon: color === 'orange' ? 'circleExclamation' : 'circleInfo',
|
|
861
|
+
"aria-hidden": true
|
|
862
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
863
|
+
className: "jfcl-info-box__content-container"
|
|
864
|
+
}, children));
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
const _excluded$4 = ["icon", "children", "className", "type"];
|
|
868
|
+
/**
|
|
869
|
+
* Use for in-page actions that should look like a text link.
|
|
870
|
+
*/
|
|
871
|
+
const LinkStyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
872
|
+
let {
|
|
873
|
+
icon,
|
|
874
|
+
children,
|
|
875
|
+
className,
|
|
876
|
+
type = 'button'
|
|
877
|
+
} = _ref,
|
|
878
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
|
|
879
|
+
const buttonClassNames = classNames__default["default"]('jfcl-link', 'jfcl-link-styled-button', className);
|
|
880
|
+
return /*#__PURE__*/React__default["default"].createElement("button", _extends__default["default"]({}, props, {
|
|
881
|
+
ref: ref,
|
|
882
|
+
type: type,
|
|
883
|
+
className: buttonClassNames,
|
|
884
|
+
"data-testid": "jfcl-link-styled-button"
|
|
885
|
+
}), children, icon === 'internal' && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
886
|
+
icon: "arrowRight",
|
|
887
|
+
className: "jfcl-link__icon"
|
|
888
|
+
}), icon === 'external' && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
889
|
+
icon: "squareArrowUpRight",
|
|
890
|
+
className: "jfcl-link__icon"
|
|
891
|
+
}));
|
|
892
|
+
});
|
|
893
|
+
LinkStyledButton.displayName = 'LinkStyledButton';
|
|
894
|
+
|
|
895
|
+
const Notice = _ref => {
|
|
896
|
+
let {
|
|
897
|
+
icon,
|
|
898
|
+
color,
|
|
899
|
+
header,
|
|
900
|
+
headingLevel,
|
|
901
|
+
children,
|
|
902
|
+
className
|
|
903
|
+
} = _ref;
|
|
904
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
905
|
+
className: classNames__default["default"]('jfcl-notice', color && "jfcl-notice--".concat(color), className),
|
|
906
|
+
"data-testid": "jfcl-notice"
|
|
907
|
+
}, icon && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
908
|
+
className: "jfcl-notice__icon-container"
|
|
909
|
+
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
910
|
+
icon: icon,
|
|
911
|
+
"aria-hidden": true
|
|
912
|
+
})), /*#__PURE__*/React__default["default"].createElement("section", {
|
|
913
|
+
className: "jfcl-notice__content-container"
|
|
914
|
+
}, header && /*#__PURE__*/React__default["default"].createElement(Heading, {
|
|
915
|
+
level: headingLevel,
|
|
916
|
+
className: "jfcl-notice__header"
|
|
917
|
+
}, header), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
918
|
+
className: "jfcl-notice__body"
|
|
919
|
+
}, children)));
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
const _excluded$3 = ["color", "children", "className", "circle"];
|
|
923
|
+
const Pill = _ref => {
|
|
924
|
+
let {
|
|
925
|
+
color,
|
|
926
|
+
children,
|
|
927
|
+
className,
|
|
928
|
+
circle = false
|
|
929
|
+
} = _ref,
|
|
930
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
|
|
931
|
+
const pillClassNames = classNames__default["default"]('jfcl-pill', "jfcl-pill--".concat(color), circle && 'jfcl-pill--circle', className);
|
|
932
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({
|
|
933
|
+
className: pillClassNames,
|
|
934
|
+
"data-testid": "jfcl-pill"
|
|
935
|
+
}, props), children);
|
|
936
|
+
};
|
|
937
|
+
|
|
549
938
|
const _excluded$2 = ["className", "invalidText", "invalidRole", "invalid", "headerText", "helperText", "labelText", "labelElement", "disabled", "id"];
|
|
550
939
|
/**
|
|
551
940
|
* Accepts all `InputHTMLAttributes`
|
|
@@ -684,13 +1073,22 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
684
1073
|
});
|
|
685
1074
|
TextInput.displayName = 'TextInput';
|
|
686
1075
|
|
|
1076
|
+
exports.Accordion = Accordion;
|
|
687
1077
|
exports.Alert = Alert;
|
|
688
1078
|
exports.Button = Button;
|
|
1079
|
+
exports.ButtonStyledLink = ButtonStyledLink;
|
|
1080
|
+
exports.CalloutBox = CalloutBox;
|
|
689
1081
|
exports.Checkbox = Checkbox;
|
|
690
1082
|
exports.Dropdown = Dropdown;
|
|
691
1083
|
exports.FormGroup = FormGroup;
|
|
1084
|
+
exports.GeoSearchDropdown = GeoSearchDropdown;
|
|
1085
|
+
exports.Heading = Heading;
|
|
692
1086
|
exports.Icon = Icon;
|
|
1087
|
+
exports.InfoBox = InfoBox;
|
|
693
1088
|
exports.Link = Link;
|
|
1089
|
+
exports.LinkStyledButton = LinkStyledButton;
|
|
1090
|
+
exports.Notice = Notice;
|
|
1091
|
+
exports.Pill = Pill;
|
|
694
1092
|
exports.RadioButton = RadioButton;
|
|
695
1093
|
exports.SelectButton = SelectButton;
|
|
696
1094
|
exports.TextInput = TextInput;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
export interface AccordionProps extends Omit<React.HTMLAttributes<HTMLDetailsElement>, 'children' | 'onClick'> {
|
|
4
|
+
summary: React.ReactNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
onClick?: React.MouseEventHandler<HTMLDetailsElement>;
|
|
9
|
+
id?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const Accordion: React.FC<AccordionProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
export interface ButtonStyledLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Text shown inside the button-styled link.
|
|
6
|
+
*/
|
|
7
|
+
labelText: string;
|
|
8
|
+
variant?: 'primary' | 'secondary' | 'tertiary';
|
|
9
|
+
size?: 'small' | 'large';
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Use for navigation actions that should look like a button.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ButtonStyledLink: React.ForwardRefExoticComponent<ButtonStyledLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
export interface CalloutBoxProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'children'> {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
action?: React.ReactNode;
|
|
7
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
}
|
|
9
|
+
export declare const CalloutBox: React.FC<CalloutBoxProps>;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { GroupBase, Props as SelectProps } from 'react-select';
|
|
2
3
|
import './styles.scss';
|
|
3
|
-
export
|
|
4
|
-
|
|
4
|
+
export type DropdownOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type DropdownBaseProps = {
|
|
5
10
|
className?: string;
|
|
6
|
-
|
|
7
|
-
value: string;
|
|
8
|
-
label: string;
|
|
9
|
-
isDisabled?: boolean;
|
|
10
|
-
}[];
|
|
11
|
-
labelText: React.ReactNode;
|
|
11
|
+
labelText?: React.ReactNode;
|
|
12
12
|
helperText?: string;
|
|
13
13
|
invalidText?: string;
|
|
14
14
|
invalidRole?: string;
|
|
15
15
|
invalid?: boolean;
|
|
16
16
|
disabled?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export
|
|
17
|
+
};
|
|
18
|
+
export type DropdownProps<Option = DropdownOption, Group extends GroupBase<Option> = GroupBase<Option>> = Omit<SelectProps<Option, false, Group>, 'className' | 'classNamePrefix' | 'isDisabled'> & DropdownBaseProps;
|
|
19
|
+
export declare const Dropdown: {
|
|
20
|
+
<Option, Group extends GroupBase<Option> = GroupBase<Option>>({ className, helperText, invalid, invalidText, invalidRole, disabled, labelText, components: selectComponents, ...props }: DropdownProps<Option, Group>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
23
|
+
export {};
|