@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.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':
|
|
@@ -169,6 +171,9 @@ const Icon = _ref => {
|
|
|
169
171
|
case 'memoPad':
|
|
170
172
|
faIcon = solid.faMemoPad;
|
|
171
173
|
break;
|
|
174
|
+
case 'mobileScreenButton':
|
|
175
|
+
faIcon = solid.faMobileScreenButton;
|
|
176
|
+
break;
|
|
172
177
|
case 'mapLocationDot':
|
|
173
178
|
faIcon = solid.faMapLocationDot;
|
|
174
179
|
break;
|
|
@@ -199,6 +204,12 @@ const Icon = _ref => {
|
|
|
199
204
|
case 'eyeSlash':
|
|
200
205
|
faIcon = regular.faEyeSlash;
|
|
201
206
|
break;
|
|
207
|
+
case 'fileLight':
|
|
208
|
+
faIcon = light.faFile;
|
|
209
|
+
break;
|
|
210
|
+
case 'fileRegular':
|
|
211
|
+
faIcon = regular.faFile;
|
|
212
|
+
break;
|
|
202
213
|
case 'print':
|
|
203
214
|
faIcon = regular.faPrint;
|
|
204
215
|
break;
|
|
@@ -222,14 +233,14 @@ const Icon = _ref => {
|
|
|
222
233
|
};
|
|
223
234
|
Icon.displayName = 'Icon';
|
|
224
235
|
|
|
225
|
-
const _excluded$
|
|
236
|
+
const _excluded$g = ["icon", "children", "className"];
|
|
226
237
|
const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
227
238
|
let {
|
|
228
239
|
icon,
|
|
229
240
|
children,
|
|
230
241
|
className
|
|
231
242
|
} = _ref,
|
|
232
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
243
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$g);
|
|
233
244
|
const linkClassNames = classNames__default["default"]('jfcl-link', className);
|
|
234
245
|
const opensInNewTab = props.target === '_blank';
|
|
235
246
|
// When using this component within a react-router-dom <Link />, a navigate function is passed through the props us here.
|
|
@@ -255,7 +266,7 @@ const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
255
266
|
});
|
|
256
267
|
Link.displayName = 'Link';
|
|
257
268
|
|
|
258
|
-
const _excluded$
|
|
269
|
+
const _excluded$f = ["type", "variant", "text", "action", "actionHref", "actionLabel", "className"];
|
|
259
270
|
const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
260
271
|
let {
|
|
261
272
|
type = 'info',
|
|
@@ -266,7 +277,7 @@ const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
266
277
|
actionLabel,
|
|
267
278
|
className
|
|
268
279
|
} = _ref,
|
|
269
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
280
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$f);
|
|
270
281
|
const alertClassNames = classNames__default["default"]('jfcl-alert', "jfcl-variant-".concat(variant), "jfcl-type-".concat(type), className);
|
|
271
282
|
const hasAction = !!action;
|
|
272
283
|
const showButton = hasAction && !actionHref;
|
|
@@ -302,7 +313,35 @@ const Alert = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
302
313
|
});
|
|
303
314
|
Alert.displayName = 'Alert';
|
|
304
315
|
|
|
305
|
-
const _excluded$
|
|
316
|
+
const _excluded$e = ["summary", "children", "open", "className", "onClick", "id"];
|
|
317
|
+
const Accordion = _ref => {
|
|
318
|
+
let {
|
|
319
|
+
summary,
|
|
320
|
+
children,
|
|
321
|
+
open = false,
|
|
322
|
+
className,
|
|
323
|
+
onClick,
|
|
324
|
+
id
|
|
325
|
+
} = _ref,
|
|
326
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$e);
|
|
327
|
+
return /*#__PURE__*/React__default["default"].createElement("details", _extends__default["default"]({
|
|
328
|
+
className: classNames__default["default"]('jfcl-accordion', className),
|
|
329
|
+
open: open,
|
|
330
|
+
onClick: onClick,
|
|
331
|
+
id: id,
|
|
332
|
+
"data-testid": "jfcl-accordion"
|
|
333
|
+
}, props), /*#__PURE__*/React__default["default"].createElement("summary", {
|
|
334
|
+
className: "jfcl-accordion__summary"
|
|
335
|
+
}, summary, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
336
|
+
icon: "chevronDown",
|
|
337
|
+
className: "jfcl-accordion__chevron",
|
|
338
|
+
"aria-hidden": true
|
|
339
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
340
|
+
className: "jfcl-accordion__content"
|
|
341
|
+
}, children));
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const _excluded$d = ["labelText", "variant", "size", "loading", "labelIcon", "iconOnRight", "iconOnly", "className"];
|
|
306
345
|
/**
|
|
307
346
|
* Accepts all `ButtonHTMLAttributes`
|
|
308
347
|
*/
|
|
@@ -317,7 +356,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
317
356
|
iconOnly,
|
|
318
357
|
className
|
|
319
358
|
} = _ref,
|
|
320
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
359
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$d);
|
|
321
360
|
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
361
|
const iconClassNames = classNames__default["default"]('jfcl-button__icon', "".concat(iconOnRight ? 'jfcl-button__icon_right' : ''));
|
|
323
362
|
const arias = {};
|
|
@@ -343,6 +382,80 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =>
|
|
|
343
382
|
});
|
|
344
383
|
Button.displayName = 'Button';
|
|
345
384
|
|
|
385
|
+
const _excluded$c = ["labelText", "variant", "size", "className"];
|
|
386
|
+
/**
|
|
387
|
+
* Use for navigation actions that should look like a button.
|
|
388
|
+
*/
|
|
389
|
+
const ButtonStyledLink = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
390
|
+
let {
|
|
391
|
+
labelText,
|
|
392
|
+
variant = 'primary',
|
|
393
|
+
size = 'large',
|
|
394
|
+
className
|
|
395
|
+
} = _ref,
|
|
396
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$c);
|
|
397
|
+
const linkClassNames = classNames__default["default"]('jfcl-button', 'jfcl-button-styled-link', "jfcl-variant-".concat(variant), "jfcl-size-".concat(size), className);
|
|
398
|
+
return /*#__PURE__*/React__default["default"].createElement("a", _extends__default["default"]({}, props, {
|
|
399
|
+
ref: ref,
|
|
400
|
+
className: linkClassNames,
|
|
401
|
+
"data-testid": "jfcl-button-styled-link"
|
|
402
|
+
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
403
|
+
className: "jfcl-button__label"
|
|
404
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
405
|
+
className: "jfcl-button__text"
|
|
406
|
+
}, labelText)));
|
|
407
|
+
});
|
|
408
|
+
ButtonStyledLink.displayName = 'ButtonStyledLink';
|
|
409
|
+
|
|
410
|
+
const _excluded$b = ["children", "className", "level"];
|
|
411
|
+
function isInteger(value) {
|
|
412
|
+
return Number.isInteger(value);
|
|
413
|
+
}
|
|
414
|
+
function isHeadingLevel(value) {
|
|
415
|
+
return [1, 2, 3, 4, 5, 6].includes(value);
|
|
416
|
+
}
|
|
417
|
+
const Heading = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
418
|
+
let {
|
|
419
|
+
children,
|
|
420
|
+
className,
|
|
421
|
+
level
|
|
422
|
+
} = _ref,
|
|
423
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$b);
|
|
424
|
+
if (!isInteger(level)) {
|
|
425
|
+
console.error('Heading level must be integer');
|
|
426
|
+
}
|
|
427
|
+
const Tag = isHeadingLevel(level) ? "h".concat(level) : 'span';
|
|
428
|
+
const headingClassNames = classNames__default["default"]('jfcl-heading', "jfcl-heading--h".concat(level), className);
|
|
429
|
+
return /*#__PURE__*/React__default["default"].createElement(Tag, _extends__default["default"]({
|
|
430
|
+
ref: ref,
|
|
431
|
+
className: headingClassNames
|
|
432
|
+
}, props), children);
|
|
433
|
+
});
|
|
434
|
+
Heading.displayName = 'Heading';
|
|
435
|
+
|
|
436
|
+
const _excluded$a = ["title", "children", "action", "headingLevel", "className"];
|
|
437
|
+
const CalloutBox = _ref => {
|
|
438
|
+
let {
|
|
439
|
+
title,
|
|
440
|
+
children,
|
|
441
|
+
action,
|
|
442
|
+
headingLevel = 4,
|
|
443
|
+
className
|
|
444
|
+
} = _ref,
|
|
445
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$a);
|
|
446
|
+
return /*#__PURE__*/React__default["default"].createElement("section", _extends__default["default"]({
|
|
447
|
+
className: classNames__default["default"]('jfcl-callout-box', className),
|
|
448
|
+
"data-testid": "jfcl-callout-box"
|
|
449
|
+
}, props), /*#__PURE__*/React__default["default"].createElement(Heading, {
|
|
450
|
+
level: headingLevel,
|
|
451
|
+
className: "jfcl-callout-box__header"
|
|
452
|
+
}, title), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
453
|
+
className: "jfcl-callout-box__content"
|
|
454
|
+
}, children), action && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
455
|
+
className: "jfcl-callout-box__action"
|
|
456
|
+
}, action));
|
|
457
|
+
};
|
|
458
|
+
|
|
346
459
|
const HeaderLabel = _ref => {
|
|
347
460
|
let {
|
|
348
461
|
labelFor,
|
|
@@ -401,7 +514,7 @@ const InputHeader = _ref2 => {
|
|
|
401
514
|
}), invalidText)));
|
|
402
515
|
};
|
|
403
516
|
|
|
404
|
-
const _excluded$
|
|
517
|
+
const _excluded$9 = ["className", "invalidText", "invalidRole", "invalid", "headerText", "helperText", "labelText", "disabled", "id"];
|
|
405
518
|
/**
|
|
406
519
|
* Accepts all `InputHTMLAttributes`
|
|
407
520
|
*/
|
|
@@ -417,7 +530,7 @@ const Checkbox = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
417
530
|
disabled,
|
|
418
531
|
id
|
|
419
532
|
} = _ref,
|
|
420
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
533
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$9);
|
|
421
534
|
const checkboxClassNames = classNames__default["default"]('jfcl-checkbox', {
|
|
422
535
|
['jfcl-checkbox--is-disabled']: disabled
|
|
423
536
|
}, className);
|
|
@@ -456,7 +569,9 @@ const Checkbox = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
456
569
|
});
|
|
457
570
|
Checkbox.displayName = 'Checkbox';
|
|
458
571
|
|
|
459
|
-
const _excluded$
|
|
572
|
+
const _excluded$8 = ["className", "helperText", "invalid", "invalidText", "invalidRole", "disabled", "labelText", "components"];
|
|
573
|
+
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; }
|
|
574
|
+
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
575
|
const DropdownIndicator = props => {
|
|
461
576
|
return /*#__PURE__*/React__default["default"].createElement(Select.components.DropdownIndicator, props, /*#__PURE__*/React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, {
|
|
462
577
|
icon: solid.faChevronDown
|
|
@@ -471,47 +586,41 @@ const Dropdown = _ref => {
|
|
|
471
586
|
invalidRole,
|
|
472
587
|
disabled,
|
|
473
588
|
labelText,
|
|
474
|
-
|
|
475
|
-
options
|
|
589
|
+
components: selectComponents
|
|
476
590
|
} = _ref,
|
|
477
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
478
|
-
const hasOnChange = !!onChange;
|
|
479
|
-
|
|
591
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$8);
|
|
480
592
|
// Randomly generated id
|
|
481
593
|
const instanceId = React.useId();
|
|
482
594
|
|
|
483
595
|
// format of the id on the actual <input /> element created by react-select
|
|
484
596
|
// using the instanceID prop
|
|
485
597
|
const inputId = "react-select-".concat(instanceId, "-input");
|
|
598
|
+
const mergedComponents = _objectSpread({
|
|
599
|
+
DropdownIndicator
|
|
600
|
+
}, selectComponents);
|
|
486
601
|
const dropdownClassNames = classNames__default["default"]('jfcl-dropdown', {
|
|
487
602
|
['jfcl-dropdown--is-invalid']: invalid
|
|
488
603
|
}, className);
|
|
489
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(InputHeader, {
|
|
604
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, labelText || helperText || invalid && invalidText ? /*#__PURE__*/React__default["default"].createElement(InputHeader, {
|
|
490
605
|
headerText: labelText,
|
|
491
606
|
labelFor: inputId,
|
|
492
607
|
helperText: helperText,
|
|
493
608
|
invalid: invalid,
|
|
494
609
|
invalidText: invalidText,
|
|
495
610
|
invalidRole: invalidRole
|
|
496
|
-
}), /*#__PURE__*/React__default["default"].createElement(Select__default["default"], _extends__default["default"]({
|
|
611
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement(Select__default["default"], _extends__default["default"]({
|
|
497
612
|
placeholder: null
|
|
498
613
|
}, props, {
|
|
499
614
|
instanceId: instanceId,
|
|
500
615
|
className: dropdownClassNames,
|
|
501
616
|
classNamePrefix: "jfcl-dropdown",
|
|
502
617
|
isDisabled: disabled,
|
|
503
|
-
|
|
504
|
-
}, hasOnChange && {
|
|
505
|
-
onChange: onChange
|
|
506
|
-
}, {
|
|
507
|
-
components: {
|
|
508
|
-
DropdownIndicator
|
|
509
|
-
}
|
|
618
|
+
components: mergedComponents
|
|
510
619
|
})));
|
|
511
620
|
};
|
|
512
621
|
Dropdown.displayName = 'Dropdown';
|
|
513
622
|
|
|
514
|
-
const _excluded$
|
|
623
|
+
const _excluded$7 = ["className", "children", "invalidText", "invalidRole", "invalid", "helperText", "helperElement", "legendText"];
|
|
515
624
|
/**
|
|
516
625
|
* Accepts all `HTMLFieldSetElement`
|
|
517
626
|
*/
|
|
@@ -526,7 +635,7 @@ const FormGroup = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
526
635
|
helperElement,
|
|
527
636
|
legendText
|
|
528
637
|
} = _ref,
|
|
529
|
-
props = _objectWithoutProperties__default["default"](_ref, _excluded$
|
|
638
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$7);
|
|
530
639
|
const fieldsetClassNames = classNames__default["default"]('jfcl-form-group', {
|
|
531
640
|
['jfcl-form-group-is-invalid']: invalid
|
|
532
641
|
}, className);
|
|
@@ -546,6 +655,295 @@ const FormGroup = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
546
655
|
});
|
|
547
656
|
FormGroup.displayName = 'FormGroup';
|
|
548
657
|
|
|
658
|
+
const _excluded$6 = ["initialAddress", "onSelect", "onChange", "onInputChange", "customGeoAutocompleteUrl", "throttleMs", "includeFullResponse", "serviceUnavailableText", "onRequestError", "noOptionsMessage", "className", "invalid", "invalidText"];
|
|
659
|
+
const DEFAULT_THROTTLE_MS = 250;
|
|
660
|
+
const GEO_AUTOCOMPLETE_URL = 'https://geosearch.planninglabs.nyc/v2/autocomplete';
|
|
661
|
+
const toTitleCase = value => value.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase());
|
|
662
|
+
const formatGeosearchAddress = feature => {
|
|
663
|
+
const {
|
|
664
|
+
name,
|
|
665
|
+
borough,
|
|
666
|
+
postalcode
|
|
667
|
+
} = feature.properties;
|
|
668
|
+
const formattedName = toTitleCase(name !== null && name !== void 0 ? name : '');
|
|
669
|
+
const boroughName = borough !== null && borough !== void 0 ? borough : '';
|
|
670
|
+
const zipCode = postalcode !== null && postalcode !== void 0 ? postalcode : '';
|
|
671
|
+
return "".concat(formattedName, ", ").concat(boroughName, ", ").concat(zipCode).trim();
|
|
672
|
+
};
|
|
673
|
+
const normalizeFeature = feature => {
|
|
674
|
+
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;
|
|
675
|
+
const typedFeature = feature;
|
|
676
|
+
return {
|
|
677
|
+
type: typedFeature.type,
|
|
678
|
+
geometry: {
|
|
679
|
+
type: (_typedFeature$geometr = typedFeature.geometry) === null || _typedFeature$geometr === void 0 ? void 0 : _typedFeature$geometr.type,
|
|
680
|
+
coordinates: (_typedFeature$geometr2 = (_typedFeature$geometr3 = typedFeature.geometry) === null || _typedFeature$geometr3 === void 0 ? void 0 : _typedFeature$geometr3.coordinates) !== null && _typedFeature$geometr2 !== void 0 ? _typedFeature$geometr2 : []
|
|
681
|
+
},
|
|
682
|
+
properties: {
|
|
683
|
+
borough: (_typedFeature$propert = typedFeature.properties) === null || _typedFeature$propert === void 0 ? void 0 : _typedFeature$propert.borough,
|
|
684
|
+
borough_gid: (_typedFeature$propert2 = typedFeature.properties) === null || _typedFeature$propert2 === void 0 ? void 0 : _typedFeature$propert2.borough_gid,
|
|
685
|
+
housenumber: (_typedFeature$propert3 = typedFeature.properties) === null || _typedFeature$propert3 === void 0 ? void 0 : _typedFeature$propert3.housenumber,
|
|
686
|
+
street: (_typedFeature$propert4 = typedFeature.properties) === null || _typedFeature$propert4 === void 0 ? void 0 : _typedFeature$propert4.street,
|
|
687
|
+
name: (_typedFeature$propert5 = typedFeature.properties) === null || _typedFeature$propert5 === void 0 ? void 0 : _typedFeature$propert5.name,
|
|
688
|
+
label: (_typedFeature$propert6 = typedFeature.properties) === null || _typedFeature$propert6 === void 0 ? void 0 : _typedFeature$propert6.label,
|
|
689
|
+
addendum: {
|
|
690
|
+
pad: {
|
|
691
|
+
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,
|
|
692
|
+
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
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
postalcode: (_typedFeature$propert9 = typedFeature.properties) === null || _typedFeature$propert9 === void 0 ? void 0 : _typedFeature$propert9.postalcode
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
const normalizeResults = (rawResults, queryText) => {
|
|
700
|
+
var _typedResults$query$t, _typedResults$query, _typedResults$feature;
|
|
701
|
+
const typedResults = rawResults;
|
|
702
|
+
return {
|
|
703
|
+
bbox: typedResults.bbox,
|
|
704
|
+
query: {
|
|
705
|
+
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
|
|
706
|
+
},
|
|
707
|
+
features: ((_typedResults$feature = typedResults.features) !== null && _typedResults$feature !== void 0 ? _typedResults$feature : []).map(feature => normalizeFeature(feature))
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
const GeoSearchDropdown = _ref => {
|
|
711
|
+
let {
|
|
712
|
+
initialAddress,
|
|
713
|
+
onSelect,
|
|
714
|
+
onChange,
|
|
715
|
+
onInputChange,
|
|
716
|
+
customGeoAutocompleteUrl,
|
|
717
|
+
throttleMs,
|
|
718
|
+
includeFullResponse = false,
|
|
719
|
+
serviceUnavailableText,
|
|
720
|
+
onRequestError,
|
|
721
|
+
noOptionsMessage,
|
|
722
|
+
className,
|
|
723
|
+
invalid,
|
|
724
|
+
invalidText
|
|
725
|
+
} = _ref,
|
|
726
|
+
dropdownProps = _objectWithoutProperties__default["default"](_ref, _excluded$6);
|
|
727
|
+
const [response, setResponse] = React.useState(null);
|
|
728
|
+
const [fullResponse, setFullResponse] = React.useState(null);
|
|
729
|
+
const [options, setOptions] = React.useState([]);
|
|
730
|
+
const [selectedValue, setSelectedValue] = React.useState(null);
|
|
731
|
+
const [isServiceUnavailable, setIsServiceUnavailable] = React.useState(false);
|
|
732
|
+
const requestIdRef = React.useRef(0);
|
|
733
|
+
const timerRef = React.useRef(null);
|
|
734
|
+
const abortRef = React.useRef(null);
|
|
735
|
+
const clearPendingRequests = React.useCallback(() => {
|
|
736
|
+
if (timerRef.current) {
|
|
737
|
+
clearTimeout(timerRef.current);
|
|
738
|
+
timerRef.current = null;
|
|
739
|
+
}
|
|
740
|
+
if (abortRef.current) {
|
|
741
|
+
abortRef.current.abort();
|
|
742
|
+
abortRef.current = null;
|
|
743
|
+
}
|
|
744
|
+
}, []);
|
|
745
|
+
const runSearch = React.useCallback(value => {
|
|
746
|
+
requestIdRef.current += 1;
|
|
747
|
+
const requestId = requestIdRef.current;
|
|
748
|
+
clearPendingRequests();
|
|
749
|
+
if (!value.trim()) {
|
|
750
|
+
setIsServiceUnavailable(false);
|
|
751
|
+
setResponse(null);
|
|
752
|
+
setFullResponse(null);
|
|
753
|
+
setOptions([]);
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
timerRef.current = setTimeout(async () => {
|
|
757
|
+
const controller = new AbortController();
|
|
758
|
+
abortRef.current = controller;
|
|
759
|
+
try {
|
|
760
|
+
const endpoint = customGeoAutocompleteUrl || GEO_AUTOCOMPLETE_URL;
|
|
761
|
+
const result = await fetch("".concat(endpoint, "?text=").concat(encodeURIComponent(value)), {
|
|
762
|
+
signal: controller.signal
|
|
763
|
+
});
|
|
764
|
+
if (result.status !== 200) {
|
|
765
|
+
const requestError = new Error("Received HTTP ".concat(result.status));
|
|
766
|
+
requestError.status = result.status;
|
|
767
|
+
throw requestError;
|
|
768
|
+
}
|
|
769
|
+
const rawJson = await result.json();
|
|
770
|
+
const json = normalizeResults(rawJson, value);
|
|
771
|
+
if (requestIdRef.current !== requestId) {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
setIsServiceUnavailable(false);
|
|
775
|
+
setResponse(json);
|
|
776
|
+
setFullResponse(rawJson);
|
|
777
|
+
setOptions(json.features.map(feature => {
|
|
778
|
+
const label = formatGeosearchAddress(feature);
|
|
779
|
+
return {
|
|
780
|
+
value: label,
|
|
781
|
+
label,
|
|
782
|
+
feature
|
|
783
|
+
};
|
|
784
|
+
}));
|
|
785
|
+
} catch (error) {
|
|
786
|
+
const requestError = error;
|
|
787
|
+
if (requestError.name === 'AbortError') {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
if (requestIdRef.current !== requestId) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
const requestIsServiceUnavailable = requestError.status === 503;
|
|
794
|
+
setIsServiceUnavailable(requestIsServiceUnavailable);
|
|
795
|
+
if (requestIsServiceUnavailable) {
|
|
796
|
+
setResponse(null);
|
|
797
|
+
setFullResponse(null);
|
|
798
|
+
setOptions([]);
|
|
799
|
+
}
|
|
800
|
+
onRequestError === null || onRequestError === void 0 || onRequestError(requestError);
|
|
801
|
+
}
|
|
802
|
+
}, throttleMs !== null && throttleMs !== void 0 ? throttleMs : DEFAULT_THROTTLE_MS);
|
|
803
|
+
}, [clearPendingRequests, customGeoAutocompleteUrl, onRequestError, throttleMs]);
|
|
804
|
+
React.useEffect(() => {
|
|
805
|
+
if (initialAddress) {
|
|
806
|
+
const addressValue = toTitleCase(initialAddress);
|
|
807
|
+
setSelectedValue({
|
|
808
|
+
value: addressValue,
|
|
809
|
+
label: addressValue
|
|
810
|
+
});
|
|
811
|
+
runSearch(addressValue);
|
|
812
|
+
}
|
|
813
|
+
}, [initialAddress, runSearch]);
|
|
814
|
+
React.useEffect(() => {
|
|
815
|
+
return () => {
|
|
816
|
+
clearPendingRequests();
|
|
817
|
+
};
|
|
818
|
+
}, [clearPendingRequests]);
|
|
819
|
+
const showServiceUnavailableState = isServiceUnavailable && !!serviceUnavailableText;
|
|
820
|
+
const effectiveInvalid = !!invalid || showServiceUnavailableState;
|
|
821
|
+
const effectiveInvalidText = showServiceUnavailableState ? serviceUnavailableText : invalidText;
|
|
822
|
+
return /*#__PURE__*/React__default["default"].createElement(Dropdown, _extends__default["default"]({}, dropdownProps, {
|
|
823
|
+
className: "jfcl-geosearch-dropdown ".concat(className !== null && className !== void 0 ? className : '').trim(),
|
|
824
|
+
invalid: effectiveInvalid,
|
|
825
|
+
invalidText: effectiveInvalidText,
|
|
826
|
+
options: options,
|
|
827
|
+
value: selectedValue,
|
|
828
|
+
filterOption: null,
|
|
829
|
+
escapeClearsValue: false,
|
|
830
|
+
noOptionsMessage: noOptionsMessage !== null && noOptionsMessage !== void 0 ? noOptionsMessage : () => 'Enter an address to get started',
|
|
831
|
+
onInputChange: (value, meta) => {
|
|
832
|
+
runSearch(value);
|
|
833
|
+
return onInputChange ? onInputChange(value, meta) : value;
|
|
834
|
+
},
|
|
835
|
+
onChange: (newValue, actionMeta) => {
|
|
836
|
+
setSelectedValue(newValue);
|
|
837
|
+
onChange === null || onChange === void 0 || onChange(newValue, actionMeta);
|
|
838
|
+
if (!newValue || !newValue.feature) {
|
|
839
|
+
onSelect === null || onSelect === void 0 || onSelect(null);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
onSelect === null || onSelect === void 0 || onSelect({
|
|
843
|
+
option: newValue,
|
|
844
|
+
feature: newValue.feature,
|
|
845
|
+
response,
|
|
846
|
+
fullResponse: includeFullResponse ? fullResponse : undefined
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
}));
|
|
850
|
+
};
|
|
851
|
+
GeoSearchDropdown.displayName = 'GeoSearchDropdown';
|
|
852
|
+
|
|
853
|
+
const _excluded$5 = ["children", "color", "role", "className"];
|
|
854
|
+
const InfoBox = _ref => {
|
|
855
|
+
let {
|
|
856
|
+
children,
|
|
857
|
+
color = 'white',
|
|
858
|
+
role,
|
|
859
|
+
className
|
|
860
|
+
} = _ref,
|
|
861
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$5);
|
|
862
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({
|
|
863
|
+
className: classNames__default["default"]('jfcl-info-box', "jfcl-info-box--".concat(color), className),
|
|
864
|
+
role: role,
|
|
865
|
+
"data-testid": "jfcl-info-box"
|
|
866
|
+
}, props), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
867
|
+
className: "jfcl-info-box__icon-container"
|
|
868
|
+
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
869
|
+
icon: color === 'orange' ? 'circleExclamation' : 'circleInfo',
|
|
870
|
+
"aria-hidden": true
|
|
871
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
872
|
+
className: "jfcl-info-box__content-container"
|
|
873
|
+
}, children));
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
const _excluded$4 = ["icon", "children", "className", "type"];
|
|
877
|
+
/**
|
|
878
|
+
* Use for in-page actions that should look like a text link.
|
|
879
|
+
*/
|
|
880
|
+
const LinkStyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
881
|
+
let {
|
|
882
|
+
icon,
|
|
883
|
+
children,
|
|
884
|
+
className,
|
|
885
|
+
type = 'button'
|
|
886
|
+
} = _ref,
|
|
887
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$4);
|
|
888
|
+
const buttonClassNames = classNames__default["default"]('jfcl-link', 'jfcl-link-styled-button', className);
|
|
889
|
+
return /*#__PURE__*/React__default["default"].createElement("button", _extends__default["default"]({}, props, {
|
|
890
|
+
ref: ref,
|
|
891
|
+
type: type,
|
|
892
|
+
className: buttonClassNames,
|
|
893
|
+
"data-testid": "jfcl-link-styled-button"
|
|
894
|
+
}), children, icon === 'internal' && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
895
|
+
icon: "arrowRight",
|
|
896
|
+
className: "jfcl-link__icon"
|
|
897
|
+
}), icon === 'external' && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
898
|
+
icon: "squareArrowUpRight",
|
|
899
|
+
className: "jfcl-link__icon"
|
|
900
|
+
}));
|
|
901
|
+
});
|
|
902
|
+
LinkStyledButton.displayName = 'LinkStyledButton';
|
|
903
|
+
|
|
904
|
+
const Notice = _ref => {
|
|
905
|
+
let {
|
|
906
|
+
icon,
|
|
907
|
+
color,
|
|
908
|
+
header,
|
|
909
|
+
headingLevel,
|
|
910
|
+
children,
|
|
911
|
+
className
|
|
912
|
+
} = _ref;
|
|
913
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
914
|
+
className: classNames__default["default"]('jfcl-notice', color && "jfcl-notice--".concat(color), className),
|
|
915
|
+
"data-testid": "jfcl-notice"
|
|
916
|
+
}, icon && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
917
|
+
className: "jfcl-notice__icon-container"
|
|
918
|
+
}, /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
919
|
+
icon: icon,
|
|
920
|
+
"aria-hidden": true
|
|
921
|
+
})), /*#__PURE__*/React__default["default"].createElement("section", {
|
|
922
|
+
className: "jfcl-notice__content-container"
|
|
923
|
+
}, header && /*#__PURE__*/React__default["default"].createElement(Heading, {
|
|
924
|
+
level: headingLevel,
|
|
925
|
+
className: "jfcl-notice__header"
|
|
926
|
+
}, header), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
927
|
+
className: "jfcl-notice__body"
|
|
928
|
+
}, children)));
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
const _excluded$3 = ["color", "children", "className", "circle"];
|
|
932
|
+
const Pill = _ref => {
|
|
933
|
+
let {
|
|
934
|
+
color,
|
|
935
|
+
children,
|
|
936
|
+
className,
|
|
937
|
+
circle = false
|
|
938
|
+
} = _ref,
|
|
939
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded$3);
|
|
940
|
+
const pillClassNames = classNames__default["default"]('jfcl-pill', "jfcl-pill--".concat(color), circle && 'jfcl-pill--circle', className);
|
|
941
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({
|
|
942
|
+
className: pillClassNames,
|
|
943
|
+
"data-testid": "jfcl-pill"
|
|
944
|
+
}, props), children);
|
|
945
|
+
};
|
|
946
|
+
|
|
549
947
|
const _excluded$2 = ["className", "invalidText", "invalidRole", "invalid", "headerText", "helperText", "labelText", "labelElement", "disabled", "id"];
|
|
550
948
|
/**
|
|
551
949
|
* Accepts all `InputHTMLAttributes`
|
|
@@ -684,13 +1082,22 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
684
1082
|
});
|
|
685
1083
|
TextInput.displayName = 'TextInput';
|
|
686
1084
|
|
|
1085
|
+
exports.Accordion = Accordion;
|
|
687
1086
|
exports.Alert = Alert;
|
|
688
1087
|
exports.Button = Button;
|
|
1088
|
+
exports.ButtonStyledLink = ButtonStyledLink;
|
|
1089
|
+
exports.CalloutBox = CalloutBox;
|
|
689
1090
|
exports.Checkbox = Checkbox;
|
|
690
1091
|
exports.Dropdown = Dropdown;
|
|
691
1092
|
exports.FormGroup = FormGroup;
|
|
1093
|
+
exports.GeoSearchDropdown = GeoSearchDropdown;
|
|
1094
|
+
exports.Heading = Heading;
|
|
692
1095
|
exports.Icon = Icon;
|
|
1096
|
+
exports.InfoBox = InfoBox;
|
|
693
1097
|
exports.Link = Link;
|
|
1098
|
+
exports.LinkStyledButton = LinkStyledButton;
|
|
1099
|
+
exports.Notice = Notice;
|
|
1100
|
+
exports.Pill = Pill;
|
|
694
1101
|
exports.RadioButton = RadioButton;
|
|
695
1102
|
exports.SelectButton = SelectButton;
|
|
696
1103
|
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>;
|