@instructure/platform-cohorts 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.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @instructure/platform-cohorts
2
+
3
+ Cohort management UI for Canvas.
4
+
5
+ Cohorts is a new domain model for grouping users into hierarchical groups agnostic of the account structure that powers exactly six things:
6
+ - enrollment into courses
7
+ - enrollment into programs
8
+ - enrollment into collections
9
+ - targeted global announcements
10
+ - targeted learner dashboards
11
+ - filtered reporting
12
+
13
+ This package is the **foundational** slice of that work. Per-product extensions belong in the consuming app, not here.
14
+
15
+ Read more: [`docs/tech-spec.md`](./docs/tech-spec.md) (reference copy).
16
+
17
+ The REST contract lives in [`openapi.yaml`](./openapi.yaml) and is the source of truth for every API operation this package performs.
18
+
19
+ ## Development
20
+
21
+ Everything runs from the monorepo root unless noted.
22
+
23
+ ```bash
24
+ pnpm install # link the package into the workspace
25
+ pnpm storybook # http://localhost:6006 — the dev loop
26
+ pnpm --filter @instructure/platform-cohorts test # vitest + coverage
27
+ pnpm --filter @instructure/platform-cohorts build # vite lib build + .d.ts
28
+ pnpm --filter @instructure/platform-cohorts type-check
29
+ pnpm lint # biome + oxlint + ast-grep
30
+ ```
@@ -0,0 +1,3 @@
1
+ import { ReactNode } from 'react';
2
+ export declare function CohortsHelloWorld(): ReactNode;
3
+ //# sourceMappingURL=CohortsHelloWorld.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CohortsHelloWorld.d.ts","sourceRoot":"","sources":["../../src/components/CohortsHelloWorld.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,wBAAgB,iBAAiB,IAAI,SAAS,CAG7C"}
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ import { default as en } from '../locales/en.json';
3
+ /** Every key the catalog ships. Type translated props as this, never as `string`. */
4
+ export type CohortsTranslationKey = keyof typeof en;
5
+ export type PluralForms = Partial<Record<Intl.LDMLPluralRule, string>>;
6
+ /** A host supplies as few or as many keys as it likes; the rest fall back to English. */
7
+ export type CohortsTranslations = Partial<Record<CohortsTranslationKey, PluralForms | string>>;
8
+ export type TranslateFunction = (key: CohortsTranslationKey, options?: Record<string, unknown>) => string;
9
+ export declare const DEFAULT_LOCALE = "en-US";
10
+ export declare function createTranslate(translations?: CohortsTranslations, locale?: string): TranslateFunction;
11
+ export declare const defaultTranslate: TranslateFunction;
12
+ export interface CohortsI18n {
13
+ t: TranslateFunction;
14
+ locale: string;
15
+ timezone?: string;
16
+ }
17
+ export interface CohortsI18nProviderProps {
18
+ translations?: CohortsTranslations;
19
+ locale?: string;
20
+ timezone?: string;
21
+ children: ReactNode;
22
+ }
23
+ export declare function CohortsI18nProvider({ translations, locale, timezone, children, }: CohortsI18nProviderProps): ReactNode;
24
+ export declare function useCohortsI18n(): CohortsI18n;
25
+ //# 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;AAC1E,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEnC,qFAAqF;AACrF,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,EAAE,CAAA;AAEnD,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAA;AAEtE,yFAAyF;AACzF,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAA;AAE9F,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,qBAAqB,EAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,MAAM,CAAA;AAMX,eAAO,MAAM,cAAc,UAAU,CAAA;AAoDrC,wBAAgB,eAAe,CAC7B,YAAY,CAAC,EAAE,mBAAmB,EAClC,MAAM,GAAE,MAAuB,GAC9B,iBAAiB,CAQnB;AAED,eAAO,MAAM,gBAAgB,EAAE,iBAAqC,CAAA;AAEpE,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,iBAAiB,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAMD,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,mBAAmB,CAAA;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,GACT,EAAE,wBAAwB,GAAG,SAAS,CAMtC;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
@@ -0,0 +1,3 @@
1
+ export { CohortsHelloWorld } from './components/CohortsHelloWorld';
2
+ export { type CohortsI18n, CohortsI18nProvider, type CohortsI18nProviderProps, type CohortsTranslationKey, type CohortsTranslations, createTranslate, DEFAULT_LOCALE, defaultTranslate, type PluralForms, type TranslateFunction, useCohortsI18n, } from './i18n';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EACL,KAAK,WAAW,EAChB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,cAAc,GACf,MAAM,QAAQ,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { Text as d } from "@instructure/ui-text";
3
+ import { createContext as h, useMemo as p, useContext as C } from "react";
4
+ const b = "Hello World", F = {
5
+ helloWorld: b
6
+ }, a = /%\{(\w+)\}/g, v = F, c = "en-US", A = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
7
+ function s(t, e, r) {
8
+ const n = t.get(e);
9
+ if (n) return n;
10
+ const o = r();
11
+ return t.set(e, o), o;
12
+ }
13
+ function T(t, e, r) {
14
+ return r ? t.replace(a, (n, o) => {
15
+ if (!Object.prototype.hasOwnProperty.call(r, o)) return n;
16
+ const u = r[o];
17
+ return typeof u == "number" ? Number.isFinite(u) ? s(L, e, () => new Intl.NumberFormat(e)).format(u) : n : String(u);
18
+ }) : t;
19
+ }
20
+ function g(t, e, r) {
21
+ const n = r == null ? void 0 : r.count;
22
+ if (typeof n == "number" && Number.isFinite(n)) {
23
+ const o = s(A, e, () => new Intl.PluralRules(e)).select(n), u = t[o];
24
+ if (typeof u == "string") return u;
25
+ }
26
+ return t.other;
27
+ }
28
+ function l(t, e, r) {
29
+ if (t !== void 0)
30
+ return typeof t == "string" ? t : g(t, e, r);
31
+ }
32
+ function i(t, e = c) {
33
+ return (r, n) => {
34
+ const o = l(t == null ? void 0 : t[r], e, n) ?? l(v[r], e, n) ?? r;
35
+ return T(o, e, n);
36
+ };
37
+ }
38
+ const w = i(), x = { t: w, locale: c }, m = h(null);
39
+ function W({
40
+ translations: t,
41
+ locale: e,
42
+ timezone: r,
43
+ children: n
44
+ }) {
45
+ const o = p(() => {
46
+ const u = e ?? c;
47
+ return { t: i(t, u), locale: u, timezone: r };
48
+ }, [t, e, r]);
49
+ return /* @__PURE__ */ f(m.Provider, { value: o, children: n });
50
+ }
51
+ function I() {
52
+ return C(m) ?? x;
53
+ }
54
+ function E() {
55
+ const { t } = I();
56
+ return /* @__PURE__ */ f(d, { children: t("helloWorld") });
57
+ }
58
+ export {
59
+ E as CohortsHelloWorld,
60
+ W as CohortsI18nProvider,
61
+ c as DEFAULT_LOCALE,
62
+ i as createTranslate,
63
+ w as defaultTranslate,
64
+ I as useCohortsI18n
65
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "helloWorld": "Hello World"
3
+ }
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@instructure/platform-cohorts",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./locales/*": "./locales/*"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "locales"
18
+ ],
19
+ "scripts": {
20
+ "build": "vite build",
21
+ "dev": "vite build --watch",
22
+ "pack:tarball": "pnpm build && pnpm pack",
23
+ "test": "vitest run --coverage",
24
+ "test:watch": "vitest",
25
+ "type-check": "tsgo -p tsconfig.check.json"
26
+ },
27
+ "peerDependencies": {
28
+ "@instructure/platform-provider": "workspace:*",
29
+ "@instructure/ui-text": "^11.0.0",
30
+ "@instructure/ui-view": "^11.0.0",
31
+ "@tanstack/react-query": "^5.0.0",
32
+ "react": "^18.0.0",
33
+ "react-dom": "^18.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@instructure/platform-provider": "workspace:*",
37
+ "@instructure/platform-test-utils": "workspace:*",
38
+ "@instructure/ui-text": "11.7.4",
39
+ "@instructure/ui-view": "11.7.4",
40
+ "@storybook/react": "^10.0.8",
41
+ "@tanstack/react-query": "^5.59.15",
42
+ "@testing-library/jest-dom": "^6.9.1",
43
+ "@testing-library/react": "^16.3.0",
44
+ "@types/react": "^18.3.0",
45
+ "@types/react-dom": "^18.3.0",
46
+ "@vitejs/plugin-react": "^4.2.0",
47
+ "@vitest/coverage-v8": "^4.0.17",
48
+ "jsdom": "^25.0.0",
49
+ "msw": "^2.0.0",
50
+ "typescript": "^5.3.0",
51
+ "vite": "^6.0.0",
52
+ "vite-plugin-dts": "^4.0.0",
53
+ "vitest": "^4.0.0"
54
+ }
55
+ }