@instructure/ui-pages 8.12.1-snapshot.7 → 8.13.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.
@@ -28,15 +28,18 @@ import PropTypes from 'prop-types'
28
28
  import { findDOMNode, findTabbable } from '@instructure/ui-dom-utils'
29
29
  import { logError as error } from '@instructure/console'
30
30
  import { View } from '@instructure/ui-view'
31
- import { PagesContext } from '..'
32
- import type { PagesPageProps } from './props'
31
+
32
+ import { PagesContext } from '../PagesContext'
33
+
33
34
  import { allowedProps, propTypes } from './props'
35
+ import type { PagesPageProps } from './props'
34
36
 
35
37
  /**
36
38
  ---
37
39
  parent: Pages
38
40
  id: Pages.Page
39
41
  ---
42
+ @tsProps
40
43
  **/
41
44
  class Page extends Component<PagesPageProps> {
42
45
  static readonly componentId = 'Pages.Page'
@@ -76,18 +79,16 @@ class Page extends Component<PagesPageProps> {
76
79
  }
77
80
 
78
81
  if (defaultFocusElement) {
79
- defaultFocusElement = findDOMNode(defaultFocusElement) as any
82
+ defaultFocusElement = findDOMNode(defaultFocusElement)
80
83
  }
81
84
 
82
85
  if (!defaultFocusElement) {
83
86
  const tabbable = findTabbable(this.ref)
84
- // @ts-expect-error ts-migrate(2554) FIXME:
85
87
  defaultFocusElement = tabbable && tabbable[0]
86
88
  }
87
89
 
88
90
  error(
89
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'focus' does not exist on type 'ReactElem... Remove this comment to see the full error message
90
- defaultFocusElement && defaultFocusElement.focus,
91
+ defaultFocusElement && !!(defaultFocusElement as HTMLElement).focus,
91
92
  '[Page] A default focusable element is required or focus will be lost.'
92
93
  )
93
94
 
@@ -97,14 +98,12 @@ class Page extends Component<PagesPageProps> {
97
98
  get focusable() {
98
99
  const element = this.defaultFocusElement
99
100
 
100
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'focus' does not exist on type 'ReactElem... Remove this comment to see the full error message
101
- return element && typeof element.focus === 'function'
101
+ return !!element && typeof (element as HTMLElement).focus === 'function'
102
102
  }
103
103
 
104
104
  focus() {
105
105
  if (this.focusable) {
106
- // @ts-expect-error ts-migrate(2532) FIXME: Object is possibly 'undefined'.
107
- this.defaultFocusElement.focus()
106
+ ;(this.defaultFocusElement as HTMLElement).focus()
108
107
  }
109
108
  }
110
109
 
@@ -28,13 +28,32 @@ import PropTypes from 'prop-types'
28
28
  import { ThemeablePropTypes } from '@instructure/emotion'
29
29
 
30
30
  import type { Spacing } from '@instructure/emotion'
31
- import type { PropValidators } from '@instructure/shared-types'
31
+ import type { PropValidators, UIElement } from '@instructure/shared-types'
32
+
33
+ import type { PagesContextType } from '../PagesContext'
32
34
 
33
35
  type PagesPageOwnProps = {
34
- defaultFocusElement?: React.ReactElement | ((...args: any[]) => any)
36
+ /**
37
+ * The children to be rendered
38
+ */
39
+ children?:
40
+ | React.ReactNode
41
+ | ((
42
+ history: PagesContextType['history'],
43
+ navigateToPreviousPage: PagesContextType['navigateToPreviousPage']
44
+ ) => React.ReactNode)
45
+
46
+ /**
47
+ * An element or a function returning an element to focus by default
48
+ */
49
+ defaultFocusElement?: UIElement | (() => UIElement)
50
+
51
+ /**
52
+ * Set the padding using familiar CSS shorthand
53
+ */
35
54
  padding?: Spacing
55
+
36
56
  textAlign?: 'start' | 'center' | 'end'
37
- children?: React.ReactNode | ((...args: any[]) => React.ReactNode)
38
57
  }
39
58
  type PropKeys = keyof PagesPageOwnProps
40
59
 
@@ -43,21 +62,9 @@ type AllowedPropKeys = Readonly<Array<PropKeys>>
43
62
  type PagesPageProps = PagesPageOwnProps
44
63
 
45
64
  const propTypes: PropValidators<PropKeys> = {
46
- /**
47
- * The children to be rendered
48
- */
49
65
  children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
50
-
51
- /**
52
- * An element or a function returning an element to focus by default
53
- */
54
66
  defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
55
-
56
- /**
57
- * Set the padding using familiar CSS shorthand
58
- */
59
67
  padding: ThemeablePropTypes.spacing,
60
-
61
68
  textAlign: PropTypes.oneOf(['start', 'center', 'end'])
62
69
  }
63
70
 
@@ -0,0 +1,39 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { createContext } from 'react'
26
+
27
+ type PagesContextType = {
28
+ history: (number | undefined)[]
29
+ navigateToPreviousPage: () => void
30
+ }
31
+
32
+ const PagesContext = createContext<PagesContextType>({
33
+ history: [],
34
+ navigateToPreviousPage: () => {}
35
+ })
36
+
37
+ export default PagesContext
38
+ export { PagesContext }
39
+ export type { PagesContextType }
@@ -2,6 +2,8 @@
2
2
  describes: Pages
3
3
  ---
4
4
 
5
+ The Pages component can be used to render Paginated content that does not fit into one page. Each page content should have at least one focusable element (e.g. the back button) otherwise the focus will be lost.
6
+
5
7
  ```js
6
8
  ---
7
9
  render: false
@@ -42,10 +44,9 @@ class Example extends React.Component {
42
44
 
43
45
  render () {
44
46
  return (
45
- <Pages
47
+ <Pages
46
48
  activePageIndex={this.state.activePageIndex}
47
49
  onPageIndexChange={this.handlePagesBackButtonClick}
48
- backButtonLabel="Back to previous page"
49
50
  >
50
51
  <Pages.Page>
51
52
  {(history, navigateToPreviousPage) => {
@@ -90,7 +91,6 @@ class Example extends React.Component {
90
91
  render(<Example />)
91
92
  ```
92
93
 
93
-
94
94
  ```js
95
95
  ---
96
96
  render: false
@@ -134,7 +134,6 @@ class Example extends React.Component {
134
134
  <Pages
135
135
  activePageIndex={this.state.activePageIndex}
136
136
  onPageIndexChange={this.handlePagesBackButtonClick}
137
- backButtonLabel="Back to previous page"
138
137
  >
139
138
  <Pages.Page>
140
139
  {(history, navigateToPreviousPage) => {
@@ -181,7 +180,6 @@ class Example extends React.Component {
181
180
  render(<Example />)
182
181
  ```
183
182
 
184
-
185
183
  ```js
186
184
  ---
187
185
  render: false
@@ -353,7 +351,6 @@ class Example extends React.Component {
353
351
  <Pages
354
352
  activePageIndex={this.state.activePageIndex}
355
353
  onPageIndexChange={this.handlePagesBackButtonClick}
356
- backButtonLabel="Back to previous page"
357
354
  >
358
355
  <Pages.Page
359
356
  defaultFocusElement={() => this._usersNav[this.state.lastPageIndex]}
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  /** @jsx jsx */
26
- import React, { Component, createContext, ReactElement } from 'react'
26
+ import React, { Component, ReactElement } from 'react'
27
27
 
28
28
  import { View } from '@instructure/ui-view'
29
29
  import { containsActiveElement, findTabbable } from '@instructure/ui-dom-utils'
@@ -36,18 +36,18 @@ import { Page } from './Page'
36
36
  import { withStyle, jsx } from '@instructure/emotion'
37
37
  import generateStyle from './styles'
38
38
  import generateComponentTheme from './theme'
39
- import type { PagesProps } from './props'
40
- import { allowedProps, propTypes } from './props'
41
39
 
42
- export const PagesContext = createContext({
43
- history: [],
44
- navigateToPreviousPage: () => {}
45
- })
40
+ import { PagesContext } from './PagesContext'
41
+ import type { PagesContextType } from './PagesContext'
42
+
43
+ import { allowedProps, propTypes } from './props'
44
+ import type { PagesProps } from './props'
46
45
 
47
46
  /**
48
47
  ---
49
48
  category: components
50
49
  ---
50
+ @tsProps
51
51
  **/
52
52
  @withStyle(generateStyle, generateComponentTheme)
53
53
  class Pages extends Component<PagesProps> {
@@ -57,15 +57,22 @@ class Pages extends Component<PagesProps> {
57
57
  static propTypes = propTypes
58
58
 
59
59
  static defaultProps = {
60
- children: null,
61
- defaultPageIndex: null,
62
- activePageIndex: 0,
63
- onPageIndexChange: function () {}
60
+ activePageIndex: 0
64
61
  }
65
62
 
66
63
  static Page = Page
67
64
 
68
- _timeouts = []
65
+ _timeouts: ReturnType<typeof setTimeout>[] = []
66
+ _history: PagesContextType['history']
67
+ _activePage: Page | null = null
68
+ _contentId: string
69
+
70
+ ref: Element | null = null
71
+
72
+ handleRef = (el: Element | null) => {
73
+ this.ref = el
74
+ }
75
+
69
76
  get _contentElement() {
70
77
  console.warn(
71
78
  '_contentElement property is deprecated and will be removed in v9, please use ref instead'
@@ -73,24 +80,16 @@ class Pages extends Component<PagesProps> {
73
80
 
74
81
  return this.ref
75
82
  }
76
- ref: Element | null = null
77
83
 
78
- handleRef = (el: Element | null) => {
79
- this.ref = el
80
- }
81
-
82
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
83
- constructor(props) {
84
+ constructor(props: PagesProps) {
84
85
  super(props)
85
86
 
86
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
87
87
  this._history = [
88
88
  typeof props.defaultPageIndex === 'number'
89
89
  ? props.defaultPageIndex
90
- : props.activePageIndex
90
+ : props.activePageIndex!
91
91
  ]
92
92
 
93
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_contentId' does not exist on type 'Page... Remove this comment to see the full error message
94
93
  this._contentId = uid('Pages')
95
94
  }
96
95
 
@@ -99,32 +98,26 @@ class Pages extends Component<PagesProps> {
99
98
  }
100
99
 
101
100
  handleBackButtonClick = () => {
102
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
103
101
  const oldPageIndex = this._history.pop()
104
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
105
102
  const newPageIndex = this._history[this._history.length - 1]
106
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
107
- this.props.onPageIndexChange(newPageIndex || 0, oldPageIndex)
103
+
104
+ this.props.onPageIndexChange?.(newPageIndex || 0, oldPageIndex)
108
105
  }
109
106
 
110
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'nextProps' implicitly has an 'any' type... Remove this comment to see the full error message
111
- componentWillReceiveProps(nextProps, nextContext) {
107
+ // TODO: componentWillReceiveProps has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.
108
+ componentWillReceiveProps(nextProps: PagesProps) {
112
109
  if (
113
110
  nextProps &&
114
111
  typeof nextProps.activePageIndex === 'number' &&
115
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
116
112
  (this._history.length === 0 ||
117
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
118
113
  nextProps.activePageIndex !== this._history[this._history.length - 1])
119
114
  ) {
120
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
121
115
  this._history.push(nextProps.activePageIndex)
122
116
  }
123
117
  }
124
118
 
125
119
  componentDidUpdate() {
126
120
  this._timeouts.push(
127
- // @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Timeout' is not assignable to pa... Remove this comment to see the full error message
128
121
  setTimeout(() => {
129
122
  !this.focused && this.focus()
130
123
  }, 0)
@@ -142,9 +135,7 @@ class Pages extends Component<PagesProps> {
142
135
 
143
136
  focus() {
144
137
  this._timeouts.push(
145
- // @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Timeout' is not assignable to pa... Remove this comment to see the full error message
146
138
  setTimeout(() => {
147
- // @ts-expect-error ts-migrate(2551) FIXME: Property '_activePage' does not exist on type 'Pag... Remove this comment to see the full error message
148
139
  const activePage = this._activePage
149
140
 
150
141
  // Attempt to focus active page
@@ -155,8 +146,7 @@ class Pages extends Component<PagesProps> {
155
146
  const tabbable = findTabbable(this.ref)
156
147
  const element = tabbable && tabbable[0]
157
148
 
158
- // @ts-expect-error ts-migrate(2554) FIXME:
159
- element && element.focus()
149
+ element && (element as HTMLElement).focus()
160
150
  }
161
151
  })
162
152
  )
@@ -166,16 +156,13 @@ class Pages extends Component<PagesProps> {
166
156
  const { activePageIndex, children } = this.props
167
157
  const pages = React.Children.toArray(children)
168
158
  const activePage =
169
- activePageIndex < pages.length ? pages[activePageIndex] : null
159
+ activePageIndex! < pages.length ? pages[activePageIndex!] : null
170
160
 
171
- // @ts-expect-error ts-migrate(2555) FIXME
172
- error(activePage, '[Pages] Invalid `activePageIndex`.')
161
+ error(!!activePage, '[Pages] Invalid `activePageIndex`.')
173
162
 
174
163
  return activePage
175
164
  ? safeCloneElement(activePage as ReactElement, {
176
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'el' implicitly has an 'any' type.
177
- ref: (el) => {
178
- // @ts-expect-error ts-migrate(2551) FIXME: Property '_activePage' does not exist on type 'Pag... Remove this comment to see the full error message
165
+ ref: (el: Page | null) => {
179
166
  this._activePage = el
180
167
  }
181
168
  })
@@ -183,10 +170,11 @@ class Pages extends Component<PagesProps> {
183
170
  }
184
171
 
185
172
  render() {
186
- return this.activePage ? (
173
+ const { activePage } = this
174
+
175
+ return activePage ? (
187
176
  <PagesContext.Provider
188
177
  value={{
189
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_history' does not exist on type 'Pages'... Remove this comment to see the full error message
190
178
  history: this._history,
191
179
  navigateToPreviousPage: () => {
192
180
  this.handleBackButtonClick()
@@ -195,14 +183,13 @@ class Pages extends Component<PagesProps> {
195
183
  >
196
184
  <View
197
185
  as="div"
198
- // @ts-expect-error ts-migrate(2322) FIXME: Type '{ children: any; as: string; id: any; css: a... Remove this comment to see the full error message
199
186
  id={this._contentId}
200
187
  css={this.props.styles?.pages}
201
188
  margin={this.props.margin}
202
189
  role="region"
203
190
  elementRef={this.handleRef}
204
191
  >
205
- {this.activePage}
192
+ {activePage}
206
193
  </View>
207
194
  </PagesContext.Provider>
208
195
  ) : null
@@ -37,11 +37,29 @@ import type {
37
37
  import type { PropValidators, PagesTheme } from '@instructure/shared-types'
38
38
 
39
39
  type PagesOwnProps = {
40
+ /**
41
+ * Children are type of `<Pages.Page>`
42
+ */
43
+ children?: React.ReactNode // TODO: oneOf([Page])
44
+
40
45
  defaultPageIndex?: number
41
- activePageIndex?: any // TODO: controllable( PropTypes.number, 'onPageIndexChange', 'defaultPageIndex' )
42
- onPageIndexChange?: (...args: any[]) => any
46
+
47
+ /**
48
+ * The currently active page index
49
+ */
50
+ activePageIndex?: number // TODO: controllable( PropTypes.number, 'onPageIndexChange', 'defaultPageIndex' )
51
+
52
+ /**
53
+ * Event handler fired anytime page index has changed due to back button being clicked
54
+ */
55
+ onPageIndexChange?: (newPageIndex: number, oldPageIndex?: number) => void
56
+
57
+ /**
58
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
59
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
60
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
61
+ */
43
62
  margin?: Spacing
44
- children?: React.ReactNode // TODO: oneOf([Page])
45
63
  }
46
64
 
47
65
  type PropKeys = keyof PagesOwnProps
@@ -54,28 +72,13 @@ type PagesStyle = ComponentStyle<'pages'>
54
72
 
55
73
  const propTypes: PropValidators<PropKeys> = {
56
74
  children: Children.oneOf([Page]),
57
-
58
75
  defaultPageIndex: PropTypes.number,
59
-
60
- /**
61
- * The currently active page index
62
- */
63
76
  activePageIndex: controllable(
64
77
  PropTypes.number,
65
78
  'onPageIndexChange',
66
79
  'defaultPageIndex'
67
80
  ),
68
-
69
- /**
70
- * Event handler fired anytime page index has changed due to back button being clicked
71
- */
72
81
  onPageIndexChange: PropTypes.func,
73
-
74
- /**
75
- * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
76
- * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
77
- * familiar CSS-like shorthand. For example: `margin="small auto large"`.
78
- */
79
82
  margin: ThemeablePropTypes.spacing
80
83
  }
81
84
 
@@ -6,20 +6,21 @@ import type { PagesPageProps } from './props';
6
6
  parent: Pages
7
7
  id: Pages.Page
8
8
  ---
9
+ @tsProps
9
10
  **/
10
11
  declare class Page extends Component<PagesPageProps> {
11
12
  static readonly componentId = "Pages.Page";
12
13
  static allowedProps: readonly (keyof {
13
- defaultFocusElement?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
14
+ children?: React.ReactNode | ((history: (number | undefined)[], navigateToPreviousPage: () => void) => React.ReactNode);
15
+ defaultFocusElement?: import("@instructure/shared-types").UIElement | (() => import("@instructure/shared-types").UIElement) | undefined;
14
16
  padding?: import("@instructure/emotion/types/styleUtils/ThemeablePropValues").Spacing | undefined;
15
17
  textAlign?: "start" | "center" | "end" | undefined;
16
- children?: React.ReactNode | ((...args: any[]) => React.ReactNode);
17
18
  })[];
18
19
  static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
19
- defaultFocusElement?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
20
+ children?: React.ReactNode | ((history: (number | undefined)[], navigateToPreviousPage: () => void) => React.ReactNode);
21
+ defaultFocusElement?: import("@instructure/shared-types").UIElement | (() => import("@instructure/shared-types").UIElement) | undefined;
20
22
  padding?: import("@instructure/emotion/types/styleUtils/ThemeablePropValues").Spacing | undefined;
21
23
  textAlign?: "start" | "center" | "end" | undefined;
22
- children?: React.ReactNode | ((...args: any[]) => React.ReactNode);
23
24
  }>;
24
25
  static defaultProps: {
25
26
  defaultFocusElement: null;
@@ -34,8 +35,8 @@ declare class Page extends Component<PagesPageProps> {
34
35
  get _content(): Element | null;
35
36
  ref: Element | null;
36
37
  handleRef: (el: Element | null) => void;
37
- get defaultFocusElement(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
38
- get focusable(): boolean | undefined;
38
+ get defaultFocusElement(): Node | Window;
39
+ get focusable(): boolean;
39
40
  focus(): void;
40
41
  render(): JSX.Element;
41
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Pages/Page/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,SAAS,MAAM,YAAY,CAAA;AAMlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C;;;;;GAKG;AACH,cAAM,IAAK,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC1C,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAe;IAE1C,MAAM,CAAC,YAAY;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;MAKlB;IAED,MAAM,CAAC,YAAY;;;MAGlB;IAED,IAAI,QAAQ,mBAIX;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAE9B;IAED,IAAI,mBAAmB,+GAwBtB;IAED,IAAI,SAAS,wBAKZ;IAED,KAAK;IAOL,MAAM;CAoBP;AAED,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Pages/Page/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,SAAS,MAAM,YAAY,CAAA;AASlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;;GAMG;AACH,cAAM,IAAK,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC1C,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAe;IAE1C,MAAM,CAAC,YAAY;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;MAKlB;IAED,MAAM,CAAC,YAAY;;;MAGlB;IAED,IAAI,QAAQ,mBAIX;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAE9B;IAED,IAAI,mBAAmB,kBAsBtB;IAED,IAAI,SAAS,YAIZ;IAED,KAAK;IAML,MAAM;CAoBP;AAED,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,11 +1,21 @@
1
1
  import React from 'react';
2
2
  import type { Spacing } from '@instructure/emotion';
3
- import type { PropValidators } from '@instructure/shared-types';
3
+ import type { PropValidators, UIElement } from '@instructure/shared-types';
4
+ import type { PagesContextType } from '../PagesContext';
4
5
  declare type PagesPageOwnProps = {
5
- defaultFocusElement?: React.ReactElement | ((...args: any[]) => any);
6
+ /**
7
+ * The children to be rendered
8
+ */
9
+ children?: React.ReactNode | ((history: PagesContextType['history'], navigateToPreviousPage: PagesContextType['navigateToPreviousPage']) => React.ReactNode);
10
+ /**
11
+ * An element or a function returning an element to focus by default
12
+ */
13
+ defaultFocusElement?: UIElement | (() => UIElement);
14
+ /**
15
+ * Set the padding using familiar CSS shorthand
16
+ */
6
17
  padding?: Spacing;
7
18
  textAlign?: 'start' | 'center' | 'end';
8
- children?: React.ReactNode | ((...args: any[]) => React.ReactNode);
9
19
  };
10
20
  declare type PropKeys = keyof PagesPageOwnProps;
11
21
  declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
@@ -1 +1 @@
1
- {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/Pages/Page/props.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,aAAK,iBAAiB,GAAG;IACvB,mBAAmB,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IACpE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAA;CACnE,CAAA;AACD,aAAK,QAAQ,GAAG,MAAM,iBAAiB,CAAA;AAEvC,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,cAAc,GAAG,iBAAiB,CAAA;AAEvC,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAiBvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAKnB,CAAA;AAED,YAAY,EAAE,cAAc,EAAE,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/Pages/Page/props.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,aAAK,iBAAiB,GAAG;IACvB;;OAEG;IACH,QAAQ,CAAC,EACL,KAAK,CAAC,SAAS,GACf,CAAC,CACC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,sBAAsB,EAAE,gBAAgB,CAAC,wBAAwB,CAAC,KAC/D,KAAK,CAAC,SAAS,CAAC,CAAA;IAEzB;;OAEG;IACH,mBAAmB,CAAC,EAAE,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAA;IAEnD;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;CACvC,CAAA;AACD,aAAK,QAAQ,GAAG,MAAM,iBAAiB,CAAA;AAEvC,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,cAAc,GAAG,iBAAiB,CAAA;AAEvC,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAKvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAKnB,CAAA;AAED,YAAY,EAAE,cAAc,EAAE,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ declare type PagesContextType = {
3
+ history: (number | undefined)[];
4
+ navigateToPreviousPage: () => void;
5
+ };
6
+ declare const PagesContext: import("react").Context<PagesContextType>;
7
+ export default PagesContext;
8
+ export { PagesContext };
9
+ export type { PagesContextType };
10
+ //# sourceMappingURL=PagesContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PagesContext.d.ts","sourceRoot":"","sources":["../../src/Pages/PagesContext.ts"],"names":[],"mappings":";AA0BA,aAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAA;IAC/B,sBAAsB,EAAE,MAAM,IAAI,CAAA;CACnC,CAAA;AAED,QAAA,MAAM,YAAY,2CAGhB,CAAA;AAEF,eAAe,YAAY,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
@@ -2,47 +2,45 @@
2
2
  import React, { Component } from 'react';
3
3
  import { Page } from './Page';
4
4
  import { jsx } from '@instructure/emotion';
5
+ import type { PagesContextType } from './PagesContext';
5
6
  import type { PagesProps } from './props';
6
- export declare const PagesContext: React.Context<{
7
- history: never[];
8
- navigateToPreviousPage: () => void;
9
- }>;
10
7
  /**
11
8
  ---
12
9
  category: components
13
10
  ---
11
+ @tsProps
14
12
  **/
15
13
  declare class Pages extends Component<PagesProps> {
16
14
  static readonly componentId = "Pages";
17
15
  static allowedProps: readonly (keyof {
16
+ children?: React.ReactNode;
18
17
  defaultPageIndex?: number | undefined;
19
- activePageIndex?: any;
20
- onPageIndexChange?: ((...args: any[]) => any) | undefined;
18
+ activePageIndex?: number | undefined;
19
+ onPageIndexChange?: ((newPageIndex: number, oldPageIndex?: number | undefined) => void) | undefined;
21
20
  margin?: import("@instructure/emotion/types/styleUtils/ThemeablePropValues").Spacing | undefined;
22
- children?: React.ReactNode;
23
21
  })[];
24
22
  static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
23
+ children?: React.ReactNode;
25
24
  defaultPageIndex?: number | undefined;
26
- activePageIndex?: any;
27
- onPageIndexChange?: ((...args: any[]) => any) | undefined;
25
+ activePageIndex?: number | undefined;
26
+ onPageIndexChange?: ((newPageIndex: number, oldPageIndex?: number | undefined) => void) | undefined;
28
27
  margin?: import("@instructure/emotion/types/styleUtils/ThemeablePropValues").Spacing | undefined;
29
- children?: React.ReactNode;
30
28
  }>;
31
29
  static defaultProps: {
32
- children: null;
33
- defaultPageIndex: null;
34
30
  activePageIndex: number;
35
- onPageIndexChange: () => void;
36
31
  };
37
32
  static Page: typeof Page;
38
- _timeouts: never[];
39
- get _contentElement(): Element | null;
33
+ _timeouts: ReturnType<typeof setTimeout>[];
34
+ _history: PagesContextType['history'];
35
+ _activePage: Page | null;
36
+ _contentId: string;
40
37
  ref: Element | null;
41
38
  handleRef: (el: Element | null) => void;
42
- constructor(props: any);
39
+ get _contentElement(): Element | null;
40
+ constructor(props: PagesProps);
43
41
  componentDidMount(): void;
44
42
  handleBackButtonClick: () => void;
45
- componentWillReceiveProps(nextProps: any, nextContext: any): void;
43
+ componentWillReceiveProps(nextProps: PagesProps): void;
46
44
  componentDidUpdate(): void;
47
45
  componentWillUnmount(): void;
48
46
  get focused(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Pages/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,KAAK,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAA;AAQrE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGzC,eAAO,MAAM,YAAY;;;EAGvB,CAAA;AAEF;;;;GAIG;AACH,cACM,KAAM,SAAQ,SAAS,CAAC,UAAU,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,WAAW,WAAU;IAErC,MAAM,CAAC,YAAY;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;;;;MAKlB;IAED,MAAM,CAAC,IAAI,cAAO;IAElB,SAAS,UAAK;IACd,IAAI,eAAe,mBAMlB;IACD,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAE9B;gBAGW,KAAK,KAAA;IAcjB,iBAAiB;IAIjB,qBAAqB,aAOpB;IAGD,yBAAyB,CAAC,SAAS,KAAA,EAAE,WAAW,KAAA;IAchD,kBAAkB;IAUlB,oBAAoB;IAIpB,IAAI,OAAO,YAEV;IAED,KAAK;IAsBL,IAAI,UAAU,8EAkBb;IAED,MAAM;CAyBP;AAED,eAAe,KAAK,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Pages/index.tsx"],"names":[],"mappings":"AAwBA,eAAe;AACf,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAA;AAQtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAa,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAKrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;;GAKG;AACH,cACM,KAAM,SAAQ,SAAS,CAAC,UAAU,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,WAAW,WAAU;IAErC,MAAM,CAAC,YAAY;;;;;;SAAe;IAClC,MAAM,CAAC,SAAS;;;;;;OAAY;IAE5B,MAAM,CAAC,YAAY;;MAElB;IAED,MAAM,CAAC,IAAI,cAAO;IAElB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,EAAE,CAAK;IAC/C,QAAQ,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IACrC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAO;IAC/B,UAAU,EAAE,MAAM,CAAA;IAElB,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,SAAS,OAAQ,OAAO,GAAG,IAAI,UAE9B;IAED,IAAI,eAAe,mBAMlB;gBAEW,KAAK,EAAE,UAAU;IAY7B,iBAAiB;IAIjB,qBAAqB,aAKpB;IAGD,yBAAyB,CAAC,SAAS,EAAE,UAAU;IAW/C,kBAAkB;IASlB,oBAAoB;IAIpB,IAAI,OAAO,YAEV;IAED,KAAK;IAmBL,IAAI,UAAU,8EAeb;IAED,MAAM;CAyBP;AAED,eAAe,KAAK,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA"}
@@ -2,11 +2,25 @@ import React from 'react';
2
2
  import type { Spacing, WithStyleProps, ComponentStyle } from '@instructure/emotion';
3
3
  import type { PropValidators, PagesTheme } from '@instructure/shared-types';
4
4
  declare type PagesOwnProps = {
5
+ /**
6
+ * Children are type of `<Pages.Page>`
7
+ */
8
+ children?: React.ReactNode;
5
9
  defaultPageIndex?: number;
6
- activePageIndex?: any;
7
- onPageIndexChange?: (...args: any[]) => any;
10
+ /**
11
+ * The currently active page index
12
+ */
13
+ activePageIndex?: number;
14
+ /**
15
+ * Event handler fired anytime page index has changed due to back button being clicked
16
+ */
17
+ onPageIndexChange?: (newPageIndex: number, oldPageIndex?: number) => void;
18
+ /**
19
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
20
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
21
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
22
+ */
8
23
  margin?: Spacing;
9
- children?: React.ReactNode;
10
24
  };
11
25
  declare type PropKeys = keyof PagesOwnProps;
12
26
  declare type AllowedPropKeys = Readonly<Array<PropKeys>>;