@dnb/eufemia 10.1.0 → 10.2.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/cjs/components/anchor/style/deps.scss +9 -0
  3. package/cjs/components/button/style/themes/dnb-button-theme-eiendom.css +4 -0
  4. package/cjs/components/button/style/themes/dnb-button-theme-eiendom.min.css +1 -1
  5. package/cjs/components/button/style/themes/dnb-button-theme-ui.css +4 -0
  6. package/cjs/components/button/style/themes/dnb-button-theme-ui.min.css +1 -1
  7. package/cjs/components/button/style/themes/dnb-button-theme-ui.scss +5 -0
  8. package/cjs/components/global-status/GlobalStatus.d.ts +3 -3
  9. package/cjs/components/heading/Heading.d.ts +89 -106
  10. package/cjs/components/heading/Heading.js +119 -184
  11. package/cjs/components/heading/HeadingContext.d.ts +12 -5
  12. package/cjs/components/heading/HeadingContext.js +2 -2
  13. package/cjs/components/heading/HeadingCounter.d.ts +38 -14
  14. package/cjs/components/heading/HeadingCounter.js +20 -17
  15. package/cjs/components/heading/HeadingHelpers.d.ts +45 -23
  16. package/cjs/components/heading/HeadingHelpers.js +29 -24
  17. package/cjs/components/heading/HeadingProvider.d.ts +9 -12
  18. package/cjs/components/heading/HeadingProvider.js +47 -90
  19. package/cjs/components/info-card/style/dnb-info-card.css +1 -1
  20. package/cjs/components/info-card/style/dnb-info-card.min.css +1 -1
  21. package/cjs/components/info-card/style/dnb-info-card.scss +1 -1
  22. package/cjs/shared/Eufemia.d.ts +1 -1
  23. package/cjs/shared/Eufemia.js +2 -2
  24. package/cjs/shared/index.d.ts +2 -1
  25. package/cjs/style/dnb-ui-components.css +1 -1
  26. package/cjs/style/dnb-ui-components.min.css +1 -1
  27. package/cjs/style/themes/theme-eiendom/eiendom-theme-components.css +9 -1
  28. package/cjs/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
  29. package/cjs/style/themes/theme-sbanken/sbanken-theme-components.css +1 -1
  30. package/cjs/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
  31. package/cjs/style/themes/theme-ui/ui-theme-components.css +5 -1
  32. package/cjs/style/themes/theme-ui/ui-theme-components.min.css +1 -1
  33. package/components/anchor/style/deps.scss +9 -0
  34. package/components/button/style/themes/dnb-button-theme-eiendom.css +4 -0
  35. package/components/button/style/themes/dnb-button-theme-eiendom.min.css +1 -1
  36. package/components/button/style/themes/dnb-button-theme-ui.css +4 -0
  37. package/components/button/style/themes/dnb-button-theme-ui.min.css +1 -1
  38. package/components/button/style/themes/dnb-button-theme-ui.scss +5 -0
  39. package/components/global-status/GlobalStatus.d.ts +3 -3
  40. package/components/heading/Heading.d.ts +89 -106
  41. package/components/heading/Heading.js +115 -183
  42. package/components/heading/HeadingContext.d.ts +12 -5
  43. package/components/heading/HeadingContext.js +2 -2
  44. package/components/heading/HeadingCounter.d.ts +38 -14
  45. package/components/heading/HeadingCounter.js +20 -17
  46. package/components/heading/HeadingHelpers.d.ts +45 -23
  47. package/components/heading/HeadingHelpers.js +27 -13
  48. package/components/heading/HeadingProvider.d.ts +9 -12
  49. package/components/heading/HeadingProvider.js +46 -90
  50. package/components/info-card/style/dnb-info-card.css +1 -1
  51. package/components/info-card/style/dnb-info-card.min.css +1 -1
  52. package/components/info-card/style/dnb-info-card.scss +1 -1
  53. package/es/components/anchor/style/deps.scss +9 -0
  54. package/es/components/button/style/themes/dnb-button-theme-eiendom.css +4 -0
  55. package/es/components/button/style/themes/dnb-button-theme-eiendom.min.css +1 -1
  56. package/es/components/button/style/themes/dnb-button-theme-ui.css +4 -0
  57. package/es/components/button/style/themes/dnb-button-theme-ui.min.css +1 -1
  58. package/es/components/button/style/themes/dnb-button-theme-ui.scss +5 -0
  59. package/es/components/global-status/GlobalStatus.d.ts +3 -3
  60. package/es/components/heading/Heading.d.ts +89 -106
  61. package/es/components/heading/Heading.js +115 -183
  62. package/es/components/heading/HeadingContext.d.ts +12 -5
  63. package/es/components/heading/HeadingContext.js +2 -2
  64. package/es/components/heading/HeadingCounter.d.ts +38 -14
  65. package/es/components/heading/HeadingCounter.js +19 -18
  66. package/es/components/heading/HeadingHelpers.d.ts +45 -23
  67. package/es/components/heading/HeadingHelpers.js +27 -13
  68. package/es/components/heading/HeadingProvider.d.ts +9 -12
  69. package/es/components/heading/HeadingProvider.js +46 -90
  70. package/es/components/info-card/style/dnb-info-card.css +1 -1
  71. package/es/components/info-card/style/dnb-info-card.min.css +1 -1
  72. package/es/components/info-card/style/dnb-info-card.scss +1 -1
  73. package/es/shared/Eufemia.d.ts +1 -1
  74. package/es/shared/Eufemia.js +2 -2
  75. package/es/shared/index.d.ts +2 -1
  76. package/es/style/dnb-ui-components.css +1 -1
  77. package/es/style/dnb-ui-components.min.css +1 -1
  78. package/es/style/themes/theme-eiendom/eiendom-theme-components.css +9 -1
  79. package/es/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
  80. package/es/style/themes/theme-sbanken/sbanken-theme-components.css +1 -1
  81. package/es/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
  82. package/es/style/themes/theme-ui/ui-theme-components.css +5 -1
  83. package/es/style/themes/theme-ui/ui-theme-components.min.css +1 -1
  84. package/esm/dnb-ui-basis.min.mjs +1 -1
  85. package/esm/dnb-ui-components.min.mjs +1 -1
  86. package/esm/dnb-ui-elements.min.mjs +1 -1
  87. package/esm/dnb-ui-extensions.min.mjs +1 -1
  88. package/esm/dnb-ui-lib.min.mjs +1 -1
  89. package/package.json +1 -1
  90. package/shared/Eufemia.d.ts +1 -1
  91. package/shared/Eufemia.js +2 -2
  92. package/shared/index.d.ts +2 -1
  93. package/style/dnb-ui-components.css +1 -1
  94. package/style/dnb-ui-components.min.css +1 -1
  95. package/style/themes/theme-eiendom/eiendom-theme-components.css +9 -1
  96. package/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
  97. package/style/themes/theme-sbanken/sbanken-theme-components.css +1 -1
  98. package/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
  99. package/style/themes/theme-ui/ui-theme-components.css +5 -1
  100. package/style/themes/theme-ui/ui-theme-components.min.css +1 -1
  101. package/umd/dnb-ui-basis.min.js +1 -1
  102. package/umd/dnb-ui-components.min.js +1 -1
  103. package/umd/dnb-ui-elements.min.js +1 -1
  104. package/umd/dnb-ui-extensions.min.js +1 -1
  105. package/umd/dnb-ui-lib.min.js +1 -1
@@ -1,23 +1,22 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- const _excluded = ["text", "relevel", "group", "debug", "debug_counter", "reset", "skip_correction", "increase", "decrease", "up", "down", "inherit", "level", "size", "skeleton", "element", "class", "className", "children"];
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ const _excluded = ["text", "group", "debug", "debug_counter", "reset", "skip_correction", "increase", "decrease", "up", "down", "inherit", "level", "size", "skeleton", "element", "className", "children"];
5
5
 
6
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7
7
 
8
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9
9
 
10
10
  import React from 'react';
11
- import PropTypes from 'prop-types';
12
11
  import classnames from 'classnames';
13
12
  import { isTrue, validateDOMAttributes } from '../../shared/component-helper';
14
13
  import '../../shared/helpers';
15
- import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper';
14
+ import { createSpacingClasses } from '../space/SpacingHelper';
16
15
  import HeadingContext from './HeadingContext';
17
16
  import Context from '../../shared/Context';
18
17
  import HeadingProvider from './HeadingProvider';
19
18
  import { createSkeletonClass } from '../skeleton/SkeletonHelper';
20
- import { correctHeadingLevel, resetLevels, resetAllLevels, setNextLevel, globalSyncCounter, globalHeadingCounter, windupHeadings, teardownHeadings, debugCounter } from './HeadingHelpers';
19
+ import { correctInternalHeadingLevel, resetLevels, resetAllLevels, setNextLevel, globalSyncCounter, globalHeadingCounter, windupHeadings, teardownHeadings, debugCounter } from './HeadingHelpers';
21
20
  import { initCounter } from './HeadingCounter';
22
21
  export const levelResolution = {
23
22
  1: 'xx-large',
@@ -27,205 +26,138 @@ export const levelResolution = {
27
26
  5: 'small',
28
27
  6: 'x-small'
29
28
  };
30
- export default class Heading extends React.PureComponent {
31
- static getDerivedStateFromProps(props, state) {
32
- if (state._listenForPropChanges) {
33
- const level = parseFloat(props.level);
34
-
35
- if (state.prevLevel !== props.level && level > 0 && level !== state.level || props.relevel) {
36
- var _state$context$headin, _state$context$headin2;
37
-
38
- state.counter.skipMakeMeReady();
39
- const {
40
- level: newLevel
41
- } = correctHeadingLevel({
42
- counter: state.counter,
43
- level,
44
- bypassChecks: isTrue(props.skip_correction) || isTrue((_state$context$headin = state.context.heading) === null || _state$context$headin === void 0 ? void 0 : _state$context$headin.skip_correction),
45
- source: props.text || props.children,
46
- debug: props.debug || ((_state$context$headin2 = state.context.heading) === null || _state$context$headin2 === void 0 ? void 0 : _state$context$headin2.debug)
47
- });
48
- state.level = state.prevLevel = newLevel;
49
- }
50
- }
51
-
52
- state._listenForPropChanges = true;
53
- return state;
54
- }
55
-
56
- constructor(props, context) {
57
- var _context$heading, _state$context$headin3, _state$context$headin4;
29
+ export default function Heading(props) {
30
+ var _headingContext$headi2, _headingContext$headi3;
31
+
32
+ const context = React.useContext(Context);
33
+ const headingContext = React.useContext(HeadingContext);
34
+
35
+ const _ref = React.useRef();
36
+
37
+ const {
38
+ text,
39
+ group: _group,
40
+ debug: _debug,
41
+ debug_counter: _debug_counter,
42
+ reset: _reset,
43
+ skip_correction: _skip_correction,
44
+ increase: _increase,
45
+ decrease: _decrease,
46
+ up: _up,
47
+ down: _down,
48
+ inherit: _inherit,
49
+ level: _level,
50
+ size: _size = 'auto',
51
+ skeleton: _skeleton,
52
+ element: _element,
53
+ className,
54
+ children
55
+ } = props,
56
+ rest = _objectWithoutProperties(props, _excluded);
57
+
58
+ const [state, setState] = React.useState(() => {
59
+ var _headingContext$headi, _state$headingContext, _state$headingContext2, _state$headingContext3, _state$headingContext4;
58
60
 
59
- super(props);
60
- this._ref = React.createRef();
61
61
  const state = {
62
+ level: null,
63
+ counter: null,
62
64
  context,
63
- _listenForPropChanges: true
65
+ headingContext
64
66
  };
65
-
66
- if ((_context$heading = context.heading) !== null && _context$heading !== void 0 && _context$heading.counter) {
67
- state.counter = initCounter(props);
68
- state.counter.setContextCounter(context.heading.counter);
69
- state.counter.isHeading = true;
70
- } else {
71
- state.counter = initCounter(props);
72
- state.counter.setContextCounter(globalHeadingCounter.current);
73
- state.counter.isHeading = true;
74
- }
75
-
76
- state.counter = correctHeadingLevel({
77
- ref: props,
67
+ state.counter = initCounter(props);
68
+ const counter = (_headingContext$headi = headingContext.heading) !== null && _headingContext$headi !== void 0 && _headingContext$headi.counter ? headingContext.heading.counter : globalHeadingCounter.current;
69
+ state.counter.setContextCounter(counter);
70
+ state.counter.isHeading = true;
71
+ state.counter = correctInternalHeadingLevel({
78
72
  counter: state.counter,
79
- level: parseFloat(props.level),
73
+ ref: props,
74
+ level: parseFloat(String(props.level)),
80
75
  inherit: isTrue(props.inherit),
81
76
  reset: props.reset,
82
77
  increase: isTrue(props.increase) || isTrue(props.up),
83
78
  decrease: isTrue(props.decrease) || isTrue(props.down),
84
- bypassChecks: isTrue(props.skip_correction) || isTrue((_state$context$headin3 = state.context.heading) === null || _state$context$headin3 === void 0 ? void 0 : _state$context$headin3.skip_correction),
79
+ bypassChecks: isTrue(props.skip_correction) || isTrue((_state$headingContext = state.headingContext) === null || _state$headingContext === void 0 ? void 0 : (_state$headingContext2 = _state$headingContext.heading) === null || _state$headingContext2 === void 0 ? void 0 : _state$headingContext2.skip_correction),
85
80
  source: props.text || props.children,
86
- debug: props.debug || ((_state$context$headin4 = state.context.heading) === null || _state$context$headin4 === void 0 ? void 0 : _state$context$headin4.debug)
81
+ debug: props.debug || ((_state$headingContext3 = state.headingContext) === null || _state$headingContext3 === void 0 ? void 0 : (_state$headingContext4 = _state$headingContext3.heading) === null || _state$headingContext4 === void 0 ? void 0 : _state$headingContext4.debug)
87
82
  });
88
83
  globalSyncCounter.current = state.counter;
89
84
  state.level = state.counter.level;
90
- state.prevLevel = props.level;
91
- this.state = state;
92
- }
93
-
94
- componentDidMount() {
85
+ state.prevLevel = parseFloat(String(props.level));
86
+ return state;
87
+ });
88
+ React.useEffect(() => {
95
89
  windupHeadings();
96
- this.state.counter.windup();
97
- }
98
-
99
- componentWillUnmount() {
100
- teardownHeadings();
101
- this.state.counter.teardown();
102
- }
103
-
104
- render() {
105
- var _this$context$heading, _this$context$heading2;
106
-
107
- const _this$props = this.props,
108
- {
109
- text,
110
- relevel: _relevel,
111
- group: _group,
112
- debug: _debug,
113
- debug_counter: _debug_counter,
114
- reset: _reset,
115
- skip_correction: _skip_correction,
116
- increase: _increase,
117
- decrease: _decrease,
118
- up: _up,
119
- down: _down,
120
- inherit: _inherit,
121
- level: _level,
122
- size: _size,
123
- skeleton: _skeleton,
124
- element: _element,
125
- class: _className,
126
- className,
127
- children
128
- } = _this$props,
129
- rest = _objectWithoutProperties(_this$props, _excluded);
130
-
131
- let {
132
- size,
133
- element,
134
- skeleton
135
- } = this.props;
136
- const {
137
- level
138
- } = this.state;
139
- const debug = _debug || ((_this$context$heading = this.context.heading) === null || _this$context$heading === void 0 ? void 0 : _this$context$heading.debug);
140
- const debug_counter = _debug_counter || ((_this$context$heading2 = this.context.heading) === null || _this$context$heading2 === void 0 ? void 0 : _this$context$heading2.debug_counter);
141
-
142
- const attributes = _objectSpread({}, rest);
143
-
144
- if (element === 'auto' || element === null) {
145
- element = `h${level || '6'}`;
146
-
147
- if (_size === 'auto' || _size === null) {
148
- size = levelResolution[level || '6'];
149
- }
150
- } else {
151
- if (!attributes.role) {
152
- attributes.role = 'heading';
153
- }
90
+ state.counter.windup();
91
+ return () => {
92
+ teardownHeadings();
93
+ state.counter.teardown();
94
+ };
95
+ }, []);
96
+ React.useEffect(() => {
97
+ const level = parseFloat(String(props.level));
98
+
99
+ if (state.prevLevel !== props.level && level > 0 && level !== state.level) {
100
+ var _state$headingContext5, _state$headingContext6, _state$headingContext7, _state$headingContext8;
101
+
102
+ const {
103
+ level: newLevel
104
+ } = correctInternalHeadingLevel({
105
+ counter: state.counter,
106
+ isRerender: true,
107
+ level,
108
+ bypassChecks: isTrue(props.skip_correction) || isTrue((_state$headingContext5 = state.headingContext) === null || _state$headingContext5 === void 0 ? void 0 : (_state$headingContext6 = _state$headingContext5.heading) === null || _state$headingContext6 === void 0 ? void 0 : _state$headingContext6.skip_correction),
109
+ source: props.text || props.children,
110
+ debug: props.debug || ((_state$headingContext7 = state.headingContext) === null || _state$headingContext7 === void 0 ? void 0 : (_state$headingContext8 = _state$headingContext7.heading) === null || _state$headingContext8 === void 0 ? void 0 : _state$headingContext8.debug)
111
+ });
112
+ state.level = state.prevLevel = newLevel;
113
+ setState(_objectSpread({}, state));
114
+ }
115
+ }, [props.level]);
116
+ let {
117
+ size,
118
+ element = 'auto',
119
+ skeleton
120
+ } = props;
121
+ const {
122
+ level
123
+ } = state;
124
+ const debug = _debug || (headingContext === null || headingContext === void 0 ? void 0 : (_headingContext$headi2 = headingContext.heading) === null || _headingContext$headi2 === void 0 ? void 0 : _headingContext$headi2.debug);
125
+ const debug_counter = _debug_counter || (headingContext === null || headingContext === void 0 ? void 0 : (_headingContext$headi3 = headingContext.heading) === null || _headingContext$headi3 === void 0 ? void 0 : _headingContext$headi3.debug_counter);
126
+
127
+ const attributes = _objectSpread({}, rest);
128
+
129
+ if (element === 'auto' || element === null) {
130
+ element = `h${level || 'x-small'}`;
131
+
132
+ if (_size === 'auto' || _size === null) {
133
+ size = levelResolution[level || 'x-small'];
134
+ }
135
+ } else {
136
+ if (!attributes.role) {
137
+ attributes.role = 'heading';
138
+ }
154
139
 
155
- if (!attributes['aria-level']) {
156
- attributes['aria-level'] = String(level);
157
- }
140
+ if (!attributes['aria-level']) {
141
+ attributes['aria-level'] = String(level);
158
142
  }
143
+ }
159
144
 
160
- validateDOMAttributes(this.props, attributes);
161
- const Element = element;
162
- return React.createElement(Context.Consumer, null, context => {
163
- if (typeof (context === null || context === void 0 ? void 0 : context.skeleton) !== 'undefined') {
164
- skeleton = context.skeleton;
165
- }
145
+ validateDOMAttributes(props, attributes);
166
146
 
167
- attributes.className = classnames(`dnb-heading dnb-h--${size}`, createSkeletonClass('font', skeleton, this.context), className, _className, createSpacingClasses(this.props));
168
- attributes.children = React.createElement(React.Fragment, null, debug && React.createElement("span", {
169
- className: "dnb-heading__debug"
170
- }, `[h${level || '6'}] `, debug_counter && React.createElement(React.Fragment, null, ' ', React.createElement("span", {
171
- className: "dnb-code"
172
- }, debugCounter(this.state.counter)))), text || children);
173
- return React.createElement(Element, _extends({
174
- ref: this._ref
175
- }, attributes));
176
- });
147
+ if (typeof (context === null || context === void 0 ? void 0 : context.skeleton) !== 'undefined') {
148
+ skeleton = context.skeleton;
177
149
  }
178
150
 
151
+ const Element = element;
152
+ return React.createElement(Element, _extends({}, attributes, {
153
+ ref: _ref,
154
+ className: classnames(`dnb-heading dnb-h--${size}`, createSkeletonClass('font', skeleton, headingContext), className, createSpacingClasses(props))
155
+ }), debug && React.createElement("span", {
156
+ className: "dnb-heading__debug"
157
+ }, `[h${level || '6'}] `, debug_counter && React.createElement(React.Fragment, null, ' ', React.createElement("span", {
158
+ className: "dnb-code"
159
+ }, debugCounter(state.counter)))), text || children);
179
160
  }
180
-
181
- _defineProperty(Heading, "contextType", HeadingContext);
182
-
183
- _defineProperty(Heading, "defaultProps", {
184
- id: null,
185
- group: null,
186
- text: null,
187
- size: 'auto',
188
- level: null,
189
- increase: null,
190
- decrease: null,
191
- up: null,
192
- down: null,
193
- skip_correction: null,
194
- debug: null,
195
- debug_counter: null,
196
- counter: null,
197
- reset: null,
198
- inherit: null,
199
- skeleton: null,
200
- element: 'auto',
201
- class: null,
202
- className: null,
203
- children: null
204
- });
205
-
206
- process.env.NODE_ENV !== "production" ? Heading.propTypes = _objectSpread(_objectSpread({
207
- id: PropTypes.string,
208
- group: PropTypes.string,
209
- text: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
210
- size: PropTypes.oneOf(['auto', 'xx-large', 'x-large', 'large', 'medium', 'basis', 'small', 'x-small']),
211
- level: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
212
- increase: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
213
- decrease: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
214
- up: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
215
- down: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
216
- skip_correction: PropTypes.bool,
217
- debug: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
218
- debug_counter: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
219
- counter: PropTypes.any,
220
- inherit: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
221
- reset: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.bool]),
222
- skeleton: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
223
- element: PropTypes.string
224
- }, spacingPropTypes), {}, {
225
- class: PropTypes.string,
226
- className: PropTypes.string,
227
- children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
228
- }) : void 0;
229
161
  Heading.Level = HeadingProvider;
230
162
 
231
163
  Heading.Increase = props => React.createElement(HeadingProvider, _extends({
@@ -1,5 +1,12 @@
1
- export default Context;
2
- declare const Context: React.Context<{
3
- heading: any;
4
- }>;
5
- import React from "react";
1
+ /**
2
+ * Web Heading Context
3
+ *
4
+ */
5
+ import React from 'react';
6
+ import { SkeletonContextProps } from '../skeleton/SkeletonHelper';
7
+ import { HeadingProps } from './Heading';
8
+ export declare type HeadingContextProps = {
9
+ heading?: HeadingProps;
10
+ } & SkeletonContextProps;
11
+ declare const HeadingContext: React.Context<HeadingContextProps>;
12
+ export default HeadingContext;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- const Context = React.createContext({
2
+ const HeadingContext = React.createContext({
3
3
  heading: null
4
4
  });
5
- export default Context;
5
+ export default HeadingContext;
@@ -1,18 +1,42 @@
1
- export function initCounter(props?: any): any;
2
- export class Counter {
3
- constructor(props?: any);
4
- level: number;
5
- entry: number;
1
+ /**
2
+ * Web Heading Counter Instance
3
+ *
4
+ */
5
+ import { HeadingAllProps, InternalHeadingLevel } from './Heading';
6
+ export declare type HeadingCounter = Counter;
7
+ export declare type HeadingDebugCounter = boolean | (() => void);
8
+ export declare type ContextCounter = {
9
+ level: InternalHeadingLevel;
10
+ entry: InternalHeadingLevel;
11
+ countHeadings: number;
12
+ _initCount: number;
13
+ _isReady: boolean;
14
+ isGlobal?: boolean;
15
+ };
16
+ export declare const initCounter: (props?: CounterProps) => Counter;
17
+ export declare type CounterGroup = HeadingAllProps['group'];
18
+ export declare type CounterChildren = HeadingAllProps['children'];
19
+ export declare type CounterProps = {
20
+ isGlobal?: boolean;
21
+ group?: CounterGroup;
22
+ children?: CounterChildren;
23
+ counter?: CounterProps;
24
+ };
25
+ export declare class Counter {
26
+ level: InternalHeadingLevel;
27
+ entry: InternalHeadingLevel;
28
+ lastResetLevel: InternalHeadingLevel;
6
29
  _isReady: boolean;
7
30
  countHeadings: number;
8
31
  _initCount: number;
9
32
  isGlobal: boolean;
10
33
  isHeading: boolean;
11
34
  bypassChecks: boolean;
12
- contextCounter: any;
35
+ contextCounter: ContextCounter;
13
36
  reports: any[];
14
- group: any;
15
- children: any;
37
+ group: CounterGroup;
38
+ children: CounterChildren;
39
+ constructor(props?: CounterProps);
16
40
  report(...str: any[]): void;
17
41
  useLastReport(): any;
18
42
  enableBypassChecks(): void;
@@ -20,23 +44,23 @@ export class Counter {
20
44
  getLevel(): number;
21
45
  hasEntryLevel(): boolean;
22
46
  hasCorrection(): boolean;
23
- setEntryLevel(level?: any): void;
47
+ setEntryLevel(level?: InternalHeadingLevel): void;
24
48
  isInContext(): boolean;
25
- setContextCounter(contextCounter: any): void;
26
- skipMakeMeReady(): void;
49
+ setContextCounter(contextCounter: ContextCounter): void;
27
50
  windup(): void;
28
51
  teardown(): void;
29
- makeMeReady(): void;
52
+ makeMeReady({ level }?: {
53
+ level?: InternalHeadingLevel;
54
+ }): void;
30
55
  factorCheck({ action, level, current, report }: {
31
56
  action: any;
32
57
  level: any;
33
58
  current: any;
34
59
  report: any;
35
60
  }): any;
36
- setLevel(level: any, action?: string): void;
61
+ setLevel(level: InternalHeadingLevel, action?: string): void;
37
62
  increment(): void;
38
63
  decrement(): void;
39
64
  force(level?: number): void;
40
65
  reset(toLevel?: any): void;
41
- lastResetLevel: any;
42
66
  }
@@ -10,7 +10,11 @@ export const initCounter = function () {
10
10
  });
11
11
  }
12
12
 
13
- return props && props.counter || new Counter(props);
13
+ if (props !== null && props !== void 0 && props.counter) {
14
+ return props.counter;
15
+ }
16
+
17
+ return new Counter(props);
14
18
  };
15
19
  export class Counter {
16
20
  constructor() {
@@ -20,6 +24,8 @@ export class Counter {
20
24
 
21
25
  _defineProperty(this, "entry", 0);
22
26
 
27
+ _defineProperty(this, "lastResetLevel", null);
28
+
23
29
  _defineProperty(this, "_isReady", false);
24
30
 
25
31
  _defineProperty(this, "countHeadings", 0);
@@ -36,6 +42,10 @@ export class Counter {
36
42
 
37
43
  _defineProperty(this, "reports", []);
38
44
 
45
+ _defineProperty(this, "group", null);
46
+
47
+ _defineProperty(this, "children", null);
48
+
39
49
  props = props || {};
40
50
 
41
51
  if (props.group) {
@@ -85,7 +95,7 @@ export class Counter {
85
95
 
86
96
  setEntryLevel() {
87
97
  let level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
88
- this.entry = parseFloat(level) || 1;
98
+ this.entry = parseFloat(String(level)) || 1;
89
99
  }
90
100
 
91
101
  isInContext() {
@@ -96,13 +106,6 @@ export class Counter {
96
106
  this.contextCounter = contextCounter;
97
107
  }
98
108
 
99
- skipMakeMeReady() {
100
- this._isReady = true;
101
- this.entry = 1;
102
- this.level = 1;
103
- this.contextCounter.entry = 2;
104
- }
105
-
106
109
  windup() {
107
110
  this.contextCounter.countHeadings++;
108
111
  }
@@ -117,6 +120,10 @@ export class Counter {
117
120
  }
118
121
 
119
122
  makeMeReady() {
123
+ let {
124
+ level
125
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
126
+
120
127
  if (!this.hasCorrection()) {
121
128
  if (this.contextCounter.level > 1) {
122
129
  this.level = this.contextCounter.level;
@@ -127,7 +134,7 @@ export class Counter {
127
134
  } else if (!this.contextCounter._isReady) {
128
135
  this.contextCounter._isReady = true;
129
136
 
130
- if (!this.bypassChecks) {
137
+ if (!this.bypassChecks && !level) {
131
138
  this.level = 1;
132
139
  }
133
140
  }
@@ -179,19 +186,15 @@ export class Counter {
179
186
  var _globalSyncCounter$cu;
180
187
 
181
188
  let action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'set';
182
- level = parseFloat(level);
189
+ level = parseFloat(String(level));
183
190
  const report = [];
184
191
 
185
- if (!this._isReady && this.level === 1 && (!globalSyncCounter.current || globalSyncCounter.current.level < 2)) {
186
- return;
187
- }
188
-
189
192
  if (((_globalSyncCounter$cu = globalSyncCounter.current) === null || _globalSyncCounter$cu === void 0 ? void 0 : _globalSyncCounter$cu.level) > 0) {
190
193
  level = this.factorCheck({
191
- report,
192
194
  action,
193
195
  level,
194
- current: globalSyncCounter.current.level
196
+ current: globalSyncCounter.current.level,
197
+ report
195
198
  });
196
199
  }
197
200
 
@@ -1,27 +1,49 @@
1
- export function resetAllLevels(): void;
2
- export function resetLevels(level: any, { overwriteContext }?: {
1
+ /**
2
+ * Web Heading Counter
3
+ *
4
+ */
5
+ import { HeadingAllProps, InternalHeadingLevel } from './Heading';
6
+ import { HeadingCounter } from './HeadingCounter';
7
+ declare type GlobalSyncCounter = {
8
+ current: HeadingCounter;
9
+ };
10
+ declare type GlobalHeadingCounter = {
11
+ current: HeadingCounter;
12
+ };
13
+ export declare const globalSyncCounter: GlobalSyncCounter;
14
+ export declare const globalHeadingCounter: GlobalHeadingCounter;
15
+ declare type CorrectInternalHeadingLevel = {
16
+ counter: HeadingCounter;
17
+ level: InternalHeadingLevel;
18
+ ref?: HeadingAllProps;
19
+ reset?: HeadingAllProps['reset'];
20
+ inherit?: boolean;
21
+ increase?: boolean;
22
+ decrease?: boolean;
23
+ source?: HeadingAllProps['children'];
24
+ bypassChecks?: boolean;
25
+ isRerender?: boolean;
26
+ debug?: HeadingAllProps['debug'];
27
+ };
28
+ export declare const correctInternalHeadingLevel: ({ counter, level, ref, reset, inherit, increase, decrease, source, bypassChecks, isRerender, debug, }: CorrectInternalHeadingLevel) => import("./HeadingCounter").Counter;
29
+ export declare function resetAllLevels(): void;
30
+ export declare const globalResetNextTime: {
31
+ current: GlobalNextLevel;
32
+ };
33
+ export declare function resetLevels(level: InternalHeadingLevel, { overwriteContext }?: {
3
34
  overwriteContext?: boolean;
4
35
  }): void;
5
- export function setNextLevel(level: any, { overwriteContext }?: {
36
+ declare type GlobalNextLevel = {
37
+ level: InternalHeadingLevel;
38
+ overwriteContext: boolean;
39
+ };
40
+ export declare const globalNextLevel: {
41
+ current: GlobalNextLevel;
42
+ };
43
+ export declare function setNextLevel(level: InternalHeadingLevel, { overwriteContext }?: {
6
44
  overwriteContext?: boolean;
7
45
  }): void;
8
- export function windupHeadings(): void;
9
- export function teardownHeadings(): void;
10
- export function debugCounter(counter: any): string;
11
- export const globalSyncCounter: React.RefObject<any>;
12
- export const globalHeadingCounter: React.RefObject<any>;
13
- export function correctHeadingLevel({ counter, level, ref, reset, inherit, increase, decrease, source, bypassChecks, debug, }: {
14
- counter: any;
15
- level: any;
16
- ref?: any;
17
- reset?: any;
18
- inherit?: any;
19
- increase?: boolean;
20
- decrease?: boolean;
21
- source?: any;
22
- bypassChecks?: boolean;
23
- debug?: any;
24
- }): any;
25
- export const globalResetNextTime: React.RefObject<any>;
26
- export const globalNextLevel: React.RefObject<any>;
27
- import React from "react";
46
+ export declare function windupHeadings(): void;
47
+ export declare function teardownHeadings(): void;
48
+ export declare function debugCounter(counter: any): string;
49
+ export {};