@zohodesk/components 1.0.0-alpha-245 → 1.0.0-alpha-248
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 +1071 -1061
- package/docs/external/active-line.js +72 -72
- package/docs/external/autorefresh.js +47 -47
- package/docs/external/codemirror.js +9681 -9681
- package/docs/external/css/hopscotch.css +576 -576
- package/docs/external/css/styleGuide.css +1100 -1100
- package/docs/external/css.js +466 -466
- package/docs/external/designTokens.js +1 -1
- package/docs/external/foldcode.js +151 -151
- package/docs/external/format.js +129 -129
- package/docs/external/htmlmixed.js +84 -84
- package/docs/external/index.html +127 -127
- package/docs/external/javascript.js +422 -422
- package/docs/external/jsx.js +147 -147
- package/docs/external/matchbrackets.js +145 -145
- package/docs/external/xml.js +322 -322
- package/docs/package.json +41 -41
- package/docs/src/index.js +1311 -1311
- package/es/AppContainer/AppContainer.module.css +18 -18
- package/es/Avatar/Avatar.js +9 -9
- package/es/Avatar/Avatar.module.css +117 -117
- package/es/Avatar/__tests__/__snapshots__/Avatar.spec.js.snap +288 -288
- package/es/AvatarTeam/AvatarTeam.js +7 -7
- package/es/AvatarTeam/AvatarTeam.module.css +161 -161
- package/es/AvatarTeam/__tests__/__snapshots__/AvatarTeam.spec.js.snap +226 -226
- package/es/AvatarTeam/docs/AvatarTeam__custom.docs.js +0 -0
- package/es/AvatarTeam/docs/AvatarTeam__default.docs.js +0 -0
- package/es/AvatarTeam/docs/AvatarTeam__palette.docs.js +0 -0
- package/es/AvatarTeam/docs/AvatarTeam__size.docs.js +0 -0
- package/es/Button/Button.js +4 -4
- package/es/Button/Button.module.css +521 -521
- package/es/Button/__tests__/__snapshots__/Button.spec.js.snap +191 -191
- package/es/Button/docs/Button__custom.docs.js +0 -0
- package/es/Button/docs/Button__default.docs.js +0 -0
- package/es/Buttongroup/Buttongroup.js +1 -1
- package/es/Buttongroup/Buttongroup.module.css +89 -89
- package/es/Buttongroup/__test__/__snapshots__/Buttongroup.spec.js.snap +146 -146
- package/es/Card/Card.js +12 -7
- package/es/Card/Card.module.css +20 -20
- package/es/Card/docs/Card__Custom.docs.js +0 -0
- package/es/Card/docs/Card__Default.docs.js +0 -0
- package/es/Card/docs/Card__Scroll.docs.js +0 -0
- package/es/CheckBox/CheckBox.js +0 -0
- package/es/CheckBox/CheckBox.module.css +157 -153
- package/es/CheckBox/docs/CheckBox__custom.docs.js +0 -0
- package/es/CheckBox/docs/CheckBox__default.docs.js +0 -0
- package/es/DateTime/CalendarView.js +0 -0
- package/es/DateTime/DateTime.js +0 -0
- package/es/DateTime/DateTime.module.css +187 -187
- package/es/DateTime/DateWidget.js +0 -0
- package/es/DateTime/DateWidget.module.css +38 -38
- package/es/DateTime/YearView.js +0 -0
- package/es/DateTime/YearView.module.css +81 -81
- package/es/DateTime/common.js +0 -0
- package/es/DateTime/docs/DateTime__default.docs.js +0 -0
- package/es/DateTime/docs/DateWidget__default.docs.js +0 -0
- package/es/DateTime/index.js +0 -0
- package/es/DateTime/objectUtils.js +0 -0
- package/es/DateTime/typeChecker.js +0 -0
- package/es/DateTime/validator.js +0 -0
- package/es/DropBox/DropBox.js +0 -0
- package/es/DropBox/DropBox.module.css +406 -406
- package/es/DropBox/DropBoxPositionMapping.json +144 -144
- package/es/DropDown/DropDown.js +0 -0
- package/es/DropDown/DropDown.module.css +5 -5
- package/es/DropDown/DropDownHeading.js +0 -0
- package/es/DropDown/DropDownHeading.module.css +53 -53
- package/es/DropDown/DropDownItem.js +0 -0
- package/es/DropDown/DropDownItem.module.css +94 -94
- package/es/DropDown/DropDownSearch.js +0 -0
- package/es/DropDown/DropDownSearch.module.css +14 -14
- package/es/DropDown/DropDownSeparator.js +0 -0
- package/es/DropDown/DropDownSeparator.module.css +7 -7
- package/es/Label/Label.js +2 -2
- package/es/Label/Label.module.css +52 -52
- package/es/Label/LabelColors.module.css +20 -20
- package/es/Label/__tests__/__snapshots__/Label.spec.js.snap +101 -101
- package/es/Label/docs/Label__clipped.docs.js +0 -0
- package/es/Label/docs/Label__custom.docs.js +0 -0
- package/es/Label/docs/Label__palette.docs.js +0 -0
- package/es/Label/docs/Label__size.docs.js +0 -0
- package/es/Label/docs/Label__type.docs.js +0 -0
- package/es/Layout/Box.js +15 -30
- package/es/Layout/Container.js +15 -27
- package/es/Layout/Layout.module.css +336 -324
- package/es/Layout/docs/Layout__default.docs.js +0 -0
- package/es/Layout/docs/Layout__four_Column.docs.js +16 -22
- package/es/Layout/props/defaultProps.js +12 -0
- package/es/Layout/props/propTypes.js +42 -0
- package/es/Layout/utils.js +0 -0
- package/es/LightNightMode/Colors.json +496 -496
- package/es/ListItem/ListItem.js +0 -0
- package/es/ListItem/ListItem.module.css +209 -205
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +6 -6
- package/es/MultiSelect/MultiSelect.js +5 -5
- package/es/MultiSelect/MultiSelect.module.css +205 -205
- package/es/MultiSelect/MultiSelectWithAvatar.js +0 -0
- package/es/MultiSelect/SelectedOptions.module.css +15 -15
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +0 -0
- package/es/PopOver/PopOver.module.css +8 -8
- package/es/Popup/Popup.js +0 -0
- package/es/Popup/PositionMapping.json +73 -73
- package/es/Radio/Radio.js +0 -0
- package/es/Radio/Radio.module.css +112 -110
- package/es/Radio/docs/Radio__custom.docs.js +0 -0
- package/es/Radio/docs/Radio__default.docs.js +0 -0
- package/es/Responsive/CustomResponsive.js +0 -0
- package/es/Responsive/docs/Responsive__Custom.docs.js +0 -0
- package/es/Responsive/docs/style.module.css +55 -55
- package/es/ResponsiveDropBox/ResponsiveDropBox.module.css +6 -6
- package/es/Ribbon/Ribbon.js +0 -0
- package/es/Ribbon/Ribbon.module.css +376 -376
- package/es/Ribbon/__tests__/__snapshots__/Ribbon.spec.js.snap +163 -163
- package/es/Ribbon/docs/Ribbon__custom.docs.js +0 -0
- package/es/Ribbon/docs/Ribbon__default.docs.js +0 -0
- package/es/RippleEffect/RippleEffect.module.css +92 -70
- package/es/Select/GroupSelect.js +0 -0
- package/es/Select/Select.js +0 -0
- package/es/Select/Select.module.css +106 -106
- package/es/Select/SelectWithAvatar.js +0 -0
- package/es/Select/SelectWithIcon.js +0 -0
- package/es/Select/__tests__/Select.spec.js +0 -0
- package/es/Select/docs/SelectWithIcon__default.docs.js +0 -0
- package/es/Select/docs/Select__default.docs.js +0 -0
- package/es/Stencils/Stencils.js +0 -0
- package/es/Stencils/Stencils.module.css +96 -96
- package/es/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +49 -49
- package/es/Switch/Switch.js +0 -0
- package/es/Switch/Switch.module.css +110 -109
- package/es/Switch/docs/Switch__custom.docs.js +0 -0
- package/es/Switch/docs/Switch__default.docs.js +0 -0
- package/es/Tab/Tab.module.css +101 -101
- package/es/Tab/TabContent.module.css +4 -4
- package/es/Tab/Tabs.js +17 -17
- package/es/Tab/Tabs.module.css +141 -141
- package/es/Tab/docs/tabdocs.module.css +29 -29
- package/es/Tag/Tag.js +8 -8
- package/es/Tag/Tag.module.css +254 -254
- package/es/Tag/docs/Tag__custom.docs.js +0 -0
- package/es/Tag/docs/Tag__default.docs.js +0 -0
- package/es/TextBox/TextBox.js +0 -0
- package/es/TextBox/TextBox.module.css +157 -157
- package/es/TextBox/__tests__/__snapshots__/TextBox.spec.js.snap +127 -127
- package/es/TextBox/docs/TextBox__custom.docs.js +0 -0
- package/es/TextBox/docs/TextBox__default.docs.js +0 -0
- package/es/TextBox/docs/TextBox__variant.docs.js +0 -0
- package/es/TextBoxIcon/TextBoxIcon.js +0 -0
- package/es/TextBoxIcon/TextBoxIcon.module.css +78 -78
- package/es/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +334 -334
- package/es/TextBoxIcon/docs/TextBoxIcon__custom.docs.js +0 -0
- package/es/TextBoxIcon/docs/TextBoxIcon__default.docs.js +0 -0
- package/es/Textarea/Textarea.js +0 -0
- package/es/Textarea/Textarea.module.css +139 -139
- package/es/Textarea/__tests__/__snapshots__/Textarea.spec.js.snap +97 -97
- package/es/Textarea/docs/Textarea__custom.docs.js +0 -0
- package/es/Textarea/docs/Textarea__default.docs.js +0 -0
- package/es/Textarea/docs/Textarea__disabled.docs.js +0 -0
- package/es/Tooltip/Tooltip.module.css +109 -109
- package/es/common/animation.module.css +624 -624
- package/es/common/avatarsizes.module.css +44 -44
- package/es/common/basic.module.css +33 -33
- package/es/common/basicReset.module.css +40 -40
- package/es/common/common.module.css +525 -502
- package/es/common/customscroll.module.css +89 -89
- package/es/common/docStyle.module.css +766 -766
- package/es/common/reset.module.css +12 -12
- package/es/common/transition.module.css +146 -146
- package/es/deprecated/AdvancedMultiSelect.module.css +126 -126
- package/es/index.js +0 -4
- package/es/semantic/Button/semanticButton.module.css +9 -9
- package/es/utils/Common.js +0 -0
- package/es/utils/dropDownUtils.js +0 -0
- package/lib/AppContainer/AppContainer.module.css +18 -18
- package/lib/Avatar/Avatar.js +9 -9
- package/lib/Avatar/Avatar.module.css +117 -117
- package/lib/Avatar/__tests__/__snapshots__/Avatar.spec.js.snap +288 -288
- package/lib/AvatarTeam/AvatarTeam.js +7 -7
- package/lib/AvatarTeam/AvatarTeam.module.css +161 -161
- package/lib/AvatarTeam/__tests__/__snapshots__/AvatarTeam.spec.js.snap +226 -226
- package/lib/AvatarTeam/docs/AvatarTeam__custom.docs.js +0 -0
- package/lib/AvatarTeam/docs/AvatarTeam__default.docs.js +0 -0
- package/lib/AvatarTeam/docs/AvatarTeam__palette.docs.js +0 -0
- package/lib/AvatarTeam/docs/AvatarTeam__size.docs.js +0 -0
- package/lib/Button/Button.js +4 -4
- package/lib/Button/Button.module.css +521 -521
- package/lib/Button/__tests__/__snapshots__/Button.spec.js.snap +191 -191
- package/lib/Button/docs/Button__custom.docs.js +0 -0
- package/lib/Button/docs/Button__default.docs.js +0 -0
- package/lib/Buttongroup/Buttongroup.js +1 -1
- package/lib/Buttongroup/Buttongroup.module.css +89 -89
- package/lib/Buttongroup/__test__/__snapshots__/Buttongroup.spec.js.snap +146 -146
- package/lib/Card/Card.js +12 -7
- package/lib/Card/Card.module.css +20 -20
- package/lib/Card/docs/Card__Custom.docs.js +0 -0
- package/lib/Card/docs/Card__Default.docs.js +0 -0
- package/lib/Card/docs/Card__Scroll.docs.js +0 -0
- package/lib/CheckBox/CheckBox.js +0 -0
- package/lib/CheckBox/CheckBox.module.css +157 -153
- package/lib/CheckBox/docs/CheckBox__custom.docs.js +0 -0
- package/lib/CheckBox/docs/CheckBox__default.docs.js +0 -0
- package/lib/DateTime/CalendarView.js +0 -0
- package/lib/DateTime/DateTime.js +0 -0
- package/lib/DateTime/DateTime.module.css +187 -187
- package/lib/DateTime/DateWidget.js +0 -0
- package/lib/DateTime/DateWidget.module.css +38 -38
- package/lib/DateTime/YearView.js +0 -0
- package/lib/DateTime/YearView.module.css +81 -81
- package/lib/DateTime/common.js +0 -0
- package/lib/DateTime/docs/DateTime__default.docs.js +0 -0
- package/lib/DateTime/docs/DateWidget__default.docs.js +0 -0
- package/lib/DateTime/index.js +0 -0
- package/lib/DateTime/objectUtils.js +0 -0
- package/lib/DateTime/typeChecker.js +0 -0
- package/lib/DateTime/validator.js +0 -0
- package/lib/DropBox/DropBox.js +0 -0
- package/lib/DropBox/DropBox.module.css +406 -406
- package/lib/DropBox/DropBoxPositionMapping.json +144 -144
- package/lib/DropDown/DropDown.js +0 -0
- package/lib/DropDown/DropDown.module.css +5 -5
- package/lib/DropDown/DropDownHeading.js +0 -0
- package/lib/DropDown/DropDownHeading.module.css +53 -53
- package/lib/DropDown/DropDownItem.js +0 -0
- package/lib/DropDown/DropDownItem.module.css +94 -94
- package/lib/DropDown/DropDownSearch.js +0 -0
- package/lib/DropDown/DropDownSearch.module.css +14 -14
- package/lib/DropDown/DropDownSeparator.js +0 -0
- package/lib/DropDown/DropDownSeparator.module.css +7 -7
- package/lib/Label/Label.js +0 -0
- package/lib/Label/Label.module.css +52 -52
- package/lib/Label/LabelColors.module.css +20 -20
- package/lib/Label/__tests__/__snapshots__/Label.spec.js.snap +101 -101
- package/lib/Label/docs/Label__clipped.docs.js +0 -0
- package/lib/Label/docs/Label__custom.docs.js +0 -0
- package/lib/Label/docs/Label__palette.docs.js +0 -0
- package/lib/Label/docs/Label__size.docs.js +0 -0
- package/lib/Label/docs/Label__type.docs.js +0 -0
- package/lib/Layout/Box.js +18 -32
- package/lib/Layout/Container.js +18 -29
- package/lib/Layout/Layout.module.css +336 -324
- package/lib/Layout/docs/Layout__default.docs.js +0 -0
- package/lib/Layout/docs/Layout__four_Column.docs.js +16 -22
- package/lib/Layout/props/defaultProps.js +20 -0
- package/lib/Layout/props/propTypes.js +54 -0
- package/lib/Layout/utils.js +0 -0
- package/lib/LightNightMode/Colors.json +496 -496
- package/lib/ListItem/ListItem.js +0 -0
- package/lib/ListItem/ListItem.module.css +209 -205
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +6 -6
- package/lib/MultiSelect/MultiSelect.js +5 -5
- package/lib/MultiSelect/MultiSelect.module.css +205 -205
- package/lib/MultiSelect/MultiSelectWithAvatar.js +0 -0
- package/lib/MultiSelect/SelectedOptions.module.css +15 -15
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +0 -0
- package/lib/PopOver/PopOver.module.css +8 -8
- package/lib/Popup/Popup.js +0 -0
- package/lib/Popup/PositionMapping.json +73 -73
- package/lib/Radio/Radio.js +0 -0
- package/lib/Radio/Radio.module.css +112 -110
- package/lib/Radio/docs/Radio__custom.docs.js +0 -0
- package/lib/Radio/docs/Radio__default.docs.js +0 -0
- package/lib/Responsive/CustomResponsive.js +0 -0
- package/lib/Responsive/docs/Responsive__Custom.docs.js +0 -0
- package/lib/Responsive/docs/style.module.css +55 -55
- package/lib/ResponsiveDropBox/ResponsiveDropBox.module.css +6 -6
- package/lib/Ribbon/Ribbon.js +0 -0
- package/lib/Ribbon/Ribbon.module.css +376 -376
- package/lib/Ribbon/__tests__/__snapshots__/Ribbon.spec.js.snap +163 -163
- package/lib/Ribbon/docs/Ribbon__custom.docs.js +0 -0
- package/lib/Ribbon/docs/Ribbon__default.docs.js +0 -0
- package/lib/RippleEffect/RippleEffect.module.css +92 -70
- package/lib/Select/GroupSelect.js +0 -0
- package/lib/Select/Select.js +0 -0
- package/lib/Select/Select.module.css +106 -106
- package/lib/Select/SelectWithAvatar.js +0 -0
- package/lib/Select/SelectWithIcon.js +0 -0
- package/lib/Select/__tests__/Select.spec.js +0 -0
- package/lib/Select/docs/SelectWithIcon__default.docs.js +0 -0
- package/lib/Select/docs/Select__default.docs.js +0 -0
- package/lib/Stencils/Stencils.js +0 -0
- package/lib/Stencils/Stencils.module.css +96 -96
- package/lib/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +49 -49
- package/lib/Switch/Switch.js +0 -0
- package/lib/Switch/Switch.module.css +110 -109
- package/lib/Switch/docs/Switch__custom.docs.js +0 -0
- package/lib/Switch/docs/Switch__default.docs.js +0 -0
- package/lib/Tab/Tab.module.css +101 -101
- package/lib/Tab/TabContent.module.css +4 -4
- package/lib/Tab/Tabs.js +11 -11
- package/lib/Tab/Tabs.module.css +141 -141
- package/lib/Tab/docs/tabdocs.module.css +29 -29
- package/lib/Tag/Tag.js +8 -8
- package/lib/Tag/Tag.module.css +254 -254
- package/lib/Tag/docs/Tag__custom.docs.js +0 -0
- package/lib/Tag/docs/Tag__default.docs.js +0 -0
- package/lib/TextBox/TextBox.js +0 -0
- package/lib/TextBox/TextBox.module.css +157 -157
- package/lib/TextBox/__tests__/__snapshots__/TextBox.spec.js.snap +127 -127
- package/lib/TextBox/docs/TextBox__custom.docs.js +0 -0
- package/lib/TextBox/docs/TextBox__default.docs.js +0 -0
- package/lib/TextBox/docs/TextBox__variant.docs.js +0 -0
- package/lib/TextBoxIcon/TextBoxIcon.js +0 -0
- package/lib/TextBoxIcon/TextBoxIcon.module.css +78 -78
- package/lib/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +334 -334
- package/lib/TextBoxIcon/docs/TextBoxIcon__custom.docs.js +0 -0
- package/lib/TextBoxIcon/docs/TextBoxIcon__default.docs.js +0 -0
- package/lib/Textarea/Textarea.js +0 -0
- package/lib/Textarea/Textarea.module.css +139 -139
- package/lib/Textarea/__tests__/__snapshots__/Textarea.spec.js.snap +97 -97
- package/lib/Textarea/docs/Textarea__custom.docs.js +0 -0
- package/lib/Textarea/docs/Textarea__default.docs.js +0 -0
- package/lib/Textarea/docs/Textarea__disabled.docs.js +0 -0
- package/lib/Tooltip/Tooltip.module.css +109 -109
- package/lib/common/animation.module.css +624 -624
- package/lib/common/avatarsizes.module.css +44 -44
- package/lib/common/basic.module.css +33 -33
- package/lib/common/basicReset.module.css +40 -40
- package/lib/common/common.module.css +525 -502
- package/lib/common/customscroll.module.css +89 -89
- package/lib/common/docStyle.module.css +766 -766
- package/lib/common/reset.module.css +12 -12
- package/lib/common/transition.module.css +146 -146
- package/lib/deprecated/AdvancedMultiSelect.module.css +126 -126
- package/lib/index.js +0 -36
- package/lib/semantic/Button/semanticButton.module.css +9 -9
- package/lib/utils/Common.js +0 -0
- package/lib/utils/dropDownUtils.js +0 -0
- package/package.json +76 -75
- package/es/a11y/FocusScope/FocusScope.js +0 -370
- package/es/a11y/FocusScope/docs/FocusScope__default.docs.js +0 -139
- package/es/beta/FocusRing/FocusRing.js +0 -281
- package/es/beta/FocusRing/FocusRing.module.css +0 -152
- package/es/beta/FocusRing/docs/FocusRing__default.docs.js +0 -48
- package/lib/a11y/FocusScope/FocusScope.js +0 -443
- package/lib/a11y/FocusScope/docs/FocusScope__default.docs.js +0 -191
- package/lib/beta/FocusRing/FocusRing.js +0 -338
- package/lib/beta/FocusRing/FocusRing.module.css +0 -152
- package/lib/beta/FocusRing/docs/FocusRing__default.docs.js +0 -101
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
-
const eventFrom = 'keyboard' | 'pointer' | 'virtual';
|
|
3
|
-
const eventType = PointerEvent | MouseEvent | KeyboardEvent | FocusEvent; //const eventHandler = (evType=eventFrom, e=eventType) => {return eventFrom}
|
|
4
|
-
|
|
5
|
-
let currentEventType = null;
|
|
6
|
-
let changeHandlers = new Set();
|
|
7
|
-
let hasSetupGlobalListeners = false;
|
|
8
|
-
let hasEventBeforeFocus = false; // let onFocusWithin= props.onFocusWithin?props.onFocusWithin:(e)=>{return void};
|
|
9
|
-
// let onBlurWithin = props.onBlurWithin?props.onBlurWithin:(e) =>void
|
|
10
|
-
// eventHandler that is called when the the focus within state changes.
|
|
11
|
-
// onFocusWithinChange(isFocusWithin)=> void
|
|
12
|
-
// Only Tab or Esc keys will make focus visible on text input elements
|
|
13
|
-
|
|
14
|
-
const FOCUS_VISIBLE_INPUT_KEYS = {
|
|
15
|
-
Tab: true,
|
|
16
|
-
Escape: false
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function triggerChangeHandlers() {
|
|
20
|
-
let evType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eventFrom;
|
|
21
|
-
let e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : eventType;
|
|
22
|
-
|
|
23
|
-
for (let handler of changeHandlers) {
|
|
24
|
-
handler(evType, e);
|
|
25
|
-
}
|
|
26
|
-
} //Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function isValidKey(e) {
|
|
30
|
-
return !(e.metaKey || e.altKey || e.ctrlKey);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function handleKeyboardEvent(e) {
|
|
34
|
-
hasEventBeforeFocus = true;
|
|
35
|
-
|
|
36
|
-
if (isValidKey(e)) {
|
|
37
|
-
currentEventType = 'keyboard';
|
|
38
|
-
triggerChangeHandlers('keyboard', e);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function handlePointerEvent(e) {
|
|
43
|
-
currentEventType = 'pointer';
|
|
44
|
-
|
|
45
|
-
if (e.type === 'mousedown' || e.type === 'pointerdown') {
|
|
46
|
-
hasEventBeforeFocus = true;
|
|
47
|
-
triggerChangeHandlers('pointer', e);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function handleFocusEvent(e) {
|
|
52
|
-
// Firefox fires two extra focus events when the user first clicks into an iframe:
|
|
53
|
-
// first on the window, then on the document. We ignore these events so they don't
|
|
54
|
-
// cause keyboard focus rings to appear.
|
|
55
|
-
if (e.target === window || e.target === document) {
|
|
56
|
-
return;
|
|
57
|
-
} // If a focus event occurs without a preceding keyboard or pointer event, switch to keyboard evType.
|
|
58
|
-
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!hasEventBeforeFocus) {
|
|
62
|
-
currentEventType = 'keyboard';
|
|
63
|
-
triggerChangeHandlers('keyboard', e);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
hasEventBeforeFocus = false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function handleWindowBlur() {
|
|
70
|
-
// When the window is blurred, reset state. This is necessary when tabbing out of the window,
|
|
71
|
-
// for example, since a subsequent focus event won't be fired.
|
|
72
|
-
hasEventBeforeFocus = false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function setupGlobalFocusEvents() {
|
|
76
|
-
if (typeof window === 'undefined' || hasSetupGlobalListeners) {
|
|
77
|
-
return;
|
|
78
|
-
} // Programmatic focus() calls shouldn't affect the current input evType.
|
|
79
|
-
// However, we need to detect other cases when a focus event occurs without
|
|
80
|
-
// a preceding user event (e.g. screen reader focus). Overriding the focus
|
|
81
|
-
// method on HTMLElement.prototype is a bit hacky, but works.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let focus = HTMLElement.prototype.focus;
|
|
85
|
-
|
|
86
|
-
HTMLElement.prototype.focus = function () {
|
|
87
|
-
hasEventBeforeFocus = true;
|
|
88
|
-
focus.apply(this, arguments);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
document.addEventListener('keydown', handleKeyboardEvent, true);
|
|
92
|
-
document.addEventListener('keyup', handleKeyboardEvent, true); // Register focus events on the window so they are sure to happen
|
|
93
|
-
// before React's event listeners (registered on the document).
|
|
94
|
-
|
|
95
|
-
window.addEventListener('focus', handleFocusEvent, true);
|
|
96
|
-
window.addEventListener('blur', handleWindowBlur, false);
|
|
97
|
-
|
|
98
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
99
|
-
document.addEventListener('pointerdown', handlePointerEvent, true);
|
|
100
|
-
document.addEventListener('pointermove', handlePointerEvent, true);
|
|
101
|
-
document.addEventListener('pointerup', handlePointerEvent, true);
|
|
102
|
-
} else {
|
|
103
|
-
document.addEventListener('mousedown', handlePointerEvent, true);
|
|
104
|
-
document.addEventListener('mousemove', handlePointerEvent, true);
|
|
105
|
-
document.addEventListener('mouseup', handlePointerEvent, true);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
hasSetupGlobalListeners = true;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isFocusVisible() {
|
|
112
|
-
return currentEventType !== 'pointer';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function useFocusVisible(props) {
|
|
116
|
-
setupGlobalFocusEvents();
|
|
117
|
-
let [isFocusVisibleState, setFocusVisible] = useState(isFocusVisible());
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
let handler = (evType, e) => {
|
|
120
|
-
// If this is a text input component, don't update the focus visible style when
|
|
121
|
-
// typing except for when the Tab and Escape keys are pressed.
|
|
122
|
-
if (evType === 'keyboard' && e instanceof KeyboardEvent && !FOCUS_VISIBLE_INPUT_KEYS[e.key]) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
setFocusVisible(isFocusVisible());
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
changeHandlers.add(handler);
|
|
130
|
-
return () => {
|
|
131
|
-
changeHandlers.delete(handler);
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
return {
|
|
135
|
-
isFocusVisible: isFocusVisibleState
|
|
136
|
-
};
|
|
137
|
-
} //If true, keyboard focus is visible.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
function useFocusWithin(props) {
|
|
141
|
-
let state = useRef({
|
|
142
|
-
isFocusWithin: false
|
|
143
|
-
}).current;
|
|
144
|
-
|
|
145
|
-
if (props.isDisabled) {
|
|
146
|
-
return {
|
|
147
|
-
focusWithinProps: {}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
let onFocus = e => {
|
|
152
|
-
if (!state.isFocusWithin) {
|
|
153
|
-
if (props.onFocusWithin) {
|
|
154
|
-
props.onFocusWithin(e);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (props.onFocusWithinChange) {
|
|
158
|
-
props.onFocusWithinChange(true);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
state.isFocusWithin = true;
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
let onBlur = e => {
|
|
166
|
-
// We don't want to trigger onBlurWithin and then immediately onFocusWithin again
|
|
167
|
-
// when moving focus inside the element. Only trigger if the currentTarget doesn't
|
|
168
|
-
// include the relatedTarget (where focus is moving).
|
|
169
|
-
if (state.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
|
|
170
|
-
if (props.onBlurWithin) {
|
|
171
|
-
props.onBlurWithin(e);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (props.onFocusWithinChange) {
|
|
175
|
-
props.onFocusWithinChange(false);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
state.isFocusWithin = false;
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
focusWithinProps: {
|
|
184
|
-
onFocus: onFocus,
|
|
185
|
-
onBlur: onBlur
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function useFocus(props) {
|
|
191
|
-
if (props.isDisabled) {
|
|
192
|
-
return {
|
|
193
|
-
focusProps: {}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
let onFocus, onBlur;
|
|
198
|
-
|
|
199
|
-
if (props.onFocus || props.onFocusChange) {
|
|
200
|
-
onFocus = e => {
|
|
201
|
-
if (e.target === e.currentTarget) {
|
|
202
|
-
if (props.onFocus) {
|
|
203
|
-
props.onFocus(e);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (props.onFocusChange) {
|
|
207
|
-
props.onFocusChange(true);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (props.onBlur || props.onFocusChange) {
|
|
214
|
-
onBlur = e => {
|
|
215
|
-
if (e.target === e.currentTarget) {
|
|
216
|
-
if (props.onBlur) {
|
|
217
|
-
props.onBlur(e);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (props.onFocusChange) {
|
|
221
|
-
props.onFocusChange(false);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
focusProps: {
|
|
229
|
-
onFocus,
|
|
230
|
-
onBlur
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function useFocusRing(props) {
|
|
236
|
-
let {
|
|
237
|
-
within
|
|
238
|
-
} = props;
|
|
239
|
-
let [isFocused, setFocused] = useState(false);
|
|
240
|
-
let [isFocusWithin, setFocusWithin] = useState(false);
|
|
241
|
-
let {
|
|
242
|
-
isFocusVisible
|
|
243
|
-
} = useFocusVisible(props);
|
|
244
|
-
let {
|
|
245
|
-
focusProps
|
|
246
|
-
} = useFocus({
|
|
247
|
-
isDisabled: within,
|
|
248
|
-
onFocusChange: setFocused
|
|
249
|
-
});
|
|
250
|
-
let {
|
|
251
|
-
focusWithinProps
|
|
252
|
-
} = useFocusWithin({
|
|
253
|
-
isDisabled: !within,
|
|
254
|
-
onFocusWithinChange: setFocusWithin
|
|
255
|
-
});
|
|
256
|
-
return {
|
|
257
|
-
isFocused: within ? isFocusWithin : isFocused,
|
|
258
|
-
isFocusVisible: (within ? isFocusWithin : isFocused) && isFocusVisible,
|
|
259
|
-
focusProps: within ? focusWithinProps : focusProps
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export default function FocusRing(props) {
|
|
264
|
-
let {
|
|
265
|
-
children,
|
|
266
|
-
focusClass,
|
|
267
|
-
focusRingClass
|
|
268
|
-
} = props;
|
|
269
|
-
let {
|
|
270
|
-
isFocused,
|
|
271
|
-
isFocusVisible,
|
|
272
|
-
focusProps
|
|
273
|
-
} = useFocusRing(props);
|
|
274
|
-
let child = React.Children.only(children);
|
|
275
|
-
return /*#__PURE__*/React.cloneElement(child, { ...focusProps,
|
|
276
|
-
customClass: isFocusVisible ? focusRingClass : isFocused ? focusClass : ''
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
FocusRing.docs = {
|
|
280
|
-
componentGroup: 'Atom'
|
|
281
|
-
};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
.input{
|
|
2
|
-
width:100%;
|
|
3
|
-
outline: 0;
|
|
4
|
-
border: 1px;
|
|
5
|
-
border-bottom: 1px solid #ddd
|
|
6
|
-
}
|
|
7
|
-
.badFocus {
|
|
8
|
-
display: inline-block;
|
|
9
|
-
margin-top: 10px;
|
|
10
|
-
border-radius: 2px;
|
|
11
|
-
box-shadow: 0 0 0 4px rgba(20,20,20,0.15);
|
|
12
|
-
margin-bottom: 30px;
|
|
13
|
-
padding: 2px;
|
|
14
|
-
margin: 10px;
|
|
15
|
-
}
|
|
16
|
-
[dir=ltr] .badFocus {
|
|
17
|
-
margin-right: 5px;
|
|
18
|
-
}
|
|
19
|
-
[dir=rtl] .badFocus {
|
|
20
|
-
margin-left: 5px;
|
|
21
|
-
}
|
|
22
|
-
:focus{
|
|
23
|
-
outline: 0;
|
|
24
|
-
}
|
|
25
|
-
.goodFocus {
|
|
26
|
-
display: inline-block;
|
|
27
|
-
border-radius: 2px;
|
|
28
|
-
padding: 2px;
|
|
29
|
-
box-shadow: 0 0 0 4px rgba(91,147,255,0.25);
|
|
30
|
-
}
|
|
31
|
-
.inpFocus{
|
|
32
|
-
width: auto;
|
|
33
|
-
padding: 5px;
|
|
34
|
-
border-radius: 2px;
|
|
35
|
-
margin: 10px;
|
|
36
|
-
}
|
|
37
|
-
.mouseFocus, .inpFocus:focus{
|
|
38
|
-
box-shadow: 0 0 0 4px rgba(20,20,20,0.15);
|
|
39
|
-
}
|
|
40
|
-
.tabFocus, .tabFocus:focus{
|
|
41
|
-
box-shadow: 0 0 0 4px rgba(24, 91, 226, 0.25);
|
|
42
|
-
}
|
|
43
|
-
.freezeLayer{
|
|
44
|
-
position: fixed;
|
|
45
|
-
top:0;
|
|
46
|
-
bottom: 0;
|
|
47
|
-
display: flex;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
align-items: center;
|
|
50
|
-
background-color: rgba(20,20,20,.5);
|
|
51
|
-
}
|
|
52
|
-
[dir=ltr] .freezeLayer{
|
|
53
|
-
left:0;
|
|
54
|
-
right: 0;
|
|
55
|
-
}
|
|
56
|
-
[dir=rtl] .freezeLayer{
|
|
57
|
-
right:0;
|
|
58
|
-
left: 0;
|
|
59
|
-
}
|
|
60
|
-
[dir=ltr] .element{
|
|
61
|
-
margin:1rem 0 1rem .5rem;
|
|
62
|
-
}
|
|
63
|
-
[dir=rtl] .element{
|
|
64
|
-
margin:1rem .5rem 1rem 0;
|
|
65
|
-
}
|
|
66
|
-
.container{
|
|
67
|
-
min-width: 400px;
|
|
68
|
-
transition: .3s ease-in-out;
|
|
69
|
-
position: absolute;
|
|
70
|
-
background-color: #fff;
|
|
71
|
-
border-radius: 10px;
|
|
72
|
-
padding: 20px;
|
|
73
|
-
}
|
|
74
|
-
.formContainer{
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
}
|
|
78
|
-
label{
|
|
79
|
-
font-weight: 400;
|
|
80
|
-
font-size: 20px;
|
|
81
|
-
}
|
|
82
|
-
.sOpt:focus{
|
|
83
|
-
background-color: red;
|
|
84
|
-
}
|
|
85
|
-
.button {
|
|
86
|
-
-webkit-appearance: none;
|
|
87
|
-
appearance: none;
|
|
88
|
-
color: white;
|
|
89
|
-
font-size: 14px;
|
|
90
|
-
background: green;
|
|
91
|
-
border: none;
|
|
92
|
-
padding: 4px 8px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.focus-ring {
|
|
96
|
-
outline: 2px solid dodgerblue;
|
|
97
|
-
outline-offset: 2px;
|
|
98
|
-
}
|
|
99
|
-
.box{
|
|
100
|
-
display: flex;
|
|
101
|
-
flex-direction: column;
|
|
102
|
-
}
|
|
103
|
-
.box1{
|
|
104
|
-
transform: scale(1);
|
|
105
|
-
}
|
|
106
|
-
[dir=ltr] .manage{
|
|
107
|
-
right: 0;
|
|
108
|
-
}
|
|
109
|
-
[dir=rtl] .manage{
|
|
110
|
-
left: 0;
|
|
111
|
-
}
|
|
112
|
-
.primary{
|
|
113
|
-
color: #fff;
|
|
114
|
-
text-decoration: none;
|
|
115
|
-
font-size: 13px;
|
|
116
|
-
background: #00aefe;
|
|
117
|
-
box-shadow: 0 2px 6px 0 rgba(209, 209, 209, 0.18);
|
|
118
|
-
padding: 7px 12px;
|
|
119
|
-
cursor: pointer;
|
|
120
|
-
margin-top: 1px;
|
|
121
|
-
border-radius: 3px;
|
|
122
|
-
border: 1px solid #00aefe;
|
|
123
|
-
margin:10px
|
|
124
|
-
}
|
|
125
|
-
.secondary{
|
|
126
|
-
color: #8c8c8c;
|
|
127
|
-
text-decoration: none;
|
|
128
|
-
font-size: 13px;
|
|
129
|
-
background: #fff;
|
|
130
|
-
box-shadow: 0 2px 6px 0 rgba(209, 209, 209, 0.18);
|
|
131
|
-
padding: 7px 12px;
|
|
132
|
-
cursor: pointer;
|
|
133
|
-
margin-top: 1px;
|
|
134
|
-
border-radius: 3px;
|
|
135
|
-
border: 1px solid #8c8c8c
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
[dir=ltr] .primary:focus{
|
|
139
|
-
box-shadow: 2px 2px 6px 0 rgba(19, 173, 211, 0.493);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
[dir=rtl] .primary:focus{
|
|
143
|
-
box-shadow: -2px 2px 6px 0 rgba(19, 173, 211, 0.493);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
[dir=ltr] .secondary:focus{
|
|
147
|
-
box-shadow: 2px 2px 6px 0 rgba(39, 40, 41, 0.493)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
[dir=rtl] .secondary:focus{
|
|
151
|
-
box-shadow: -2px 2px 6px 0 rgba(39, 40, 41, 0.493)
|
|
152
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Button from '../../../Button/Button';
|
|
3
|
-
import TextBox from '../../../TextBox/TextBox';
|
|
4
|
-
import FocusRing from '../FocusRing';
|
|
5
|
-
import style from '../FocusRing.module.css';
|
|
6
|
-
import { Box } from '../../../Layout';
|
|
7
|
-
export default class FocusRing__default extends React.Component {
|
|
8
|
-
render() {
|
|
9
|
-
let styles = {
|
|
10
|
-
margin: '30px',
|
|
11
|
-
width: '50%',
|
|
12
|
-
display: 'block'
|
|
13
|
-
};
|
|
14
|
-
return /*#__PURE__*/React.createElement(FocusRing, {
|
|
15
|
-
focusClass: style.mouseFocus,
|
|
16
|
-
focusRingClass: style.tabFocus,
|
|
17
|
-
within: true
|
|
18
|
-
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement("span", {
|
|
19
|
-
style: styles
|
|
20
|
-
}, /*#__PURE__*/React.createElement(FocusRing, {
|
|
21
|
-
focusClass: style.mouseFocus,
|
|
22
|
-
focusRingClass: style.tabFocus
|
|
23
|
-
}, /*#__PURE__*/React.createElement(TextBox, {
|
|
24
|
-
type: "text",
|
|
25
|
-
defaultValue: "Input a",
|
|
26
|
-
id: "1"
|
|
27
|
-
}))), /*#__PURE__*/React.createElement("span", {
|
|
28
|
-
style: styles
|
|
29
|
-
}, /*#__PURE__*/React.createElement(FocusRing, {
|
|
30
|
-
focusClass: style.mouseFocus,
|
|
31
|
-
focusRingClass: style.tabFocus
|
|
32
|
-
}, /*#__PURE__*/React.createElement(TextBox, {
|
|
33
|
-
type: "text",
|
|
34
|
-
defaultValue: "Input b",
|
|
35
|
-
id: "2"
|
|
36
|
-
}))), /*#__PURE__*/React.createElement("span", {
|
|
37
|
-
style: styles
|
|
38
|
-
}, /*#__PURE__*/React.createElement(TextBox, {
|
|
39
|
-
type: "text",
|
|
40
|
-
defaultValue: "Input c",
|
|
41
|
-
id: "3"
|
|
42
|
-
}))));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
FocusRing__default.docs = {
|
|
47
|
-
componentGroup: 'Atom'
|
|
48
|
-
};
|