@westpac/ui 0.30.0 → 0.32.0
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/CHANGELOG.md +16 -0
- package/assets/icons/filled/child-care-filled.svg +1 -0
- package/assets/icons/filled/child-filled.svg +1 -0
- package/assets/icons/filled/piggy-bank-filled.svg +3 -0
- package/assets/icons/filled/x-filled.svg +1 -0
- package/assets/icons/outlined/child-care-outlined.svg +1 -0
- package/assets/icons/outlined/child-outlined.svg +1 -0
- package/assets/icons/outlined/piggy-bank-outlined.svg +6 -0
- package/assets/icons/outlined/x-outlined.svg +1 -0
- package/dist/component-type.json +1 -1
- package/dist/components/accordion/components/accordion-item/accordion-item.styles.js +1 -1
- package/dist/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.styles.js +4 -4
- package/dist/components/circle/circle.styles.d.ts +2 -2
- package/dist/components/circle/circle.styles.js +1 -1
- package/dist/components/flexi-cell/components/flexi-cell-circle/flexi-cell-circle.styles.js +1 -1
- package/dist/components/header/header.styles.js +1 -1
- package/dist/components/icon/components/child-care-icon.js +1 -1
- package/dist/components/icon/components/child-icon.js +1 -1
- package/dist/components/icon/components/piggy-bank-icon.d.ts +2 -0
- package/dist/components/icon/components/piggy-bank-icon.js +35 -0
- package/dist/components/icon/components/x-icon.js +1 -1
- package/dist/components/icon/icon.styles.js +5 -5
- package/dist/components/icon/index.d.ts +4 -0
- package/dist/components/icon/index.js +4 -0
- package/dist/components/list/components/list-item/list-item.styles.js +3 -3
- package/dist/components/pictogram/components/decorative/wbc-bank-card-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/accessibility-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/accounts-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/aeroplane-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/arrow-down-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/arrow-left-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/arrow-right-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/arrow-up-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/arrows-passing-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/atm-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/australia-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/bank-card-locked-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/bank-card-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/bank-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/birth-certificate-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/building-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/buoy-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/bus-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/business-person-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/calculator-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/calendar-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/car-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/cash-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/celebration-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/chat-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/clock-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/coffee-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/coins-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/compass-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/customer-profile-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/desktop-computer-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/document-and-pen-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/dollar-sign-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/drivers-licence-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/education-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/eftpos-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/envelope-email-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/envelope-printed-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/face-happy-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/face-unhappy-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/face-unsure-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/finger-motion-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/fingerprint-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/football-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/fork-knife-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/generic-document-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/gift-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/globe-australia-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/globe-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/graph-decreasing-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/graph-increasing-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/gym-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/headset-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/heart-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/house-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/light-bulb-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/loop-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/medicare-card-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/mobile-device-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/money-in-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/money-out-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/movie-tickets-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/nest-egg-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/noodles-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/number-1-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/number-2-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/number-3-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/number-4-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/number-5-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/padlock-locked-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/padlock-unlocked-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/passport-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/percent-sign-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/person-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/piggy-bank-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/pizza-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/plant-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/search-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/secure-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/shop-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/shopping-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/sparkle-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/star-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/stopwatch-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/target-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/tax-document-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/telephone-call-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/thumbs-up-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/tick-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/tools-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/tractor-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/truck-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/umbrella-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/unsecure-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/wallet-pictogram.js +1 -1
- package/dist/components/pictogram/components/informative/wearables-pictogram.js +1 -1
- package/dist/components/popover/components/panel/panel.component.d.ts +2 -1
- package/dist/components/popover/components/panel/panel.component.js +42 -40
- package/dist/components/popover/components/panel/panel.hook.d.ts +39 -0
- package/dist/components/popover/components/panel/panel.hook.js +83 -0
- package/dist/components/popover/components/panel/panel.styles.js +9 -6
- package/dist/components/popover/components/panel/panel.types.d.ts +4 -0
- package/dist/components/popover/popover.component.d.ts +1 -1
- package/dist/components/popover/popover.component.js +4 -3
- package/dist/components/popover/popover.types.d.ts +7 -0
- package/dist/components/progress-indicator/progress-indicator.styles.js +5 -5
- package/dist/components/progress-rope/components/progress-rope-group-step/progress-rope-group-step.styles.js +1 -1
- package/dist/components/progress-rope/components/progress-rope-step/progress-rope-step.styles.js +2 -2
- package/dist/components/radio-group/components/radio-group-radio/radio-group-radio.styles.js +4 -4
- package/dist/components/switch/switch.styles.js +4 -4
- package/dist/components/symbol/components/logos/red-avatar-circle-logo.js +1 -1
- package/dist/components/symbol/components/logos/red-avatar-circle-reversed-logo.js +1 -1
- package/dist/components/symbol/components/symbols/facebook-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/google-plus-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/instagram-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/linked-in-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/slack-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/twitter-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/x-mark-inverse-symbol.d.ts +2 -0
- package/dist/components/symbol/components/symbols/x-mark-inverse-symbol.js +27 -0
- package/dist/components/symbol/components/symbols/x-mark-symbol.d.ts +2 -0
- package/dist/components/symbol/components/symbols/x-mark-symbol.js +27 -0
- package/dist/components/symbol/components/symbols/x-symbol.d.ts +2 -0
- package/dist/components/symbol/components/symbols/x-symbol.js +38 -0
- package/dist/components/symbol/components/symbols/yammer-symbol.js +1 -1
- package/dist/components/symbol/components/symbols/youtube-symbol.js +1 -1
- package/dist/components/symbol/index.d.ts +3 -0
- package/dist/components/symbol/index.js +3 -0
- package/dist/components/textarea/textarea.styles.js +4 -4
- package/dist/css/westpac-ui.css +519 -515
- package/dist/css/westpac-ui.min.css +519 -515
- package/package.json +1 -1
- package/src/components/accordion/components/accordion-item/accordion-item.styles.ts +1 -1
- package/src/components/checkbox-group/components/checkbox-group-checkbox/checkbox-group-checkbox.styles.ts +4 -4
- package/src/components/circle/circle.styles.ts +1 -1
- package/src/components/flexi-cell/components/flexi-cell-circle/flexi-cell-circle.styles.ts +1 -1
- package/src/components/header/header.styles.ts +1 -1
- package/src/components/icon/components/child-care-icon.tsx +1 -1
- package/src/components/icon/components/child-icon.tsx +1 -1
- package/src/components/icon/components/piggy-bank-icon.tsx +35 -0
- package/src/components/icon/components/x-icon.tsx +1 -1
- package/src/components/icon/icon.styles.ts +5 -5
- package/src/components/icon/index.ts +4 -0
- package/src/components/list/components/list-item/list-item.styles.ts +3 -3
- package/src/components/pictogram/components/decorative/wbc-bank-card-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/accessibility-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/accounts-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/aeroplane-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/arrow-down-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/arrow-left-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/arrow-right-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/arrow-up-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/arrows-passing-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/atm-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/australia-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/bank-card-locked-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/bank-card-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/bank-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/birth-certificate-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/building-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/buoy-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/bus-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/business-person-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/calculator-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/calendar-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/car-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/cash-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/celebration-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/chat-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/clock-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/coffee-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/coins-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/compass-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/customer-profile-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/desktop-computer-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/document-and-pen-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/dollar-sign-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/drivers-licence-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/education-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/eftpos-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/envelope-email-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/envelope-printed-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/face-happy-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/face-unhappy-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/face-unsure-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/finger-motion-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/fingerprint-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/football-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/fork-knife-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/generic-document-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/gift-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/globe-australia-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/globe-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/graph-decreasing-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/graph-increasing-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/gym-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/headset-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/heart-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/house-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/light-bulb-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/loop-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/medicare-card-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/mobile-device-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/money-in-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/money-out-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/movie-tickets-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/nest-egg-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/noodles-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/number-1-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/number-2-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/number-3-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/number-4-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/number-5-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/padlock-locked-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/padlock-unlocked-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/passport-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/percent-sign-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/person-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/piggy-bank-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/pizza-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/plant-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/search-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/secure-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/shop-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/shopping-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/sparkle-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/star-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/stopwatch-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/target-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/tax-document-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/telephone-call-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/thumbs-up-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/tick-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/tools-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/tractor-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/truck-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/umbrella-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/unsecure-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/wallet-pictogram.tsx +1 -1
- package/src/components/pictogram/components/informative/wearables-pictogram.tsx +1 -1
- package/src/components/popover/components/panel/panel.component.tsx +34 -45
- package/src/components/popover/components/panel/panel.hook.tsx +113 -0
- package/src/components/popover/components/panel/panel.styles.ts +9 -7
- package/src/components/popover/components/panel/panel.types.ts +4 -0
- package/src/components/popover/popover.component.tsx +10 -4
- package/src/components/popover/popover.types.ts +8 -0
- package/src/components/progress-indicator/progress-indicator.styles.ts +5 -5
- package/src/components/progress-rope/components/progress-rope-group-step/progress-rope-group-step.styles.ts +1 -1
- package/src/components/progress-rope/components/progress-rope-step/progress-rope-step.styles.ts +2 -2
- package/src/components/radio-group/components/radio-group-radio/radio-group-radio.styles.ts +4 -4
- package/src/components/switch/switch.styles.ts +4 -4
- package/src/components/symbol/components/logos/red-avatar-circle-logo.tsx +1 -1
- package/src/components/symbol/components/logos/red-avatar-circle-reversed-logo.tsx +1 -1
- package/src/components/symbol/components/symbols/facebook-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/google-plus-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/instagram-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/linked-in-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/slack-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/twitter-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/x-mark-inverse-symbol.tsx +28 -0
- package/src/components/symbol/components/symbols/x-mark-symbol.tsx +28 -0
- package/src/components/symbol/components/symbols/x-symbol.tsx +39 -0
- package/src/components/symbol/components/symbols/yammer-symbol.tsx +1 -1
- package/src/components/symbol/components/symbols/youtube-symbol.tsx +1 -1
- package/src/components/symbol/index.ts +3 -0
- package/src/components/textarea/textarea.styles.ts +4 -4
- package/dist/components/popover/popover.utils.d.ts +0 -3
- package/dist/components/popover/popover.utils.js +0 -37
- package/src/components/popover/popover.utils.tsx +0 -59
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const getPopoverPosition = (triggerRef, popoverRef, arrowRef, placement)=>{
|
|
2
|
-
if (!triggerRef.current || !popoverRef.current || !arrowRef.current) {
|
|
3
|
-
throw new Error('You must pass valid refs.');
|
|
4
|
-
}
|
|
5
|
-
const trigger = triggerRef.current.getBoundingClientRect();
|
|
6
|
-
const popover = popoverRef.current.getBoundingClientRect();
|
|
7
|
-
const arrow = arrowRef.current.getBoundingClientRect();
|
|
8
|
-
const remSize = typeof window !== 'undefined' ? parseInt(window.getComputedStyle(document.getElementsByTagName('html')[0]).fontSize) : 1;
|
|
9
|
-
const position = {
|
|
10
|
-
placement: placement ? placement : 'top',
|
|
11
|
-
offset: popover.right >= window.innerWidth ? 'right' : 'left',
|
|
12
|
-
panelPosition: trigger.width / 2 / remSize,
|
|
13
|
-
arrowPosition: (popover.width / 2 - arrow.width / 2) / remSize
|
|
14
|
-
};
|
|
15
|
-
if (typeof window === 'undefined') {
|
|
16
|
-
return position;
|
|
17
|
-
}
|
|
18
|
-
const offLeft = popover.left <= 0;
|
|
19
|
-
const offRight = popover.right + remSize >= window.innerWidth;
|
|
20
|
-
if (offLeft) {
|
|
21
|
-
position.panelPosition = (popover.width - popover.right + trigger.width / 2 + remSize) / remSize;
|
|
22
|
-
position.arrowPosition = (trigger.right - trigger.width / 2 - arrow.width / 2 - remSize) / remSize;
|
|
23
|
-
}
|
|
24
|
-
if (offRight) {
|
|
25
|
-
position.panelPosition = (window.innerWidth - trigger.right - remSize) / remSize;
|
|
26
|
-
position.arrowPosition = (window.innerWidth - (trigger.left + trigger.width / 2) - (remSize + arrow.width / 2)) / remSize;
|
|
27
|
-
}
|
|
28
|
-
if (popover.height > trigger.top) {
|
|
29
|
-
position.placement = placement ? placement : 'bottom';
|
|
30
|
-
return position;
|
|
31
|
-
}
|
|
32
|
-
if (popover.bottom > window.innerHeight) {
|
|
33
|
-
position.placement = placement ? placement : 'top';
|
|
34
|
-
return position;
|
|
35
|
-
}
|
|
36
|
-
return position;
|
|
37
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Position } from './components/panel/panel.types.js';
|
|
4
|
-
|
|
5
|
-
export const getPopoverPosition = (
|
|
6
|
-
triggerRef: RefObject<HTMLDivElement>,
|
|
7
|
-
popoverRef: RefObject<HTMLDivElement>,
|
|
8
|
-
arrowRef: RefObject<HTMLDivElement>,
|
|
9
|
-
placement?: 'top' | 'bottom',
|
|
10
|
-
): Position => {
|
|
11
|
-
// bail early without refs
|
|
12
|
-
if (!triggerRef.current || !popoverRef.current || !arrowRef.current) {
|
|
13
|
-
throw new Error('You must pass valid refs.');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const trigger = triggerRef.current.getBoundingClientRect();
|
|
17
|
-
const popover = popoverRef.current.getBoundingClientRect();
|
|
18
|
-
const arrow = arrowRef.current.getBoundingClientRect();
|
|
19
|
-
const remSize =
|
|
20
|
-
typeof window !== 'undefined'
|
|
21
|
-
? parseInt(window.getComputedStyle(document.getElementsByTagName('html')[0]).fontSize)
|
|
22
|
-
: 1;
|
|
23
|
-
|
|
24
|
-
const position: Position = {
|
|
25
|
-
placement: placement ? placement : 'top',
|
|
26
|
-
offset: popover.right >= window.innerWidth ? 'right' : 'left',
|
|
27
|
-
panelPosition: trigger.width / 2 / remSize,
|
|
28
|
-
arrowPosition: (popover.width / 2 - arrow.width / 2) / remSize,
|
|
29
|
-
};
|
|
30
|
-
if (typeof window === 'undefined') {
|
|
31
|
-
return position;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const offLeft = popover.left <= 0;
|
|
35
|
-
const offRight = popover.right + remSize >= window.innerWidth;
|
|
36
|
-
|
|
37
|
-
if (offLeft) {
|
|
38
|
-
position.panelPosition = (popover.width - popover.right + trigger.width / 2 + remSize) / remSize;
|
|
39
|
-
position.arrowPosition = (trigger.right - trigger.width / 2 - arrow.width / 2 - remSize) / remSize;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (offRight) {
|
|
43
|
-
position.panelPosition = (window.innerWidth - trigger.right - remSize) / remSize;
|
|
44
|
-
position.arrowPosition =
|
|
45
|
-
(window.innerWidth - (trigger.left + trigger.width / 2) - (remSize + arrow.width / 2)) / remSize;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (popover.height > trigger.top) {
|
|
49
|
-
position.placement = placement ? placement : 'bottom';
|
|
50
|
-
return position;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (popover.bottom > window.innerHeight) {
|
|
54
|
-
position.placement = placement ? placement : 'top';
|
|
55
|
-
return position;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return position;
|
|
59
|
-
};
|