@justfixnyc/component-library 0.60.2 → 0.61.3
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 +3 -2
- package/dist/src/assets/index.css +642 -6
- package/dist/src/assets/index.es.css +642 -6
- package/dist/src/index.es.js +429 -32
- package/dist/src/index.js +434 -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/Icon/Icon.d.ts +1 -1
- 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.es.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/extends';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import React, { forwardRef, useId } from 'react';
|
|
5
|
-
import { faShieldCheck, faCalculatorSimple, faPlus, faBan, faXmark, faDownload as faDownload$1, faBuildingColumns, faAddressCard, faBuilding, faMapLocationDot, faMemoPad, faLocationDot, faHouse, faGlobe, faUser, faSpinner, faBars, faMailboxOpenLetter as faMailboxOpenLetter$1, faEnvelope as faEnvelope$2, faCommentSms, faCopy, faCirclePlus, faCircleInfo, faCircleExclamation as faCircleExclamation$1, faChevronRight, faChevronLeft, faChevronDown, faChevronUp, faCheckDouble, faCheck, faCaretDown, faCaretRight, faBookmark as faBookmark$1, faSquareArrowUpRight, faArrowsRotateReverse, faArrowDownWideShort, faArrowUpShortWide, faArrowUpArrowDown, faArrowDownLong, faArrowUpLong, faArrowDown, faArrowUpRight, faArrowUp, faArrowRight, faArrowLeft } from '@awesome.me/kit-6863e5a21e/icons/classic/solid';
|
|
6
|
-
import { faMailboxOpenLetter, faPaperPlane, faEnvelopeCircleCheck, faEnvelope } from '@awesome.me/kit-6863e5a21e/icons/classic/light';
|
|
7
|
-
import { faPrint, faEyeSlash, faEye, faDownload, faEnvelope as faEnvelope$1, faCircleExclamation, faBookmark } from '@awesome.me/kit-6863e5a21e/icons/classic/regular';
|
|
4
|
+
import React, { forwardRef, useId, useState, useRef, useCallback, useEffect } from 'react';
|
|
5
|
+
import { faShieldCheck, faCalculatorSimple, faPlus, faBan, faXmark, faDownload as faDownload$1, faBuildingColumns, faAddressCard, faBuilding, faMapLocationDot, faMobileScreenButton, faMemoPad, faLocationDot, faHouse, faGlobe, faUser, faSpinner, faBars, faMailboxOpenLetter as faMailboxOpenLetter$1, faEnvelope as faEnvelope$2, faCommentSms, faCopy, faCirclePlus, faCircleInfo, faCircleExclamation as faCircleExclamation$1, faChevronRight, faChevronLeft, faChevronDown, faChevronUp, faCheckDouble, faCheck, faCaretDown, faCaretRight, faBookmark as faBookmark$1, faSquareArrowUpRight, faArrowsRotateReverse, faArrowDownWideShort, faArrowUpShortWide, faArrowUpArrowDown, faArrowDownLong, faArrowUpLong, faArrowDown, faArrowUpRight, faArrowUp, faArrowRight, faArrowLeft } from '@awesome.me/kit-6863e5a21e/icons/classic/solid';
|
|
6
|
+
import { faFile as faFile$1, faMailboxOpenLetter, faPaperPlane, faEnvelopeCircleCheck, faEnvelope } from '@awesome.me/kit-6863e5a21e/icons/classic/light';
|
|
7
|
+
import { faPrint, faFile, faEyeSlash, faEye, faDownload, faEnvelope as faEnvelope$1, faCircleExclamation, faBookmark } from '@awesome.me/kit-6863e5a21e/icons/classic/regular';
|
|
8
8
|
import { faXTwitter, faTwitter, faFacebookF } from '@awesome.me/kit-6863e5a21e/icons/classic/brands';
|
|
9
9
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
10
|
import { faEnvelopeCircleExclamationLight } from '@awesome.me/kit-6863e5a21e/icons/kit/custom';
|
|
11
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
11
12
|
import Select, { components } from 'react-select';
|
|
12
13
|
|
|
13
|
-
const _excluded$
|
|
14
|
+
const _excluded$h = ["className", "icon"];
|
|
14
15
|
const Icon = _ref => {
|
|
15
16
|
let {
|
|
16
17
|
className,
|
|
17
18
|
icon
|
|
18
19
|
} = _ref,
|
|
19
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
20
|
+
props = _objectWithoutProperties(_ref, _excluded$h);
|
|
20
21
|
let faIcon;
|
|
21
22
|
switch (icon) {
|
|
22
23
|
case 'arrowLeft':
|
|
@@ -157,6 +158,9 @@ const Icon = _ref => {
|
|
|
157
158
|
case 'memoPad':
|
|
158
159
|
faIcon = faMemoPad;
|
|
159
160
|
break;
|
|
161
|
+
case 'mobileScreenButton':
|
|
162
|
+
faIcon = faMobileScreenButton;
|
|
163
|
+
break;
|
|
160
164
|
case 'mapLocationDot':
|
|
161
165
|
faIcon = faMapLocationDot;
|
|
162
166
|
break;
|
|
@@ -187,6 +191,12 @@ const Icon = _ref => {
|
|
|
187
191
|
case 'eyeSlash':
|
|
188
192
|
faIcon = faEyeSlash;
|
|
189
193
|
break;
|
|
194
|
+
case 'fileLight':
|
|
195
|
+
faIcon = faFile$1;
|
|
196
|
+
break;
|
|
197
|
+
case 'fileRegular':
|
|
198
|
+
faIcon = faFile;
|
|
199
|
+
break;
|
|
190
200
|
case 'print':
|
|
191
201
|
faIcon = faPrint;
|
|
192
202
|
break;
|
|
@@ -210,14 +220,14 @@ const Icon = _ref => {
|
|
|
210
220
|
};
|
|
211
221
|
Icon.displayName = 'Icon';
|
|
212
222
|
|
|
213
|
-
const _excluded$
|
|
223
|
+
const _excluded$g = ["icon", "children", "className"];
|
|
214
224
|
const Link = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
215
225
|
let {
|
|
216
226
|
icon,
|
|
217
227
|
children,
|
|
218
228
|
className
|
|
219
229
|
} = _ref,
|
|
220
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
230
|
+
props = _objectWithoutProperties(_ref, _excluded$g);
|
|
221
231
|
const linkClassNames = classNames('jfcl-link', className);
|
|
222
232
|
const opensInNewTab = props.target === '_blank';
|
|
223
233
|
// When using this component within a react-router-dom <Link />, a navigate function is passed through the props us here.
|
|
@@ -243,7 +253,7 @@ const Link = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
243
253
|
});
|
|
244
254
|
Link.displayName = 'Link';
|
|
245
255
|
|
|
246
|
-
const _excluded$
|
|
256
|
+
const _excluded$f = ["type", "variant", "text", "action", "actionHref", "actionLabel", "className"];
|
|
247
257
|
const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
248
258
|
let {
|
|
249
259
|
type = 'info',
|
|
@@ -254,7 +264,7 @@ const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
254
264
|
actionLabel,
|
|
255
265
|
className
|
|
256
266
|
} = _ref,
|
|
257
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
267
|
+
props = _objectWithoutProperties(_ref, _excluded$f);
|
|
258
268
|
const alertClassNames = classNames('jfcl-alert', "jfcl-variant-".concat(variant), "jfcl-type-".concat(type), className);
|
|
259
269
|
const hasAction = !!action;
|
|
260
270
|
const showButton = hasAction && !actionHref;
|
|
@@ -290,7 +300,35 @@ const Alert = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
290
300
|
});
|
|
291
301
|
Alert.displayName = 'Alert';
|
|
292
302
|
|
|
293
|
-
const _excluded$
|
|
303
|
+
const _excluded$e = ["summary", "children", "open", "className", "onClick", "id"];
|
|
304
|
+
const Accordion = _ref => {
|
|
305
|
+
let {
|
|
306
|
+
summary,
|
|
307
|
+
children,
|
|
308
|
+
open = false,
|
|
309
|
+
className,
|
|
310
|
+
onClick,
|
|
311
|
+
id
|
|
312
|
+
} = _ref,
|
|
313
|
+
props = _objectWithoutProperties(_ref, _excluded$e);
|
|
314
|
+
return /*#__PURE__*/React.createElement("details", _extends({
|
|
315
|
+
className: classNames('jfcl-accordion', className),
|
|
316
|
+
open: open,
|
|
317
|
+
onClick: onClick,
|
|
318
|
+
id: id,
|
|
319
|
+
"data-testid": "jfcl-accordion"
|
|
320
|
+
}, props), /*#__PURE__*/React.createElement("summary", {
|
|
321
|
+
className: "jfcl-accordion__summary"
|
|
322
|
+
}, summary, /*#__PURE__*/React.createElement(Icon, {
|
|
323
|
+
icon: "chevronDown",
|
|
324
|
+
className: "jfcl-accordion__chevron",
|
|
325
|
+
"aria-hidden": true
|
|
326
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
327
|
+
className: "jfcl-accordion__content"
|
|
328
|
+
}, children));
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const _excluded$d = ["labelText", "variant", "size", "loading", "labelIcon", "iconOnRight", "iconOnly", "className"];
|
|
294
332
|
/**
|
|
295
333
|
* Accepts all `ButtonHTMLAttributes`
|
|
296
334
|
*/
|
|
@@ -305,7 +343,7 @@ const Button = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
305
343
|
iconOnly,
|
|
306
344
|
className
|
|
307
345
|
} = _ref,
|
|
308
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
346
|
+
props = _objectWithoutProperties(_ref, _excluded$d);
|
|
309
347
|
const buttonClassNames = classNames('jfcl-button', "jfcl-variant-".concat(variant), "jfcl-size-".concat(size), "".concat(loading ? 'jfcl-is-loading' : ''), "".concat(iconOnly ? 'jfcl-btn-icon-only' : ''), className);
|
|
310
348
|
const iconClassNames = classNames('jfcl-button__icon', "".concat(iconOnRight ? 'jfcl-button__icon_right' : ''));
|
|
311
349
|
const arias = {};
|
|
@@ -331,6 +369,80 @@ const Button = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
331
369
|
});
|
|
332
370
|
Button.displayName = 'Button';
|
|
333
371
|
|
|
372
|
+
const _excluded$c = ["labelText", "variant", "size", "className"];
|
|
373
|
+
/**
|
|
374
|
+
* Use for navigation actions that should look like a button.
|
|
375
|
+
*/
|
|
376
|
+
const ButtonStyledLink = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
377
|
+
let {
|
|
378
|
+
labelText,
|
|
379
|
+
variant = 'primary',
|
|
380
|
+
size = 'large',
|
|
381
|
+
className
|
|
382
|
+
} = _ref,
|
|
383
|
+
props = _objectWithoutProperties(_ref, _excluded$c);
|
|
384
|
+
const linkClassNames = classNames('jfcl-button', 'jfcl-button-styled-link', "jfcl-variant-".concat(variant), "jfcl-size-".concat(size), className);
|
|
385
|
+
return /*#__PURE__*/React.createElement("a", _extends({}, props, {
|
|
386
|
+
ref: ref,
|
|
387
|
+
className: linkClassNames,
|
|
388
|
+
"data-testid": "jfcl-button-styled-link"
|
|
389
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
390
|
+
className: "jfcl-button__label"
|
|
391
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
392
|
+
className: "jfcl-button__text"
|
|
393
|
+
}, labelText)));
|
|
394
|
+
});
|
|
395
|
+
ButtonStyledLink.displayName = 'ButtonStyledLink';
|
|
396
|
+
|
|
397
|
+
const _excluded$b = ["children", "className", "level"];
|
|
398
|
+
function isInteger(value) {
|
|
399
|
+
return Number.isInteger(value);
|
|
400
|
+
}
|
|
401
|
+
function isHeadingLevel(value) {
|
|
402
|
+
return [1, 2, 3, 4, 5, 6].includes(value);
|
|
403
|
+
}
|
|
404
|
+
const Heading = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
405
|
+
let {
|
|
406
|
+
children,
|
|
407
|
+
className,
|
|
408
|
+
level
|
|
409
|
+
} = _ref,
|
|
410
|
+
props = _objectWithoutProperties(_ref, _excluded$b);
|
|
411
|
+
if (!isInteger(level)) {
|
|
412
|
+
console.error('Heading level must be integer');
|
|
413
|
+
}
|
|
414
|
+
const Tag = isHeadingLevel(level) ? "h".concat(level) : 'span';
|
|
415
|
+
const headingClassNames = classNames('jfcl-heading', "jfcl-heading--h".concat(level), className);
|
|
416
|
+
return /*#__PURE__*/React.createElement(Tag, _extends({
|
|
417
|
+
ref: ref,
|
|
418
|
+
className: headingClassNames
|
|
419
|
+
}, props), children);
|
|
420
|
+
});
|
|
421
|
+
Heading.displayName = 'Heading';
|
|
422
|
+
|
|
423
|
+
const _excluded$a = ["title", "children", "action", "headingLevel", "className"];
|
|
424
|
+
const CalloutBox = _ref => {
|
|
425
|
+
let {
|
|
426
|
+
title,
|
|
427
|
+
children,
|
|
428
|
+
action,
|
|
429
|
+
headingLevel = 4,
|
|
430
|
+
className
|
|
431
|
+
} = _ref,
|
|
432
|
+
props = _objectWithoutProperties(_ref, _excluded$a);
|
|
433
|
+
return /*#__PURE__*/React.createElement("section", _extends({
|
|
434
|
+
className: classNames('jfcl-callout-box', className),
|
|
435
|
+
"data-testid": "jfcl-callout-box"
|
|
436
|
+
}, props), /*#__PURE__*/React.createElement(Heading, {
|
|
437
|
+
level: headingLevel,
|
|
438
|
+
className: "jfcl-callout-box__header"
|
|
439
|
+
}, title), /*#__PURE__*/React.createElement("div", {
|
|
440
|
+
className: "jfcl-callout-box__content"
|
|
441
|
+
}, children), action && /*#__PURE__*/React.createElement("div", {
|
|
442
|
+
className: "jfcl-callout-box__action"
|
|
443
|
+
}, action));
|
|
444
|
+
};
|
|
445
|
+
|
|
334
446
|
const HeaderLabel = _ref => {
|
|
335
447
|
let {
|
|
336
448
|
labelFor,
|
|
@@ -389,7 +501,7 @@ const InputHeader = _ref2 => {
|
|
|
389
501
|
}), invalidText)));
|
|
390
502
|
};
|
|
391
503
|
|
|
392
|
-
const _excluded$
|
|
504
|
+
const _excluded$9 = ["className", "invalidText", "invalidRole", "invalid", "headerText", "helperText", "labelText", "disabled", "id"];
|
|
393
505
|
/**
|
|
394
506
|
* Accepts all `InputHTMLAttributes`
|
|
395
507
|
*/
|
|
@@ -405,7 +517,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
405
517
|
disabled,
|
|
406
518
|
id
|
|
407
519
|
} = _ref,
|
|
408
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
520
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
409
521
|
const checkboxClassNames = classNames('jfcl-checkbox', {
|
|
410
522
|
['jfcl-checkbox--is-disabled']: disabled
|
|
411
523
|
}, className);
|
|
@@ -444,7 +556,9 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
444
556
|
});
|
|
445
557
|
Checkbox.displayName = 'Checkbox';
|
|
446
558
|
|
|
447
|
-
const _excluded$
|
|
559
|
+
const _excluded$8 = ["className", "helperText", "invalid", "invalidText", "invalidRole", "disabled", "labelText", "components"];
|
|
560
|
+
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; }
|
|
561
|
+
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(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; }
|
|
448
562
|
const DropdownIndicator = props => {
|
|
449
563
|
return /*#__PURE__*/React.createElement(components.DropdownIndicator, props, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
450
564
|
icon: faChevronDown
|
|
@@ -459,47 +573,41 @@ const Dropdown = _ref => {
|
|
|
459
573
|
invalidRole,
|
|
460
574
|
disabled,
|
|
461
575
|
labelText,
|
|
462
|
-
|
|
463
|
-
options
|
|
576
|
+
components: selectComponents
|
|
464
577
|
} = _ref,
|
|
465
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
466
|
-
const hasOnChange = !!onChange;
|
|
467
|
-
|
|
578
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
468
579
|
// Randomly generated id
|
|
469
580
|
const instanceId = useId();
|
|
470
581
|
|
|
471
582
|
// format of the id on the actual <input /> element created by react-select
|
|
472
583
|
// using the instanceID prop
|
|
473
584
|
const inputId = "react-select-".concat(instanceId, "-input");
|
|
585
|
+
const mergedComponents = _objectSpread({
|
|
586
|
+
DropdownIndicator
|
|
587
|
+
}, selectComponents);
|
|
474
588
|
const dropdownClassNames = classNames('jfcl-dropdown', {
|
|
475
589
|
['jfcl-dropdown--is-invalid']: invalid
|
|
476
590
|
}, className);
|
|
477
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputHeader, {
|
|
591
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, labelText || helperText || invalid && invalidText ? /*#__PURE__*/React.createElement(InputHeader, {
|
|
478
592
|
headerText: labelText,
|
|
479
593
|
labelFor: inputId,
|
|
480
594
|
helperText: helperText,
|
|
481
595
|
invalid: invalid,
|
|
482
596
|
invalidText: invalidText,
|
|
483
597
|
invalidRole: invalidRole
|
|
484
|
-
}), /*#__PURE__*/React.createElement(Select, _extends({
|
|
598
|
+
}) : null, /*#__PURE__*/React.createElement(Select, _extends({
|
|
485
599
|
placeholder: null
|
|
486
600
|
}, props, {
|
|
487
601
|
instanceId: instanceId,
|
|
488
602
|
className: dropdownClassNames,
|
|
489
603
|
classNamePrefix: "jfcl-dropdown",
|
|
490
604
|
isDisabled: disabled,
|
|
491
|
-
|
|
492
|
-
}, hasOnChange && {
|
|
493
|
-
onChange: onChange
|
|
494
|
-
}, {
|
|
495
|
-
components: {
|
|
496
|
-
DropdownIndicator
|
|
497
|
-
}
|
|
605
|
+
components: mergedComponents
|
|
498
606
|
})));
|
|
499
607
|
};
|
|
500
608
|
Dropdown.displayName = 'Dropdown';
|
|
501
609
|
|
|
502
|
-
const _excluded$
|
|
610
|
+
const _excluded$7 = ["className", "children", "invalidText", "invalidRole", "invalid", "helperText", "helperElement", "legendText"];
|
|
503
611
|
/**
|
|
504
612
|
* Accepts all `HTMLFieldSetElement`
|
|
505
613
|
*/
|
|
@@ -514,7 +622,7 @@ const FormGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
514
622
|
helperElement,
|
|
515
623
|
legendText
|
|
516
624
|
} = _ref,
|
|
517
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
625
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
518
626
|
const fieldsetClassNames = classNames('jfcl-form-group', {
|
|
519
627
|
['jfcl-form-group-is-invalid']: invalid
|
|
520
628
|
}, className);
|
|
@@ -534,6 +642,295 @@ const FormGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
534
642
|
});
|
|
535
643
|
FormGroup.displayName = 'FormGroup';
|
|
536
644
|
|
|
645
|
+
const _excluded$6 = ["initialAddress", "onSelect", "onChange", "onInputChange", "customGeoAutocompleteUrl", "throttleMs", "includeFullResponse", "serviceUnavailableText", "onRequestError", "noOptionsMessage", "className", "invalid", "invalidText"];
|
|
646
|
+
const DEFAULT_THROTTLE_MS = 250;
|
|
647
|
+
const GEO_AUTOCOMPLETE_URL = 'https://geosearch.planninglabs.nyc/v2/autocomplete';
|
|
648
|
+
const toTitleCase = value => value.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase());
|
|
649
|
+
const formatGeosearchAddress = feature => {
|
|
650
|
+
const {
|
|
651
|
+
name,
|
|
652
|
+
borough,
|
|
653
|
+
postalcode
|
|
654
|
+
} = feature.properties;
|
|
655
|
+
const formattedName = toTitleCase(name !== null && name !== void 0 ? name : '');
|
|
656
|
+
const boroughName = borough !== null && borough !== void 0 ? borough : '';
|
|
657
|
+
const zipCode = postalcode !== null && postalcode !== void 0 ? postalcode : '';
|
|
658
|
+
return "".concat(formattedName, ", ").concat(boroughName, ", ").concat(zipCode).trim();
|
|
659
|
+
};
|
|
660
|
+
const normalizeFeature = feature => {
|
|
661
|
+
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;
|
|
662
|
+
const typedFeature = feature;
|
|
663
|
+
return {
|
|
664
|
+
type: typedFeature.type,
|
|
665
|
+
geometry: {
|
|
666
|
+
type: (_typedFeature$geometr = typedFeature.geometry) === null || _typedFeature$geometr === void 0 ? void 0 : _typedFeature$geometr.type,
|
|
667
|
+
coordinates: (_typedFeature$geometr2 = (_typedFeature$geometr3 = typedFeature.geometry) === null || _typedFeature$geometr3 === void 0 ? void 0 : _typedFeature$geometr3.coordinates) !== null && _typedFeature$geometr2 !== void 0 ? _typedFeature$geometr2 : []
|
|
668
|
+
},
|
|
669
|
+
properties: {
|
|
670
|
+
borough: (_typedFeature$propert = typedFeature.properties) === null || _typedFeature$propert === void 0 ? void 0 : _typedFeature$propert.borough,
|
|
671
|
+
borough_gid: (_typedFeature$propert2 = typedFeature.properties) === null || _typedFeature$propert2 === void 0 ? void 0 : _typedFeature$propert2.borough_gid,
|
|
672
|
+
housenumber: (_typedFeature$propert3 = typedFeature.properties) === null || _typedFeature$propert3 === void 0 ? void 0 : _typedFeature$propert3.housenumber,
|
|
673
|
+
street: (_typedFeature$propert4 = typedFeature.properties) === null || _typedFeature$propert4 === void 0 ? void 0 : _typedFeature$propert4.street,
|
|
674
|
+
name: (_typedFeature$propert5 = typedFeature.properties) === null || _typedFeature$propert5 === void 0 ? void 0 : _typedFeature$propert5.name,
|
|
675
|
+
label: (_typedFeature$propert6 = typedFeature.properties) === null || _typedFeature$propert6 === void 0 ? void 0 : _typedFeature$propert6.label,
|
|
676
|
+
addendum: {
|
|
677
|
+
pad: {
|
|
678
|
+
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,
|
|
679
|
+
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
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
postalcode: (_typedFeature$propert9 = typedFeature.properties) === null || _typedFeature$propert9 === void 0 ? void 0 : _typedFeature$propert9.postalcode
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
const normalizeResults = (rawResults, queryText) => {
|
|
687
|
+
var _typedResults$query$t, _typedResults$query, _typedResults$feature;
|
|
688
|
+
const typedResults = rawResults;
|
|
689
|
+
return {
|
|
690
|
+
bbox: typedResults.bbox,
|
|
691
|
+
query: {
|
|
692
|
+
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
|
|
693
|
+
},
|
|
694
|
+
features: ((_typedResults$feature = typedResults.features) !== null && _typedResults$feature !== void 0 ? _typedResults$feature : []).map(feature => normalizeFeature(feature))
|
|
695
|
+
};
|
|
696
|
+
};
|
|
697
|
+
const GeoSearchDropdown = _ref => {
|
|
698
|
+
let {
|
|
699
|
+
initialAddress,
|
|
700
|
+
onSelect,
|
|
701
|
+
onChange,
|
|
702
|
+
onInputChange,
|
|
703
|
+
customGeoAutocompleteUrl,
|
|
704
|
+
throttleMs,
|
|
705
|
+
includeFullResponse = false,
|
|
706
|
+
serviceUnavailableText,
|
|
707
|
+
onRequestError,
|
|
708
|
+
noOptionsMessage,
|
|
709
|
+
className,
|
|
710
|
+
invalid,
|
|
711
|
+
invalidText
|
|
712
|
+
} = _ref,
|
|
713
|
+
dropdownProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
714
|
+
const [response, setResponse] = useState(null);
|
|
715
|
+
const [fullResponse, setFullResponse] = useState(null);
|
|
716
|
+
const [options, setOptions] = useState([]);
|
|
717
|
+
const [selectedValue, setSelectedValue] = useState(null);
|
|
718
|
+
const [isServiceUnavailable, setIsServiceUnavailable] = useState(false);
|
|
719
|
+
const requestIdRef = useRef(0);
|
|
720
|
+
const timerRef = useRef(null);
|
|
721
|
+
const abortRef = useRef(null);
|
|
722
|
+
const clearPendingRequests = useCallback(() => {
|
|
723
|
+
if (timerRef.current) {
|
|
724
|
+
clearTimeout(timerRef.current);
|
|
725
|
+
timerRef.current = null;
|
|
726
|
+
}
|
|
727
|
+
if (abortRef.current) {
|
|
728
|
+
abortRef.current.abort();
|
|
729
|
+
abortRef.current = null;
|
|
730
|
+
}
|
|
731
|
+
}, []);
|
|
732
|
+
const runSearch = useCallback(value => {
|
|
733
|
+
requestIdRef.current += 1;
|
|
734
|
+
const requestId = requestIdRef.current;
|
|
735
|
+
clearPendingRequests();
|
|
736
|
+
if (!value.trim()) {
|
|
737
|
+
setIsServiceUnavailable(false);
|
|
738
|
+
setResponse(null);
|
|
739
|
+
setFullResponse(null);
|
|
740
|
+
setOptions([]);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
timerRef.current = setTimeout(async () => {
|
|
744
|
+
const controller = new AbortController();
|
|
745
|
+
abortRef.current = controller;
|
|
746
|
+
try {
|
|
747
|
+
const endpoint = customGeoAutocompleteUrl || GEO_AUTOCOMPLETE_URL;
|
|
748
|
+
const result = await fetch("".concat(endpoint, "?text=").concat(encodeURIComponent(value)), {
|
|
749
|
+
signal: controller.signal
|
|
750
|
+
});
|
|
751
|
+
if (result.status !== 200) {
|
|
752
|
+
const requestError = new Error("Received HTTP ".concat(result.status));
|
|
753
|
+
requestError.status = result.status;
|
|
754
|
+
throw requestError;
|
|
755
|
+
}
|
|
756
|
+
const rawJson = await result.json();
|
|
757
|
+
const json = normalizeResults(rawJson, value);
|
|
758
|
+
if (requestIdRef.current !== requestId) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
setIsServiceUnavailable(false);
|
|
762
|
+
setResponse(json);
|
|
763
|
+
setFullResponse(rawJson);
|
|
764
|
+
setOptions(json.features.map(feature => {
|
|
765
|
+
const label = formatGeosearchAddress(feature);
|
|
766
|
+
return {
|
|
767
|
+
value: label,
|
|
768
|
+
label,
|
|
769
|
+
feature
|
|
770
|
+
};
|
|
771
|
+
}));
|
|
772
|
+
} catch (error) {
|
|
773
|
+
const requestError = error;
|
|
774
|
+
if (requestError.name === 'AbortError') {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (requestIdRef.current !== requestId) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const requestIsServiceUnavailable = requestError.status === 503;
|
|
781
|
+
setIsServiceUnavailable(requestIsServiceUnavailable);
|
|
782
|
+
if (requestIsServiceUnavailable) {
|
|
783
|
+
setResponse(null);
|
|
784
|
+
setFullResponse(null);
|
|
785
|
+
setOptions([]);
|
|
786
|
+
}
|
|
787
|
+
onRequestError === null || onRequestError === void 0 || onRequestError(requestError);
|
|
788
|
+
}
|
|
789
|
+
}, throttleMs !== null && throttleMs !== void 0 ? throttleMs : DEFAULT_THROTTLE_MS);
|
|
790
|
+
}, [clearPendingRequests, customGeoAutocompleteUrl, onRequestError, throttleMs]);
|
|
791
|
+
useEffect(() => {
|
|
792
|
+
if (initialAddress) {
|
|
793
|
+
const addressValue = toTitleCase(initialAddress);
|
|
794
|
+
setSelectedValue({
|
|
795
|
+
value: addressValue,
|
|
796
|
+
label: addressValue
|
|
797
|
+
});
|
|
798
|
+
runSearch(addressValue);
|
|
799
|
+
}
|
|
800
|
+
}, [initialAddress, runSearch]);
|
|
801
|
+
useEffect(() => {
|
|
802
|
+
return () => {
|
|
803
|
+
clearPendingRequests();
|
|
804
|
+
};
|
|
805
|
+
}, [clearPendingRequests]);
|
|
806
|
+
const showServiceUnavailableState = isServiceUnavailable && !!serviceUnavailableText;
|
|
807
|
+
const effectiveInvalid = !!invalid || showServiceUnavailableState;
|
|
808
|
+
const effectiveInvalidText = showServiceUnavailableState ? serviceUnavailableText : invalidText;
|
|
809
|
+
return /*#__PURE__*/React.createElement(Dropdown, _extends({}, dropdownProps, {
|
|
810
|
+
className: "jfcl-geosearch-dropdown ".concat(className !== null && className !== void 0 ? className : '').trim(),
|
|
811
|
+
invalid: effectiveInvalid,
|
|
812
|
+
invalidText: effectiveInvalidText,
|
|
813
|
+
options: options,
|
|
814
|
+
value: selectedValue,
|
|
815
|
+
filterOption: null,
|
|
816
|
+
escapeClearsValue: false,
|
|
817
|
+
noOptionsMessage: noOptionsMessage !== null && noOptionsMessage !== void 0 ? noOptionsMessage : () => 'Enter an address to get started',
|
|
818
|
+
onInputChange: (value, meta) => {
|
|
819
|
+
runSearch(value);
|
|
820
|
+
return onInputChange ? onInputChange(value, meta) : value;
|
|
821
|
+
},
|
|
822
|
+
onChange: (newValue, actionMeta) => {
|
|
823
|
+
setSelectedValue(newValue);
|
|
824
|
+
onChange === null || onChange === void 0 || onChange(newValue, actionMeta);
|
|
825
|
+
if (!newValue || !newValue.feature) {
|
|
826
|
+
onSelect === null || onSelect === void 0 || onSelect(null);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
onSelect === null || onSelect === void 0 || onSelect({
|
|
830
|
+
option: newValue,
|
|
831
|
+
feature: newValue.feature,
|
|
832
|
+
response,
|
|
833
|
+
fullResponse: includeFullResponse ? fullResponse : undefined
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
}));
|
|
837
|
+
};
|
|
838
|
+
GeoSearchDropdown.displayName = 'GeoSearchDropdown';
|
|
839
|
+
|
|
840
|
+
const _excluded$5 = ["children", "color", "role", "className"];
|
|
841
|
+
const InfoBox = _ref => {
|
|
842
|
+
let {
|
|
843
|
+
children,
|
|
844
|
+
color = 'white',
|
|
845
|
+
role,
|
|
846
|
+
className
|
|
847
|
+
} = _ref,
|
|
848
|
+
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
849
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
850
|
+
className: classNames('jfcl-info-box', "jfcl-info-box--".concat(color), className),
|
|
851
|
+
role: role,
|
|
852
|
+
"data-testid": "jfcl-info-box"
|
|
853
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
854
|
+
className: "jfcl-info-box__icon-container"
|
|
855
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
856
|
+
icon: color === 'orange' ? 'circleExclamation' : 'circleInfo',
|
|
857
|
+
"aria-hidden": true
|
|
858
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
859
|
+
className: "jfcl-info-box__content-container"
|
|
860
|
+
}, children));
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
const _excluded$4 = ["icon", "children", "className", "type"];
|
|
864
|
+
/**
|
|
865
|
+
* Use for in-page actions that should look like a text link.
|
|
866
|
+
*/
|
|
867
|
+
const LinkStyledButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
868
|
+
let {
|
|
869
|
+
icon,
|
|
870
|
+
children,
|
|
871
|
+
className,
|
|
872
|
+
type = 'button'
|
|
873
|
+
} = _ref,
|
|
874
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
875
|
+
const buttonClassNames = classNames('jfcl-link', 'jfcl-link-styled-button', className);
|
|
876
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, props, {
|
|
877
|
+
ref: ref,
|
|
878
|
+
type: type,
|
|
879
|
+
className: buttonClassNames,
|
|
880
|
+
"data-testid": "jfcl-link-styled-button"
|
|
881
|
+
}), children, icon === 'internal' && /*#__PURE__*/React.createElement(Icon, {
|
|
882
|
+
icon: "arrowRight",
|
|
883
|
+
className: "jfcl-link__icon"
|
|
884
|
+
}), icon === 'external' && /*#__PURE__*/React.createElement(Icon, {
|
|
885
|
+
icon: "squareArrowUpRight",
|
|
886
|
+
className: "jfcl-link__icon"
|
|
887
|
+
}));
|
|
888
|
+
});
|
|
889
|
+
LinkStyledButton.displayName = 'LinkStyledButton';
|
|
890
|
+
|
|
891
|
+
const Notice = _ref => {
|
|
892
|
+
let {
|
|
893
|
+
icon,
|
|
894
|
+
color,
|
|
895
|
+
header,
|
|
896
|
+
headingLevel,
|
|
897
|
+
children,
|
|
898
|
+
className
|
|
899
|
+
} = _ref;
|
|
900
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
901
|
+
className: classNames('jfcl-notice', color && "jfcl-notice--".concat(color), className),
|
|
902
|
+
"data-testid": "jfcl-notice"
|
|
903
|
+
}, icon && /*#__PURE__*/React.createElement("div", {
|
|
904
|
+
className: "jfcl-notice__icon-container"
|
|
905
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
906
|
+
icon: icon,
|
|
907
|
+
"aria-hidden": true
|
|
908
|
+
})), /*#__PURE__*/React.createElement("section", {
|
|
909
|
+
className: "jfcl-notice__content-container"
|
|
910
|
+
}, header && /*#__PURE__*/React.createElement(Heading, {
|
|
911
|
+
level: headingLevel,
|
|
912
|
+
className: "jfcl-notice__header"
|
|
913
|
+
}, header), /*#__PURE__*/React.createElement("div", {
|
|
914
|
+
className: "jfcl-notice__body"
|
|
915
|
+
}, children)));
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
const _excluded$3 = ["color", "children", "className", "circle"];
|
|
919
|
+
const Pill = _ref => {
|
|
920
|
+
let {
|
|
921
|
+
color,
|
|
922
|
+
children,
|
|
923
|
+
className,
|
|
924
|
+
circle = false
|
|
925
|
+
} = _ref,
|
|
926
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
927
|
+
const pillClassNames = classNames('jfcl-pill', "jfcl-pill--".concat(color), circle && 'jfcl-pill--circle', className);
|
|
928
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
929
|
+
className: pillClassNames,
|
|
930
|
+
"data-testid": "jfcl-pill"
|
|
931
|
+
}, props), children);
|
|
932
|
+
};
|
|
933
|
+
|
|
537
934
|
const _excluded$2 = ["className", "invalidText", "invalidRole", "invalid", "headerText", "helperText", "labelText", "labelElement", "disabled", "id"];
|
|
538
935
|
/**
|
|
539
936
|
* Accepts all `InputHTMLAttributes`
|
|
@@ -672,4 +1069,4 @@ const TextInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
672
1069
|
});
|
|
673
1070
|
TextInput.displayName = 'TextInput';
|
|
674
1071
|
|
|
675
|
-
export { Alert, Button, Checkbox, Dropdown, FormGroup, Icon, Link, RadioButton, SelectButton, TextInput };
|
|
1072
|
+
export { Accordion, Alert, Button, ButtonStyledLink, CalloutBox, Checkbox, Dropdown, FormGroup, GeoSearchDropdown, Heading, Icon, InfoBox, Link, LinkStyledButton, Notice, Pill, RadioButton, SelectButton, TextInput };
|