nsw-design-system 3.17.3 → 3.17.4

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/dist/js/main.js CHANGED
@@ -1855,6 +1855,8 @@
1855
1855
  this.showMoreContent = this.element.querySelectorAll(`.${this.prefix}${this.allClass}`);
1856
1856
  this.showMoreButtons = this.element.querySelectorAll(`.${this.prefix}${this.moreClass}`);
1857
1857
  this.focusableElements = 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])';
1858
+ // Get default selected option
1859
+ this.selectedOption = this.element.querySelector('option[selected]');
1858
1860
  // Accordion arrays
1859
1861
  this.buttons = [];
1860
1862
  this.content = [];
@@ -2002,11 +2004,23 @@
2002
2004
  if (this.options.length > 0) {
2003
2005
  this.options.forEach(input => {
2004
2006
  const option = input;
2005
- if (option.type === 'text' || option.type === 'select-one') {
2007
+ if (option.type === 'text') {
2006
2008
  option.value = '';
2009
+ } else if (option.type === 'select-one') {
2010
+ if (this.selectedOption) {
2011
+ console.log(Array.from(option.options).indexOf(this.selectedOption));
2012
+ option.selectedIndex = Array.from(option.options).indexOf(this.selectedOption);
2013
+ } else {
2014
+ option.selectedIndex = 0;
2015
+ }
2016
+ } else if (option.type === 'checkbox') {
2017
+ if (option.defaultChecked) {
2018
+ option.checked = true;
2019
+ } else {
2020
+ option.checked = false;
2021
+ }
2007
2022
  } else if (!option.parentElement.classList.contains('js-multi-select__option')) {
2008
2023
  option.value = false;
2009
- option.checked = false;
2010
2024
  }
2011
2025
  });
2012
2026
  }
@@ -2699,7 +2713,7 @@
2699
2713
  * appears centered to the reference element.
2700
2714
  * @see https://floating-ui.com/docs/arrow
2701
2715
  */
2702
- const arrow = options => ({
2716
+ const arrow$1 = options => ({
2703
2717
  name: 'arrow',
2704
2718
  options,
2705
2719
  async fn(state) {
@@ -2835,7 +2849,7 @@
2835
2849
  * clipping boundary. Alternative to `autoPlacement`.
2836
2850
  * @see https://floating-ui.com/docs/flip
2837
2851
  */
2838
- const flip = function (options) {
2852
+ const flip$1 = function (options) {
2839
2853
  if (options === void 0) {
2840
2854
  options = {};
2841
2855
  }
@@ -2986,7 +3000,7 @@
2986
3000
  * object may be passed.
2987
3001
  * @see https://floating-ui.com/docs/offset
2988
3002
  */
2989
- const offset = function (value) {
3003
+ const offset$1 = function (value) {
2990
3004
  if (value === void 0) {
2991
3005
  value = 0;
2992
3006
  }
@@ -3016,7 +3030,7 @@
3016
3030
  * keep it in view when it will overflow the clipping boundary.
3017
3031
  * @see https://floating-ui.com/docs/shift
3018
3032
  */
3019
- const shift = function (options) {
3033
+ const shift$1 = function (options) {
3020
3034
  if (options === void 0) {
3021
3035
  options = {};
3022
3036
  }
@@ -3087,7 +3101,7 @@
3087
3101
  /**
3088
3102
  * Built-in `limiter` that will stop `shift()` at a certain point.
3089
3103
  */
3090
- const limitShift = function (options) {
3104
+ const limitShift$1 = function (options) {
3091
3105
  if (options === void 0) {
3092
3106
  options = {};
3093
3107
  }
@@ -3153,44 +3167,50 @@
3153
3167
  };
3154
3168
  };
3155
3169
 
3170
+ /**
3171
+ * Custom positioning reference element.
3172
+ * @see https://floating-ui.com/docs/virtual-elements
3173
+ */
3174
+ const min = Math.min;
3175
+ const max = Math.max;
3176
+ const round = Math.round;
3177
+ const createCoords = v => ({
3178
+ x: v,
3179
+ y: v
3180
+ });
3181
+
3182
+ function getNodeName(node) {
3183
+ if (isNode(node)) {
3184
+ return (node.nodeName || '').toLowerCase();
3185
+ }
3186
+ // Mocked nodes in testing environments may not be instances of Node. By
3187
+ // returning `#document` an infinite loop won't occur.
3188
+ // https://github.com/floating-ui/floating-ui/issues/2317
3189
+ return '#document';
3190
+ }
3156
3191
  function getWindow(node) {
3157
3192
  var _node$ownerDocument;
3158
- return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
3193
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
3159
3194
  }
3160
- function getComputedStyle$1(element) {
3161
- return getWindow(element).getComputedStyle(element);
3195
+ function getDocumentElement(node) {
3196
+ var _ref;
3197
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
3162
3198
  }
3163
3199
  function isNode(value) {
3164
- return value instanceof getWindow(value).Node;
3165
- }
3166
- function getNodeName(node) {
3167
- return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
3200
+ return value instanceof Node || value instanceof getWindow(value).Node;
3168
3201
  }
3169
- let uaString;
3170
- function getUAString() {
3171
- if (uaString) {
3172
- return uaString;
3173
- }
3174
- const uaData = navigator.userAgentData;
3175
- if (uaData && Array.isArray(uaData.brands)) {
3176
- uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
3177
- return uaString;
3178
- }
3179
- return navigator.userAgent;
3202
+ function isElement(value) {
3203
+ return value instanceof Element || value instanceof getWindow(value).Element;
3180
3204
  }
3181
3205
  function isHTMLElement(value) {
3182
- return value instanceof getWindow(value).HTMLElement;
3183
- }
3184
- function isElement(value) {
3185
- return value instanceof getWindow(value).Element;
3206
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
3186
3207
  }
3187
- function isShadowRoot(node) {
3208
+ function isShadowRoot(value) {
3188
3209
  // Browsers without `ShadowRoot` support.
3189
3210
  if (typeof ShadowRoot === 'undefined') {
3190
3211
  return false;
3191
3212
  }
3192
- const OwnElement = getWindow(node).ShadowRoot;
3193
- return node instanceof OwnElement || node instanceof ShadowRoot;
3213
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
3194
3214
  }
3195
3215
  function isOverflowElement(element) {
3196
3216
  const {
@@ -3204,44 +3224,99 @@
3204
3224
  function isTableElement(element) {
3205
3225
  return ['table', 'td', 'th'].includes(getNodeName(element));
3206
3226
  }
3227
+ function isTopLayer(element) {
3228
+ return [':popover-open', ':modal'].some(selector => {
3229
+ try {
3230
+ return element.matches(selector);
3231
+ } catch (e) {
3232
+ return false;
3233
+ }
3234
+ });
3235
+ }
3207
3236
  function isContainingBlock(element) {
3208
- // TODO: Try to use feature detection here instead.
3209
- const isFirefox = /firefox/i.test(getUAString());
3237
+ const webkit = isWebKit();
3210
3238
  const css = getComputedStyle$1(element);
3211
- const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
3212
3239
 
3213
- // This is non-exhaustive but covers the most common CSS properties that
3214
- // create a containing block.
3215
3240
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
3216
- return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
3217
- // Add type check for old browsers.
3218
- const contain = css.contain;
3219
- return contain != null ? contain.includes(value) : false;
3220
- });
3241
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
3221
3242
  }
3222
-
3223
- /**
3224
- * Determines whether or not `.getBoundingClientRect()` is affected by visual
3225
- * viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
3226
- * visual viewport, while in other engines, they are values relative to the
3227
- * layout viewport.
3228
- */
3229
- function isClientRectVisualViewportBased() {
3230
- // TODO: Try to use feature detection here instead. Feature detection for
3231
- // this can fail in various ways, making the userAgent check the most
3232
- // reliable:
3233
- // • Always-visible scrollbar or not
3234
- // • Width of <html>
3235
-
3236
- // Is Safari.
3237
- return /^((?!chrome|android).)*safari/i.test(getUAString());
3243
+ function getContainingBlock(element) {
3244
+ let currentNode = getParentNode(element);
3245
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
3246
+ if (isTopLayer(currentNode)) {
3247
+ return null;
3248
+ }
3249
+ if (isContainingBlock(currentNode)) {
3250
+ return currentNode;
3251
+ }
3252
+ currentNode = getParentNode(currentNode);
3253
+ }
3254
+ return null;
3255
+ }
3256
+ function isWebKit() {
3257
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
3258
+ return CSS.supports('-webkit-backdrop-filter', 'none');
3238
3259
  }
3239
3260
  function isLastTraversableNode(node) {
3240
3261
  return ['html', 'body', '#document'].includes(getNodeName(node));
3241
3262
  }
3242
- const min = Math.min;
3243
- const max = Math.max;
3244
- const round = Math.round;
3263
+ function getComputedStyle$1(element) {
3264
+ return getWindow(element).getComputedStyle(element);
3265
+ }
3266
+ function getNodeScroll(element) {
3267
+ if (isElement(element)) {
3268
+ return {
3269
+ scrollLeft: element.scrollLeft,
3270
+ scrollTop: element.scrollTop
3271
+ };
3272
+ }
3273
+ return {
3274
+ scrollLeft: element.scrollX,
3275
+ scrollTop: element.scrollY
3276
+ };
3277
+ }
3278
+ function getParentNode(node) {
3279
+ if (getNodeName(node) === 'html') {
3280
+ return node;
3281
+ }
3282
+ const result =
3283
+ // Step into the shadow DOM of the parent of a slotted node.
3284
+ node.assignedSlot ||
3285
+ // DOM Element detected.
3286
+ node.parentNode ||
3287
+ // ShadowRoot detected.
3288
+ isShadowRoot(node) && node.host ||
3289
+ // Fallback.
3290
+ getDocumentElement(node);
3291
+ return isShadowRoot(result) ? result.host : result;
3292
+ }
3293
+ function getNearestOverflowAncestor(node) {
3294
+ const parentNode = getParentNode(node);
3295
+ if (isLastTraversableNode(parentNode)) {
3296
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
3297
+ }
3298
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
3299
+ return parentNode;
3300
+ }
3301
+ return getNearestOverflowAncestor(parentNode);
3302
+ }
3303
+ function getOverflowAncestors(node, list, traverseIframes) {
3304
+ var _node$ownerDocument2;
3305
+ if (list === void 0) {
3306
+ list = [];
3307
+ }
3308
+ if (traverseIframes === void 0) {
3309
+ traverseIframes = true;
3310
+ }
3311
+ const scrollableAncestor = getNearestOverflowAncestor(node);
3312
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
3313
+ const win = getWindow(scrollableAncestor);
3314
+ if (isBody) {
3315
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
3316
+ }
3317
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
3318
+ }
3319
+
3245
3320
  function getCssDimensions(element) {
3246
3321
  const css = getComputedStyle$1(element);
3247
3322
  // In testing environments, the `width` and `height` properties are empty
@@ -3259,29 +3334,25 @@
3259
3334
  return {
3260
3335
  width,
3261
3336
  height,
3262
- fallback: shouldFallback
3337
+ $: shouldFallback
3263
3338
  };
3264
3339
  }
3265
3340
  function unwrapElement(element) {
3266
3341
  return !isElement(element) ? element.contextElement : element;
3267
3342
  }
3268
- const FALLBACK_SCALE = {
3269
- x: 1,
3270
- y: 1
3271
- };
3272
3343
  function getScale(element) {
3273
3344
  const domElement = unwrapElement(element);
3274
3345
  if (!isHTMLElement(domElement)) {
3275
- return FALLBACK_SCALE;
3346
+ return createCoords(1);
3276
3347
  }
3277
3348
  const rect = domElement.getBoundingClientRect();
3278
3349
  const {
3279
3350
  width,
3280
3351
  height,
3281
- fallback
3352
+ $
3282
3353
  } = getCssDimensions(domElement);
3283
- let x = (fallback ? round(rect.width) : rect.width) / width;
3284
- let y = (fallback ? round(rect.height) : rect.height) / height;
3354
+ let x = ($ ? round(rect.width) : rect.width) / width;
3355
+ let y = ($ ? round(rect.height) : rect.height) / height;
3285
3356
 
3286
3357
  // 0, NaN, or Infinity should always fallback to 1.
3287
3358
 
@@ -3296,8 +3367,27 @@
3296
3367
  y
3297
3368
  };
3298
3369
  }
3370
+ const noOffsets = /*#__PURE__*/createCoords(0);
3371
+ function getVisualOffsets(element) {
3372
+ const win = getWindow(element);
3373
+ if (!isWebKit() || !win.visualViewport) {
3374
+ return noOffsets;
3375
+ }
3376
+ return {
3377
+ x: win.visualViewport.offsetLeft,
3378
+ y: win.visualViewport.offsetTop
3379
+ };
3380
+ }
3381
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
3382
+ if (isFixed === void 0) {
3383
+ isFixed = false;
3384
+ }
3385
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
3386
+ return false;
3387
+ }
3388
+ return isFixed;
3389
+ }
3299
3390
  function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
3300
- var _win$visualViewport, _win$visualViewport2;
3301
3391
  if (includeScale === void 0) {
3302
3392
  includeScale = false;
3303
3393
  }
@@ -3306,7 +3396,7 @@
3306
3396
  }
3307
3397
  const clientRect = element.getBoundingClientRect();
3308
3398
  const domElement = unwrapElement(element);
3309
- let scale = FALLBACK_SCALE;
3399
+ let scale = createCoords(1);
3310
3400
  if (includeScale) {
3311
3401
  if (offsetParent) {
3312
3402
  if (isElement(offsetParent)) {
@@ -3316,29 +3406,30 @@
3316
3406
  scale = getScale(element);
3317
3407
  }
3318
3408
  }
3319
- const win = domElement ? getWindow(domElement) : window;
3320
- const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
3321
- let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
3322
- let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
3409
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
3410
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
3411
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
3323
3412
  let width = clientRect.width / scale.x;
3324
3413
  let height = clientRect.height / scale.y;
3325
3414
  if (domElement) {
3326
3415
  const win = getWindow(domElement);
3327
3416
  const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
3328
- let currentIFrame = win.frameElement;
3329
- while (currentIFrame && offsetParent && offsetWin !== win) {
3417
+ let currentWin = win;
3418
+ let currentIFrame = currentWin.frameElement;
3419
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
3330
3420
  const iframeScale = getScale(currentIFrame);
3331
3421
  const iframeRect = currentIFrame.getBoundingClientRect();
3332
- const css = getComputedStyle(currentIFrame);
3333
- iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
3334
- iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
3422
+ const css = getComputedStyle$1(currentIFrame);
3423
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
3424
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
3335
3425
  x *= iframeScale.x;
3336
3426
  y *= iframeScale.y;
3337
3427
  width *= iframeScale.x;
3338
3428
  height *= iframeScale.y;
3339
- x += iframeRect.x;
3340
- y += iframeRect.y;
3341
- currentIFrame = getWindow(currentIFrame).frameElement;
3429
+ x += left;
3430
+ y += top;
3431
+ currentWin = getWindow(currentIFrame);
3432
+ currentIFrame = currentWin.frameElement;
3342
3433
  }
3343
3434
  }
3344
3435
  return rectToClientRect({
@@ -3348,45 +3439,27 @@
3348
3439
  y
3349
3440
  });
3350
3441
  }
3351
- function getDocumentElement(node) {
3352
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
3353
- }
3354
- function getNodeScroll(element) {
3355
- if (isElement(element)) {
3356
- return {
3357
- scrollLeft: element.scrollLeft,
3358
- scrollTop: element.scrollTop
3359
- };
3360
- }
3361
- return {
3362
- scrollLeft: element.pageXOffset,
3363
- scrollTop: element.pageYOffset
3364
- };
3365
- }
3366
3442
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
3367
3443
  let {
3444
+ elements,
3368
3445
  rect,
3369
3446
  offsetParent,
3370
3447
  strategy
3371
3448
  } = _ref;
3372
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
3449
+ const isFixed = strategy === 'fixed';
3373
3450
  const documentElement = getDocumentElement(offsetParent);
3374
- if (offsetParent === documentElement) {
3451
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
3452
+ if (offsetParent === documentElement || topLayer && isFixed) {
3375
3453
  return rect;
3376
3454
  }
3377
3455
  let scroll = {
3378
3456
  scrollLeft: 0,
3379
3457
  scrollTop: 0
3380
3458
  };
3381
- let scale = {
3382
- x: 1,
3383
- y: 1
3384
- };
3385
- const offsets = {
3386
- x: 0,
3387
- y: 0
3388
- };
3389
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
3459
+ let scale = createCoords(1);
3460
+ const offsets = createCoords(0);
3461
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
3462
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3390
3463
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
3391
3464
  scroll = getNodeScroll(offsetParent);
3392
3465
  }
@@ -3404,6 +3477,9 @@
3404
3477
  y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
3405
3478
  };
3406
3479
  }
3480
+ function getClientRects(element) {
3481
+ return Array.from(element.getClientRects());
3482
+ }
3407
3483
  function getWindowScrollBarX(element) {
3408
3484
  // If <html> has a CSS width greater than the viewport, then this will be
3409
3485
  // incorrect for RTL.
@@ -3430,46 +3506,6 @@
3430
3506
  y
3431
3507
  };
3432
3508
  }
3433
- function getParentNode(node) {
3434
- if (getNodeName(node) === 'html') {
3435
- return node;
3436
- }
3437
- const result =
3438
- // Step into the shadow DOM of the parent of a slotted node.
3439
- node.assignedSlot ||
3440
- // DOM Element detected.
3441
- node.parentNode ||
3442
- // ShadowRoot detected.
3443
- isShadowRoot(node) && node.host ||
3444
- // Fallback.
3445
- getDocumentElement(node);
3446
- return isShadowRoot(result) ? result.host : result;
3447
- }
3448
- function getNearestOverflowAncestor(node) {
3449
- const parentNode = getParentNode(node);
3450
- if (isLastTraversableNode(parentNode)) {
3451
- // `getParentNode` will never return a `Document` due to the fallback
3452
- // check, so it's either the <html> or <body> element.
3453
- return parentNode.ownerDocument.body;
3454
- }
3455
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
3456
- return parentNode;
3457
- }
3458
- return getNearestOverflowAncestor(parentNode);
3459
- }
3460
- function getOverflowAncestors(node, list) {
3461
- var _node$ownerDocument;
3462
- if (list === void 0) {
3463
- list = [];
3464
- }
3465
- const scrollableAncestor = getNearestOverflowAncestor(node);
3466
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
3467
- const win = getWindow(scrollableAncestor);
3468
- if (isBody) {
3469
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
3470
- }
3471
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
3472
- }
3473
3509
  function getViewportRect(element, strategy) {
3474
3510
  const win = getWindow(element);
3475
3511
  const html = getDocumentElement(element);
@@ -3481,7 +3517,7 @@
3481
3517
  if (visualViewport) {
3482
3518
  width = visualViewport.width;
3483
3519
  height = visualViewport.height;
3484
- const visualViewportBased = isClientRectVisualViewportBased();
3520
+ const visualViewportBased = isWebKit();
3485
3521
  if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
3486
3522
  x = visualViewport.offsetLeft;
3487
3523
  y = visualViewport.offsetTop;
@@ -3500,10 +3536,7 @@
3500
3536
  const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
3501
3537
  const top = clientRect.top + element.clientTop;
3502
3538
  const left = clientRect.left + element.clientLeft;
3503
- const scale = isHTMLElement(element) ? getScale(element) : {
3504
- x: 1,
3505
- y: 1
3506
- };
3539
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
3507
3540
  const width = element.clientWidth * scale.x;
3508
3541
  const height = element.clientHeight * scale.y;
3509
3542
  const x = left * scale.x;
@@ -3524,16 +3557,12 @@
3524
3557
  } else if (isElement(clippingAncestor)) {
3525
3558
  rect = getInnerBoundingClientRect(clippingAncestor, strategy);
3526
3559
  } else {
3527
- const mutableRect = {
3528
- ...clippingAncestor
3560
+ const visualOffsets = getVisualOffsets(element);
3561
+ rect = {
3562
+ ...clippingAncestor,
3563
+ x: clippingAncestor.x - visualOffsets.x,
3564
+ y: clippingAncestor.y - visualOffsets.y
3529
3565
  };
3530
- if (isClientRectVisualViewportBased()) {
3531
- var _win$visualViewport, _win$visualViewport2;
3532
- const win = getWindow(element);
3533
- mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
3534
- mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
3535
- }
3536
- rect = mutableRect;
3537
3566
  }
3538
3567
  return rectToClientRect(rect);
3539
3568
  }
@@ -3553,7 +3582,7 @@
3553
3582
  if (cachedResult) {
3554
3583
  return cachedResult;
3555
3584
  }
3556
- let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
3585
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
3557
3586
  let currentContainingBlockComputedStyle = null;
3558
3587
  const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
3559
3588
  let currentNode = elementIsFixed ? getParentNode(element) : element;
@@ -3588,7 +3617,7 @@
3588
3617
  rootBoundary,
3589
3618
  strategy
3590
3619
  } = _ref;
3591
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
3620
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
3592
3621
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
3593
3622
  const firstClippingAncestor = clippingAncestors[0];
3594
3623
  const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
@@ -3607,7 +3636,48 @@
3607
3636
  };
3608
3637
  }
3609
3638
  function getDimensions(element) {
3610
- return getCssDimensions(element);
3639
+ const {
3640
+ width,
3641
+ height
3642
+ } = getCssDimensions(element);
3643
+ return {
3644
+ width,
3645
+ height
3646
+ };
3647
+ }
3648
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
3649
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
3650
+ const documentElement = getDocumentElement(offsetParent);
3651
+ const isFixed = strategy === 'fixed';
3652
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
3653
+ let scroll = {
3654
+ scrollLeft: 0,
3655
+ scrollTop: 0
3656
+ };
3657
+ const offsets = createCoords(0);
3658
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3659
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
3660
+ scroll = getNodeScroll(offsetParent);
3661
+ }
3662
+ if (isOffsetParentAnElement) {
3663
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
3664
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
3665
+ offsets.y = offsetRect.y + offsetParent.clientTop;
3666
+ } else if (documentElement) {
3667
+ offsets.x = getWindowScrollBarX(documentElement);
3668
+ }
3669
+ }
3670
+ const x = rect.left + scroll.scrollLeft - offsets.x;
3671
+ const y = rect.top + scroll.scrollTop - offsets.y;
3672
+ return {
3673
+ x,
3674
+ y,
3675
+ width: rect.width,
3676
+ height: rect.height
3677
+ };
3678
+ }
3679
+ function isStaticPositioned(element) {
3680
+ return getComputedStyle$1(element).position === 'static';
3611
3681
  }
3612
3682
  function getTrueOffsetParent(element, polyfill) {
3613
3683
  if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
@@ -3618,98 +3688,102 @@
3618
3688
  }
3619
3689
  return element.offsetParent;
3620
3690
  }
3621
- function getContainingBlock(element) {
3622
- let currentNode = getParentNode(element);
3623
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
3624
- if (isContainingBlock(currentNode)) {
3625
- return currentNode;
3626
- } else {
3627
- currentNode = getParentNode(currentNode);
3628
- }
3629
- }
3630
- return null;
3631
- }
3632
3691
 
3633
3692
  // Gets the closest ancestor positioned element. Handles some edge cases,
3634
3693
  // such as table ancestors and cross browser bugs.
3635
3694
  function getOffsetParent(element, polyfill) {
3636
- const window = getWindow(element);
3695
+ const win = getWindow(element);
3696
+ if (isTopLayer(element)) {
3697
+ return win;
3698
+ }
3637
3699
  if (!isHTMLElement(element)) {
3638
- return window;
3700
+ let svgOffsetParent = getParentNode(element);
3701
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
3702
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
3703
+ return svgOffsetParent;
3704
+ }
3705
+ svgOffsetParent = getParentNode(svgOffsetParent);
3706
+ }
3707
+ return win;
3639
3708
  }
3640
3709
  let offsetParent = getTrueOffsetParent(element, polyfill);
3641
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
3710
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
3642
3711
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
3643
3712
  }
3644
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
3645
- return window;
3713
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
3714
+ return win;
3646
3715
  }
3647
- return offsetParent || getContainingBlock(element) || window;
3716
+ return offsetParent || getContainingBlock(element) || win;
3648
3717
  }
3649
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
3650
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
3651
- const documentElement = getDocumentElement(offsetParent);
3652
- const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
3653
- let scroll = {
3654
- scrollLeft: 0,
3655
- scrollTop: 0
3656
- };
3657
- const offsets = {
3658
- x: 0,
3659
- y: 0
3660
- };
3661
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
3662
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
3663
- scroll = getNodeScroll(offsetParent);
3664
- }
3665
- if (isHTMLElement(offsetParent)) {
3666
- const offsetRect = getBoundingClientRect(offsetParent, true);
3667
- offsets.x = offsetRect.x + offsetParent.clientLeft;
3668
- offsets.y = offsetRect.y + offsetParent.clientTop;
3669
- } else if (documentElement) {
3670
- offsets.x = getWindowScrollBarX(documentElement);
3671
- }
3672
- }
3718
+ const getElementRects = async function (data) {
3719
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
3720
+ const getDimensionsFn = this.getDimensions;
3721
+ const floatingDimensions = await getDimensionsFn(data.floating);
3673
3722
  return {
3674
- x: rect.left + scroll.scrollLeft - offsets.x,
3675
- y: rect.top + scroll.scrollTop - offsets.y,
3676
- width: rect.width,
3677
- height: rect.height
3723
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
3724
+ floating: {
3725
+ x: 0,
3726
+ y: 0,
3727
+ width: floatingDimensions.width,
3728
+ height: floatingDimensions.height
3729
+ }
3678
3730
  };
3731
+ };
3732
+ function isRTL(element) {
3733
+ return getComputedStyle$1(element).direction === 'rtl';
3679
3734
  }
3680
3735
  const platform = {
3681
- getClippingRect,
3682
3736
  convertOffsetParentRelativeRectToViewportRelativeRect,
3683
- isElement,
3684
- getDimensions,
3685
- getOffsetParent,
3686
3737
  getDocumentElement,
3738
+ getClippingRect,
3739
+ getOffsetParent,
3740
+ getElementRects,
3741
+ getClientRects,
3742
+ getDimensions,
3687
3743
  getScale,
3688
- async getElementRects(_ref) {
3689
- let {
3690
- reference,
3691
- floating,
3692
- strategy
3693
- } = _ref;
3694
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
3695
- const getDimensionsFn = this.getDimensions;
3696
- return {
3697
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
3698
- floating: {
3699
- x: 0,
3700
- y: 0,
3701
- ...(await getDimensionsFn(floating))
3702
- }
3703
- };
3704
- },
3705
- getClientRects: element => Array.from(element.getClientRects()),
3706
- isRTL: element => getComputedStyle$1(element).direction === 'rtl'
3744
+ isElement,
3745
+ isRTL
3707
3746
  };
3708
3747
 
3748
+ /**
3749
+ * Modifies the placement by translating the floating element along the
3750
+ * specified axes.
3751
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
3752
+ * object may be passed.
3753
+ * @see https://floating-ui.com/docs/offset
3754
+ */
3755
+ const offset = offset$1;
3756
+
3757
+ /**
3758
+ * Optimizes the visibility of the floating element by shifting it in order to
3759
+ * keep it in view when it will overflow the clipping boundary.
3760
+ * @see https://floating-ui.com/docs/shift
3761
+ */
3762
+ const shift = shift$1;
3763
+
3764
+ /**
3765
+ * Optimizes the visibility of the floating element by flipping the `placement`
3766
+ * in order to keep it in view when the preferred placement(s) will overflow the
3767
+ * clipping boundary. Alternative to `autoPlacement`.
3768
+ * @see https://floating-ui.com/docs/flip
3769
+ */
3770
+ const flip = flip$1;
3771
+
3772
+ /**
3773
+ * Provides data to position an inner element of the floating element so that it
3774
+ * appears centered to the reference element.
3775
+ * @see https://floating-ui.com/docs/arrow
3776
+ */
3777
+ const arrow = arrow$1;
3778
+
3779
+ /**
3780
+ * Built-in `limiter` that will stop `shift()` at a certain point.
3781
+ */
3782
+ const limitShift = limitShift$1;
3783
+
3709
3784
  /**
3710
3785
  * Computes the `x` and `y` coordinates that will place the floating element
3711
- * next to a reference element when it is given a certain CSS positioning
3712
- * strategy.
3786
+ * next to a given reference element.
3713
3787
  */
3714
3788
  const computePosition = (reference, floating, options) => {
3715
3789
  // This caches the expensive `getClippingElementAncestors` function so that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "3.17.3",
3
+ "version": "3.17.4",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/main.js",
6
6
  "style": "dist/main.css",
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@babel/core": "^7.21.4",
47
47
  "@babel/preset-env": "^7.21.4",
48
- "@floating-ui/dom": "^1.2.8",
48
+ "@floating-ui/dom": "^1.6.6",
49
49
  "@rollup/plugin-babel": "^6.0.3",
50
50
  "@rollup/plugin-node-resolve": "^15.0.2",
51
51
  "auto-changelog": "^2.4.0",
@@ -105,6 +105,6 @@
105
105
  }
106
106
  },
107
107
  "dependencies": {
108
- "@floating-ui/dom": "^1.2.8"
108
+ "@floating-ui/dom": "^1.6.6"
109
109
  }
110
110
  }
@@ -36,6 +36,8 @@ class Filters {
36
36
  this.showMoreContent = this.element.querySelectorAll(`.${this.prefix}${this.allClass}`)
37
37
  this.showMoreButtons = this.element.querySelectorAll(`.${this.prefix}${this.moreClass}`)
38
38
  this.focusableElements = 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'
39
+ // Get default selected option
40
+ this.selectedOption = this.element.querySelector('option[selected]')
39
41
  // Accordion arrays
40
42
  this.buttons = []
41
43
  this.content = []
@@ -208,11 +210,23 @@ class Filters {
208
210
  if (this.options.length > 0) {
209
211
  this.options.forEach((input) => {
210
212
  const option = input
211
- if (option.type === 'text' || option.type === 'select-one') {
213
+ if (option.type === 'text') {
212
214
  option.value = ''
215
+ } else if (option.type === 'select-one') {
216
+ if (this.selectedOption) {
217
+ console.log(Array.from(option.options).indexOf(this.selectedOption))
218
+ option.selectedIndex = Array.from(option.options).indexOf(this.selectedOption)
219
+ } else {
220
+ option.selectedIndex = 0
221
+ }
222
+ } else if (option.type === 'checkbox') {
223
+ if (option.defaultChecked) {
224
+ option.checked = true
225
+ } else {
226
+ option.checked = false
227
+ }
213
228
  } else if (!option.parentElement.classList.contains('js-multi-select__option')) {
214
229
  option.value = false
215
- option.checked = false
216
230
  }
217
231
  })
218
232
  }