1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.setTextDirection = setTextDirection;
|
7 | exports.default = void 0;
|
8 |
|
9 | var _console = require("@instructure/console");
|
10 |
|
11 | var _canUseDOM = require("@instructure/ui-dom-utils/lib/canUseDOM.js");
|
12 |
|
13 | /*
|
14 | * The MIT License (MIT)
|
15 | *
|
16 | * Copyright (c) 2015 - present Instructure, Inc.
|
17 | *
|
18 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
19 | * of this software and associated documentation files (the "Software"), to deal
|
20 | * in the Software without restriction, including without limitation the rights
|
21 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
22 | * copies of the Software, and to permit persons to whom the Software is
|
23 | * furnished to do so, subject to the following conditions:
|
24 | *
|
25 | * The above copyright notice and this permission notice shall be included in all
|
26 | * copies or substantial portions of the Software.
|
27 | *
|
28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
33 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
34 | * SOFTWARE.
|
35 | */
|
36 | var hasRan = false;
|
37 | /**
|
38 | * ---
|
39 | * category: utilities/themes
|
40 | * ---
|
41 | * Sets the document text direction as it's required for themeable component
|
42 | * bidirectional styles.
|
43 | */
|
44 |
|
45 | function setTextDirection() {
|
46 | if (hasRan) return;
|
47 | hasRan = true;
|
48 |
|
49 | if (_canUseDOM.canUseDOM) {
|
50 | var dir = document.documentElement.getAttribute('dir');
|
51 |
|
52 | if (!dir) {
|
53 | /*#__PURE__*/
|
54 | ( /*#__PURE__*/0, _console.warn)(dir, "[themeable] component styles require setting a 'dir' attribute on the HTML element.\n To prevent breaking changes, we'll set it to a default value: 'ltr'.");
|
55 | document.documentElement.setAttribute('dir', 'ltr');
|
56 | }
|
57 | }
|
58 | }
|
59 |
|
60 | var _default = setTextDirection;
|
61 | exports.default = _default; |
\ | No newline at end of file |