@instructure/platform-modules 0.1.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 (81) hide show
  1. package/README.md +75 -0
  2. package/dist/adapters/canvasGraphql/index.d.ts +54 -0
  3. package/dist/adapters/canvasGraphql/index.d.ts.map +1 -0
  4. package/dist/adapters/canvasGraphql/normalize.d.ts +345 -0
  5. package/dist/adapters/canvasGraphql/normalize.d.ts.map +1 -0
  6. package/dist/adapters/canvasGraphql/queries.d.ts +69 -0
  7. package/dist/adapters/canvasGraphql/queries.d.ts.map +1 -0
  8. package/dist/adapters/inMemory.d.ts +63 -0
  9. package/dist/adapters/inMemory.d.ts.map +1 -0
  10. package/dist/adapters/index.d.ts +3 -0
  11. package/dist/adapters/index.d.ts.map +1 -0
  12. package/dist/adapters/limits.d.ts +86 -0
  13. package/dist/adapters/limits.d.ts.map +1 -0
  14. package/dist/adapters/types.d.ts +87 -0
  15. package/dist/adapters/types.d.ts.map +1 -0
  16. package/dist/cache/index.d.ts +3 -0
  17. package/dist/cache/index.d.ts.map +1 -0
  18. package/dist/cache/invalidate.d.ts +52 -0
  19. package/dist/cache/invalidate.d.ts.map +1 -0
  20. package/dist/cache/keys.d.ts +86 -0
  21. package/dist/cache/keys.d.ts.map +1 -0
  22. package/dist/components/FilterChips.d.ts +19 -0
  23. package/dist/components/FilterChips.d.ts.map +1 -0
  24. package/dist/components/ModuleCard.d.ts +32 -0
  25. package/dist/components/ModuleCard.d.ts.map +1 -0
  26. package/dist/components/ModuleItemRow.d.ts +17 -0
  27. package/dist/components/ModuleItemRow.d.ts.map +1 -0
  28. package/dist/components/ModulesList.d.ts +69 -0
  29. package/dist/components/ModulesList.d.ts.map +1 -0
  30. package/dist/components/ModulesList.stories.d.ts +138 -0
  31. package/dist/components/ModulesList.stories.d.ts.map +1 -0
  32. package/dist/components/StatusPill.d.ts +18 -0
  33. package/dist/components/StatusPill.d.ts.map +1 -0
  34. package/dist/components/index.d.ts +7 -0
  35. package/dist/components/index.d.ts.map +1 -0
  36. package/dist/components/labels.d.ts +89 -0
  37. package/dist/components/labels.d.ts.map +1 -0
  38. package/dist/config/index.d.ts +3 -0
  39. package/dist/config/index.d.ts.map +1 -0
  40. package/dist/config/registry.d.ts +38 -0
  41. package/dist/config/registry.d.ts.map +1 -0
  42. package/dist/config/schemas.d.ts +16 -0
  43. package/dist/config/schemas.d.ts.map +1 -0
  44. package/dist/fixtures/generate.d.ts +48 -0
  45. package/dist/fixtures/generate.d.ts.map +1 -0
  46. package/dist/fixtures/index.d.ts +3 -0
  47. package/dist/fixtures/index.d.ts.map +1 -0
  48. package/dist/fixtures/scenarios.d.ts +42 -0
  49. package/dist/fixtures/scenarios.d.ts.map +1 -0
  50. package/dist/hooks/constants.d.ts +49 -0
  51. package/dist/hooks/constants.d.ts.map +1 -0
  52. package/dist/hooks/index.d.ts +7 -0
  53. package/dist/hooks/index.d.ts.map +1 -0
  54. package/dist/hooks/queryOptions.d.ts +58 -0
  55. package/dist/hooks/queryOptions.d.ts.map +1 -0
  56. package/dist/hooks/useItemsMode.d.ts +114 -0
  57. package/dist/hooks/useItemsMode.d.ts.map +1 -0
  58. package/dist/hooks/useModuleItemQueries.d.ts +56 -0
  59. package/dist/hooks/useModuleItemQueries.d.ts.map +1 -0
  60. package/dist/hooks/useModuleItems.d.ts +41 -0
  61. package/dist/hooks/useModuleItems.d.ts.map +1 -0
  62. package/dist/hooks/useModules.d.ts +50 -0
  63. package/dist/hooks/useModules.d.ts.map +1 -0
  64. package/dist/hooks/useModulesPageData.d.ts +78 -0
  65. package/dist/hooks/useModulesPageData.d.ts.map +1 -0
  66. package/dist/i18n.d.ts +92 -0
  67. package/dist/i18n.d.ts.map +1 -0
  68. package/dist/index.d.ts +19 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +1966 -0
  71. package/dist/types/domain.d.ts +147 -0
  72. package/dist/types/domain.d.ts.map +1 -0
  73. package/dist/types/enums.d.ts +93 -0
  74. package/dist/types/enums.d.ts.map +1 -0
  75. package/dist/types/extensions.d.ts +48 -0
  76. package/dist/types/extensions.d.ts.map +1 -0
  77. package/dist/types/index.d.ts +4 -0
  78. package/dist/types/index.d.ts.map +1 -0
  79. package/dist/types/schemas.d.ts +38 -0
  80. package/dist/types/schemas.d.ts.map +1 -0
  81. package/package.json +80 -0
@@ -0,0 +1,41 @@
1
+ import { LimitFunction } from 'p-limit';
2
+ import { ModulesDataAdapter } from '../adapters/types';
3
+ import { ModulesView } from '../cache/keys';
4
+ import { ModuleItem, PageInfo } from '../types/domain';
5
+ export interface UseModuleItemsOptions {
6
+ courseId: string;
7
+ moduleId: string;
8
+ adapter: ModulesDataAdapter;
9
+ pageSize?: number;
10
+ /** The audience being rendered. Partitions the cache; see `ModuleItemsKeyOptions`. */
11
+ view?: ModulesView;
12
+ /**
13
+ * Set to the module's expanded state. A collapsed module fetches nothing, and
14
+ * — because the query stays mounted while disabled — re-expanding it is a
15
+ * cache hit rather than a refetch.
16
+ */
17
+ enabled?: boolean;
18
+ staleTime?: number;
19
+ limit?: LimitFunction;
20
+ }
21
+ export interface UseModuleItemsResult {
22
+ items: ModuleItem[];
23
+ pageInfo: PageInfo;
24
+ hasNextPage: boolean;
25
+ fetchNextPage: () => void;
26
+ isLoading: boolean;
27
+ isFetchingNextPage: boolean;
28
+ error: Error | null;
29
+ }
30
+ /**
31
+ * One module's items, paged explicitly, keyed per module.
32
+ *
33
+ * The query's `AbortSignal` is handed to the adapter (in `queryOptions.ts`), so
34
+ * cancelling the query — which is what collapsing a module does — aborts the
35
+ * request rather than letting a response nobody wants land in the cache.
36
+ *
37
+ * `useModulesPageData` is the hook a page should use; this one is for a caller
38
+ * that already knows it wants exactly one module.
39
+ */
40
+ export declare function useModuleItems(options: UseModuleItemsOptions): UseModuleItemsResult;
41
+ //# sourceMappingURL=useModuleItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModuleItems.d.ts","sourceRoot":"","sources":["../../src/hooks/useModuleItems.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI3D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,kBAAkB,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sFAAsF;IACtF,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;IAClB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CA2CnF"}
@@ -0,0 +1,50 @@
1
+ import { ModulesDataAdapter } from '../adapters/types';
2
+ import { ModulesView } from '../cache/keys';
3
+ import { Module, PageInfo } from '../types/domain';
4
+ export interface UseModulesOptions {
5
+ courseId: string;
6
+ adapter: ModulesDataAdapter;
7
+ /** Modules per request. Defaults to Canvas's max page size. */
8
+ pageSize?: number;
9
+ /** Ask the server to inline each module's items. Resolved by `useItemsMode`. */
10
+ includeItems?: boolean;
11
+ /** Items to request per module when inlining. @see ListModulesArgs.inlineItemsFirst */
12
+ inlineItemsFirst?: number;
13
+ /** Modules to request when inlining. @see ListModulesArgs.inlineFirst */
14
+ inlineFirst?: number;
15
+ view?: ModulesView;
16
+ staleTime?: number;
17
+ enabled?: boolean;
18
+ }
19
+ export interface UseModulesResult {
20
+ /** Every module fetched so far, in server order, flattened across pages. */
21
+ modules: Module[];
22
+ /**
23
+ * The *last fetched page's* pageInfo — i.e. the frontier. `hasNextPage` here
24
+ * is the honest answer to "is there more of this course I have not shown".
25
+ */
26
+ pageInfo: PageInfo;
27
+ hasNextPage: boolean;
28
+ /**
29
+ * Fetches exactly one more page. Nothing in this package calls it on your
30
+ * behalf: pagination is a decision the UI makes, not a side effect of
31
+ * rendering.
32
+ */
33
+ fetchNextPage: () => void;
34
+ isLoading: boolean;
35
+ isFetchingNextPage: boolean;
36
+ /** True while the query has no data, including while it is disabled. */
37
+ isPending: boolean;
38
+ error: Error | null;
39
+ }
40
+ /**
41
+ * The module list, paged explicitly.
42
+ *
43
+ * Deliberately *not* `useAllPages`: that helper walks every page on mount and
44
+ * again on every invalidation, which is the mechanism behind Canvas's
45
+ * "expand a module, refetch the course" behaviour. Here one call is one page,
46
+ * and `hasNextPage` is surfaced so an unfetched remainder is visible to the
47
+ * caller instead of silently dropped.
48
+ */
49
+ export declare function useModules(options: UseModulesOptions): UseModulesResult;
50
+ //# sourceMappingURL=useModules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModules.d.ts","sourceRoot":"","sources":["../../src/hooks/useModules.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAIvD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,kBAAkB,CAAA;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gFAAgF;IAChF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;IAClB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,wEAAwE;IACxE,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CA8CvE"}
@@ -0,0 +1,78 @@
1
+ import { ModulesDataAdapter } from '../adapters/types';
2
+ import { ModulesView } from '../cache/keys';
3
+ import { Module, ModuleItem, PageInfo } from '../types/domain';
4
+ import { ItemsMode, ResolvedItemsMode } from './useItemsMode';
5
+ /** Where a module's items came from. Mostly useful for tests and diagnostics. */
6
+ export type ModuleItemsSource = 'inline' | 'onDemand';
7
+ export interface ModuleItemsState {
8
+ items: ModuleItem[];
9
+ pageInfo: PageInfo;
10
+ hasNextPage: boolean;
11
+ fetchNextPage: () => void;
12
+ isLoading: boolean;
13
+ isFetchingNextPage: boolean;
14
+ error: Error | null;
15
+ source: ModuleItemsSource;
16
+ }
17
+ export interface UseModulesPageDataOptions {
18
+ courseId: string;
19
+ /**
20
+ * Keep this referentially stable — build it once per host, not in render.
21
+ * A new adapter identity every render rebuilds every item observer's options
22
+ * every render. That does not refetch anything, but it is pure churn.
23
+ */
24
+ adapter: ModulesDataAdapter;
25
+ view?: ModulesView;
26
+ /** Defaults to `'auto'`. */
27
+ itemsMode?: ItemsMode;
28
+ inlineThreshold?: number;
29
+ pageSize?: number;
30
+ itemPageSize?: number;
31
+ /** Max simultaneous per-module item requests. Defaults to 4. */
32
+ itemConcurrency?: number;
33
+ /**
34
+ * How many collapsed modules keep their item query subscribed — and therefore
35
+ * their pages pinned in the cache. Defaults to 20.
36
+ * @see DEFAULT_RETAIN_COLLAPSED_LIMIT
37
+ */
38
+ retainCollapsedLimit?: number;
39
+ staleTime?: number;
40
+ initialExpandedModuleIds?: readonly string[];
41
+ }
42
+ export interface UseModulesPageDataResult {
43
+ modules: Module[];
44
+ /** Frontier of the module list. `hasNextPage` is never hidden from the caller. */
45
+ pageInfo: PageInfo;
46
+ hasNextPage: boolean;
47
+ /** One more page of modules. Explicit; nothing calls this for you. */
48
+ fetchNextPage: () => void;
49
+ isLoading: boolean;
50
+ isFetchingNextPage: boolean;
51
+ error: Error | null;
52
+ /** `null` until the `auto` probe resolves. */
53
+ itemsMode: ResolvedItemsMode | null;
54
+ getItems: (moduleId: string) => ModuleItemsState;
55
+ expandModule: (moduleId: string) => void;
56
+ collapseModule: (moduleId: string) => void;
57
+ toggleModule: (moduleId: string) => void;
58
+ expandedModuleIds: readonly string[];
59
+ }
60
+ /**
61
+ * The one hook a modules page renders with.
62
+ *
63
+ * It owns three things the UI should not have to:
64
+ *
65
+ * 1. **Expansion state.** Which modules are open is UI state and is treated as
66
+ * such — expanding or collapsing invalidates nothing. See
67
+ * `cache/invalidate.ts` for why that sentence is the point of the package.
68
+ * 2. **The items-mode decision.** `auto` probes page 1 without items and picks
69
+ * inline or on-demand from what it sees. See `useItemsMode`.
70
+ * 3. **Per-module item fetching**, gated by a shared `p-limit` so "expand
71
+ * everything" is a trickle, and aborted on collapse so a response nobody
72
+ * is waiting for never lands.
73
+ *
74
+ * Both levels of pagination stay explicit and both expose `hasNextPage`, so an
75
+ * unfetched remainder is always visible rather than silently truncated.
76
+ */
77
+ export declare function useModulesPageData(options: UseModulesPageDataOptions): UseModulesPageDataResult;
78
+ //# sourceMappingURL=useModulesPageData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModulesPageData.d.ts","sourceRoot":"","sources":["../../src/hooks/useModulesPageData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAWnE,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIrF,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,UAAU,CAAA;AAErD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;IAClB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,OAAO,EAAE,kBAAkB,CAAA;IAC3B,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC7C;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,kFAAkF;IAClF,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,EAAE,OAAO,CAAA;IACpB,sEAAsE;IACtE,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,SAAS,EAAE,OAAO,CAAA;IAClB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,8CAA8C;IAC9C,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAA;IACnC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,gBAAgB,CAAA;IAChD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAA;CACrC;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,wBAAwB,CAsP/F"}
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,92 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * The i18n seam.
4
+ *
5
+ * This package renders user-visible text, so it cannot hardcode English. It also
6
+ * cannot *translate* anything: the host owns the catalogues, the locale
7
+ * negotiation and the extraction pipeline. So strings are injected, using
8
+ * `TranslateFunction` as defined in `packages/provider/src/i18n.ts`.
9
+ *
10
+ * ## How this differs from ADR 0011, and why
11
+ *
12
+ * ADR 0011 (`docs/adr/translations.md`) specifies a `translations` *object* of
13
+ * named keys plus a `translate` function, and packages shipping `locales/en.json`.
14
+ * notebook, widget-dashboard and block-content-editor all do that; this package
15
+ * does not.
16
+ *
17
+ * The divergence is deliberate and argued in `docs/adr/modules-i18n.md`. In short:
18
+ * ADR 0011 marks itself provisional and lists "large interface: 100+ keys and
19
+ * growing" and "host must provide all keys; missing keys fail silently or throw"
20
+ * as its own known costs. Using the English source string as the key removes both
21
+ * — there is no key surface to keep in sync, and a missing translation degrades to
22
+ * readable English rather than to a blank or a throw.
23
+ *
24
+ * ## Keys are the English source string
25
+ *
26
+ * `t('Load more items (%{loaded} of %{total} loaded)', { loaded, total })`.
27
+ *
28
+ * The package therefore renders correctly with no provider at all — the default
29
+ * `t` interpolates the key itself — so Storybook, tests and a host mid-migration
30
+ * all work.
31
+ *
32
+ * One thing this does *not* buy, contrary to what this comment used to say:
33
+ * automatic extraction. Canvas's i18nliner cannot see a literal passed at runtime,
34
+ * which is exactly why `platformBridge.tsx` maintains a `LITERAL_THUNKS` list — and
35
+ * it already carries `'%{points} pts'`, the same literal `labels.ts` uses. A Canvas
36
+ * host adopting this package adds its literals there. That is a real cost of this
37
+ * shape and belongs on the record.
38
+ *
39
+ * ## Why the locale rides along
40
+ *
41
+ * `labels.ts` formats dates and numbers through `Intl`, which needs a locale.
42
+ * Translating the words while hard-pinning `en-US` would produce German text beside
43
+ * American dates, so the two travel together.
44
+ *
45
+ * `timezone` is deliberately absent, and not because the package cannot reach one:
46
+ * it is on provider context (`CanvasUiProvider.tsx:26-27,63-65`) and Canvas passes
47
+ * `ENV.TIMEZONE` through `platformBridge.tsx`. Consuming it means either depending
48
+ * on `usePlatformUi()`, which throws without a provider and would cost this package
49
+ * its render-anywhere property, or a host passing it in alongside `locale`. The
50
+ * latter is the right shape; the timezone-aware formatting behind it is not built,
51
+ * so the prop does not exist yet rather than existing unused.
52
+ */
53
+ /**
54
+ * Translate an English source string, interpolating `%{named}` placeholders.
55
+ *
56
+ * Structurally compatible with `TranslateFunction` from
57
+ * `@instructure/platform-provider`, so a host already supplying one can pass it
58
+ * straight through.
59
+ */
60
+ export type TranslateFunction = (key: string, options?: Record<string, unknown>) => string;
61
+ /**
62
+ * The no-host fallback: interpolate the key, translate nothing.
63
+ *
64
+ * An unknown placeholder is left visibly intact (`%{name}`) rather than replaced
65
+ * with "undefined" — a missing interpolation should look like a bug, not like
66
+ * data.
67
+ */
68
+ export declare const defaultTranslate: TranslateFunction;
69
+ export interface ModulesI18n {
70
+ t: TranslateFunction;
71
+ /** BCP 47 tag for `Intl` formatting. */
72
+ locale: string;
73
+ }
74
+ export declare const DEFAULT_LOCALE = "en-US";
75
+ export interface ModulesI18nProviderProps {
76
+ /** Omit to render untranslated English. */
77
+ t?: TranslateFunction;
78
+ /** Omit for `en-US`. */
79
+ locale?: string;
80
+ children: ReactNode;
81
+ }
82
+ /**
83
+ * Supplies the host's translate function and locale.
84
+ *
85
+ * Optional. Without it the package renders untranslated English, which is the
86
+ * right behaviour for Storybook and for a host mid-migration — a thrown error
87
+ * would make the seam harder to adopt than the hardcoded strings it replaces.
88
+ */
89
+ export declare function ModulesI18nProvider({ t, locale, children }: ModulesI18nProviderProps): ReactNode;
90
+ /** The translate function and locale, falling back to untranslated English. */
91
+ export declare function useModulesI18n(): ModulesI18n;
92
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;AAI1F;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBAK9B,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,iBAAiB,CAAA;IACpB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,cAAc,UAAU,CAAA;AAMrC,MAAM,WAAW,wBAAwB;IACvC,2CAA2C;IAC3C,CAAC,CAAC,EAAE,iBAAiB,CAAA;IACrB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,wBAAwB,GAAG,SAAS,CAMhG;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Public surface of @instructure/platform-modules.
3
+ *
4
+ * Hosts should need three things: a domain type, an adapter factory, and
5
+ * `useModulesPageData`. Everything else is exported for testing, for hosts
6
+ * that want finer control, or for the track that owns it.
7
+ */
8
+ export type { CompletionRequirement, CompletionRequirementType, Module, ModuleItem, ModuleItemsPage, ModuleItemStatus, ModuleItemType, ModuleProgress, ModulesPage, ModuleStatus, PageInfo, } from './types';
9
+ export { CompletionRequirementSchema, CompletionRequirementTypeSchema, ModuleItemSchema, ModuleItemsPageSchema, ModuleItemStatusSchema, ModuleItemTypeSchema, ModuleProgressSchema, ModuleSchema, ModulesPageSchema, ModuleStatusSchema, PageInfoSchema, } from './types';
10
+ export { EXT_CAREER_ESTIMATED_DURATION_MINUTES, getEstimatedDurationMinutes, withEstimatedDurationMinutes, } from './types';
11
+ export type { ListModuleItemsArgs, ListModulesArgs, ModulesDataAdapter } from './adapters';
12
+ export { createInMemoryAdapter, InMemoryCourseMismatchError, INLINE_ITEM_LIMIT, type InMemoryAdapterOptions, type InMemoryFixture, type InMemoryRequest, } from './adapters';
13
+ export { type CanvasGraphqlAdapterOptions, createCanvasGraphqlAdapter, INLINE_QUERY_NODE_BUDGET, type ExecuteQuery, GET_MODULE_ITEMS, GET_MODULES, PartialCanvasResponseError, type PartialResponseSubject, type UnsupportedModuleItem, } from './adapters/canvasGraphql';
14
+ export { DEFAULT_INLINE_THRESHOLD, DEFAULT_ITEM_CONCURRENCY, DEFAULT_ITEM_PAGE_SIZE, DEFAULT_PAGE_SIZE, DEFAULT_RETAIN_COLLAPSED_LIMIT, DEFAULT_STALE_TIME_MS, type InlineQueryShape, type ItemsMode, type ModuleItemsSource, type ModuleItemsState, type ResolvedItemsMode, useModuleItems, type UseModuleItemsOptions, type UseModuleItemsResult, useModules, type UseModulesOptions, useModulesPageData, type UseModulesPageDataOptions, type UseModulesPageDataResult, type UseModulesResult, } from './hooks';
15
+ export { invalidateCourse, invalidateModuleItems, invalidateModuleList, moduleItemsPrefix, type ModuleItemsKeyOptions, modulesKeys, modulesListPrefix, type ModulesListKeyOptions, type ModulesView, } from './cache';
16
+ export { filterLabel, FilterChips, type FilterChipsProps, ModuleCard, type ModuleCardProps, ModuleItemRow, type ModuleItemRowProps, moduleItemStatusLabel, ModuleItemStatusPill, type ModuleItemStatusPillProps, MODULES_FILTER_IDS, type ModulesFilterId, ModulesList, type ModulesListProps, type ModulesRequestCounts, moduleStatusLabel, ModuleStatusPill, type ModuleStatusPillProps, } from './components';
17
+ export { DEFAULT_LOCALE, defaultTranslate, type ModulesI18n, ModulesI18nProvider, type ModulesI18nProviderProps, type TranslateFunction, useModulesI18n, } from './i18n';
18
+ export { buildFixture, type BuildFixtureOptions, courseEmpty, courseFatModule, courseLarge, courseSmall, FIXTURE_COURSE_ID, type FixtureView, } from './fixtures';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+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