@g9tm/lynxcontrols-web 0.0.0-stage → 2.4.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 +107 -2
- package/catalog/catalog.json +305 -0
- package/catalog/index.md +4 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/font.d.ts +7 -0
- package/dist/font.d.ts.map +1 -0
- package/dist/font.js +4 -0
- package/dist/font.js.map +1 -0
- package/dist/handler.d.ts +69 -0
- package/dist/handler.d.ts.map +1 -0
- package/dist/handler.js +180 -0
- package/dist/handler.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/install.d.ts +96 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +310 -0
- package/dist/install.js.map +1 -0
- package/dist/module.d.ts +22 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +46 -0
- package/dist/module.js.map +1 -0
- package/dist/static.d.ts +57 -0
- package/dist/static.d.ts.map +1 -0
- package/dist/static.js +395 -0
- package/dist/static.js.map +1 -0
- package/package.json +44 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sources":["../src/install.ts"],"sourcesContent":["// Installs G9HostModule on a `<lynx-view>` (Lynx for Web): names the worker module (./module.ts) in the view's\n// `nativeModulesMap` and answers its calls from the page (`onNativeModulesCall`, ./handler.ts). Call it before the\n// view gets its `url`. The page's safe-area insets (`env(safe-area-inset-*)`) are measured once and again on every\n// resize, and sent to the page as the `g9:insets` event the native hosts send on rotation.\n//\n// The window a G9 provider sizes its layout class by is the VIEW: Lynx for Web fills SystemInfo from the screen\n// (`screen.availWidth`) and sends no resize, so a 390 px `<lynx-view>` in a 1,600 px window reported `desktop` and\n// never changed. The host starts the view's `browserConfig` at its own size and reports every change of it as the\n// `onWindowResize` event the provider listens to (the event a native host sends on a window resize).\n\nimport { G9_WEB_FONT_STACK } from './font';\nimport { createG9WebHostHandler, type G9WebFindings, type G9WebHostOptions, type G9WebInsets } from './handler';\n\n/** The part of a `<lynx-view>` element (@lynx-js/web-core) the host uses. */\nexport interface G9LynxViewElement {\n nativeModulesMap?: Record<string, string> | undefined;\n onNativeModulesCall?: ((name: string, data: unknown, moduleName: string) => unknown) | undefined;\n sendGlobalEvent?(eventName: string, params: unknown[]): void;\n /** The view's own events (`error`: the runtime caught an error in the page's code). */\n addEventListener?(type: string, listener: (event: { readonly detail?: unknown }) => void): void;\n removeEventListener?(type: string, listener: (event: { readonly detail?: unknown }) => void): void;\n /** CSS rules inserted into the view's shadow root, read when the card starts. */\n injectStyleRules?: string[] | undefined;\n /** The view's SystemInfo overrides (pixelWidth / pixelHeight / pixelRatio), read when the card starts. */\n browserConfig?: Record<string, unknown> | string | undefined;\n readonly clientWidth?: number;\n readonly clientHeight?: number;\n /** Where the card's elements live (an open shadow root, attached when the view first renders). */\n readonly shadowRoot?: Node | null;\n attachShadow?(init: { mode: 'open' | 'closed' }): Node;\n}\n\n/** Watches an element's size (`ResizeObserver`); tests pass a fake. Returns the stop function. */\nexport type G9SizeWatcher = (element: object, onResize: () => void) => () => void;\n\n/** The page's `ResizeObserver` as a size watcher, or null where there is none (read when a host is installed). */\nfunction resizeObserverWatcher(): G9SizeWatcher | null {\n if (typeof ResizeObserver === 'undefined') return null;\n return (element, onResize) => {\n const observer = new ResizeObserver(() => onResize());\n observer.observe(element as Element);\n return () => observer.disconnect();\n };\n}\n\n/**\n * The rules the host adds to the view's shadow root so a browser draws text as the native engines do:\n * - the system font: a browser's default is a serif, the native default the system's sans;\n * - each text's direction from its first strong letter (`@g9tm/lynxcontrols` in a Persian page reads as written, as on\n * Android and iOS), where the browser would take it from the CSS `direction` and move the `@` to the end;\n * - the view as a size container, the box the viewport units measure against ({@link bridgeViewportUnits}).\n */\nexport const G9_WEB_STYLE_RULES: readonly string[] = [\n `:host { font-family: ${G9_WEB_FONT_STACK}; }`,\n 'x-text::part(inner-box) { unicode-bidi: plaintext; }',\n ':host { container-type: size; }',\n];\n\nconst VIEWPORT_UNIT = /(\\d)v(w|h|min|max)\\b/g;\nconst HAS_VIEWPORT_UNIT = /\\dv(w|h|min|max)\\b/;\n\n/** `100vw` → `100cqw`, `calc(50vh - 8px)` → `calc(50cqh - 8px)`. */\nexport const toContainerUnits = (value: string): string => value.replace(VIEWPORT_UNIT, '$1cq$2');\n\nfunction rewriteDeclaration(style: CSSStyleDeclaration): void {\n for (let i = 0; i < style.length; i++) {\n const name = style.item(i);\n const value = style.getPropertyValue(name);\n if (HAS_VIEWPORT_UNIT.test(value))\n style.setProperty(name, toContainerUnits(value), style.getPropertyPriority(name));\n }\n}\n\nfunction rewriteRules(rules: CSSRuleList): void {\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i] as CSSRule & { style?: CSSStyleDeclaration; cssRules?: CSSRuleList };\n if (rule.style) rewriteDeclaration(rule.style);\n if (rule.cssRules) rewriteRules(rule.cssRules);\n }\n}\n\n/**\n * Viewport units on the web: a native engine measures `vw` / `vh` against the LynxView, a browser against its window,\n * so lynx-ui's sheet (`width: 100vw`) in a 390 px view inside a 1,600 px window was 1,600 px wide and its text ran out\n * of the view. The view is a size container (`:host { container-type: size }`, {@link G9_WEB_STYLE_RULES}; it already\n * has `contain: strict`), and every viewport unit under `root` becomes the container's own (`cqw`, `cqh`, `cqmin`,\n * `cqmax`): in each style sheet once, and in each element's inline style as it is written. Returns the stop function.\n */\nexport function bridgeViewportUnits(\n root: Node & { styleSheets?: StyleSheetList; adoptedStyleSheets?: CSSStyleSheet[] },\n): () => void {\n if (typeof MutationObserver === 'undefined') return () => undefined;\n const seen = new WeakSet<object>();\n const sheets = () => {\n for (const sheet of [...Array.from(root.styleSheets ?? []), ...(root.adoptedStyleSheets ?? [])]) {\n if (seen.has(sheet)) continue;\n seen.add(sheet);\n try {\n rewriteRules((sheet as CSSStyleSheet).cssRules);\n } catch {\n // a cross-origin sheet hides its rules\n }\n }\n };\n const inline = (element: Element) => {\n const text = element.getAttribute('style');\n if (text && HAS_VIEWPORT_UNIT.test(text)) rewriteDeclaration((element as HTMLElement).style);\n };\n const scan = (node: Node) => {\n if (!(node instanceof Element)) return;\n inline(node);\n for (const e of Array.from(node.querySelectorAll('[style]'))) inline(e);\n };\n sheets();\n for (const child of Array.from(root.childNodes)) scan(child);\n const observer = new MutationObserver((records) => {\n sheets();\n for (const r of records) {\n if (r.type === 'childList') for (const n of Array.from(r.addedNodes)) scan(n);\n else if (r.target instanceof Element) inline(r.target);\n }\n });\n observer.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ['style'] });\n return () => observer.disconnect();\n}\n\nconst INPUTS = 'x-input[default-value], x-textarea[default-value]';\n\n/** Gives one input its start text, unless it already has a `value`. */\nfunction startTextOf(element: Element): void {\n const text = element.getAttribute('default-value');\n if (text !== null && !element.hasAttribute('value')) element.setAttribute('value', text);\n}\n\n/**\n * Lynx's `<input default-value>` / `<textarea default-value>` (the start text, which G9's number, time and tag entries\n * write) on the web: Lynx for Web's `x-input` and `x-textarea` know only `value`, so a time entry started at 08:30 drew\n * an empty box. Every input that appears under `root` with a start text gets it as its `value`, once; later text comes\n * from the control's own `setValue`, as on the native engines. Returns the stop function (nothing to stop without a\n * `MutationObserver`).\n */\nexport function bridgeStartText(root: Node): () => void {\n if (typeof MutationObserver === 'undefined') return () => undefined;\n const scan = (node: Node) => {\n if (!(node instanceof Element)) return;\n if (node.matches(INPUTS)) startTextOf(node);\n for (const input of Array.from(node.querySelectorAll(INPUTS))) startTextOf(input);\n };\n for (const child of Array.from(root.childNodes)) scan(child);\n const observer = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'childList') for (const n of Array.from(r.addedNodes)) scan(n);\n else if (r.oldValue === null && r.target instanceof Element && r.target.matches(INPUTS)) startTextOf(r.target);\n }\n });\n observer.observe(root, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['default-value'],\n attributeOldValue: true,\n });\n return () => observer.disconnect();\n}\n\n/** Options of {@link installG9WebHost}. */\nexport interface G9WebInstallOptions extends G9WebHostOptions {\n /** The URL of this package's worker module (`@g9tm/lynxcontrols-web/module`), when a bundler moved it. */\n readonly moduleUrl?: string;\n /** Where resizes come from (default: the page's `window`); tests pass a fake. */\n readonly resizeTarget?: {\n addEventListener(type: 'resize', l: () => void): void;\n removeEventListener(type: 'resize', l: () => void): void;\n } | null;\n /** How the view's own size is watched (default: a `ResizeObserver`; null: the layout keeps the start size). */\n readonly sizeWatcher?: G9SizeWatcher | null;\n /** The device pixel ratio (default: the page's `devicePixelRatio`). */\n readonly pixelRatio?: number;\n /** The rules added to the view's shadow root (default {@link G9_WEB_STYLE_RULES}; `[]` adds none). */\n readonly styleRules?: readonly string[];\n}\n\n/** The page's safe-area insets in px (= dp on the web), start/end in the document's direction; 0 without `env()`. */\nexport function pageSafeInsets(): G9WebInsets {\n if (typeof document === 'undefined' || !document.body) return { top: 0, end: 0, bottom: 0, start: 0 };\n const probe = document.createElement('div');\n probe.style.cssText =\n 'position:fixed;visibility:hidden;pointer-events:none;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)';\n document.body.appendChild(probe);\n const style = getComputedStyle(probe);\n const px = (v: string) => Number.parseFloat(v) || 0;\n const left = px(style.paddingLeft);\n const right = px(style.paddingRight);\n const insets = { top: px(style.paddingTop), bottom: px(style.paddingBottom) };\n probe.remove();\n const rtl = document.documentElement.dir === 'rtl';\n return { ...insets, start: rtl ? right : left, end: rtl ? left : right };\n}\n\n/**\n * The default URL of the worker module: `module.js` next to this file in the published package. Plain string work on\n * `import.meta.url`, never `new URL('./module.js', import.meta.url)`: a bundler rewrites that pattern (rslib copied\n * module.ts as an asset, and with a variable it emitted a `require` context that fails in a browser).\n */\nexport const g9WebHostModuleUrl = (): string => {\n const here = import.meta.url;\n return `${here.slice(0, here.lastIndexOf('/') + 1)}module.js`;\n};\n\ninterface FindingsState {\n latest: G9WebFindings | null;\n readonly listeners: Set<(findings: G9WebFindings) => void>;\n}\nconst findingsOf = new WeakMap<object, FindingsState>();\nfunction stateOf(view: object): FindingsState {\n let state = findingsOf.get(view);\n if (!state) {\n state = { latest: null, listeners: new Set() };\n findingsOf.set(view, state);\n }\n return state;\n}\n\n/**\n * The latest findings of G9AppPilot's watch in `view`'s page (LC-08: the bundle built with the `observe` profile or up,\n * `@g9tm/lynxcontrols-pilot`): js errors, controls without a name, translation keys and controls off screen, and what\n * a browser cannot measure (`unsupported`). Null before the watch has sent anything (or in a build without it).\n */\nexport function g9WebFindings(view: object): G9WebFindings | null {\n return findingsOf.get(view)?.latest ?? null;\n}\n\n/** Calls `listener` with every set of findings `view`'s watch sends; returns the unsubscribe. */\nexport function subscribeG9WebFindings(view: object, listener: (findings: G9WebFindings) => void): () => void {\n const state = stateOf(view);\n state.listeners.add(listener);\n return () => void state.listeners.delete(listener);\n}\n\n/**\n * Asks the watch to run its screen rules now (`oracle.check`) and resolves with the findings it sends after that\n * check; null when nothing answers within `timeoutMs` (a build without the watch).\n */\nexport function checkG9WebScreen(view: G9LynxViewElement, timeoutMs = 5000): Promise<G9WebFindings | null> {\n const before = g9WebFindings(view)?.checks ?? 0;\n return new Promise((resolve) => {\n let done = false;\n const finish = (value: G9WebFindings | null) => {\n if (done) return;\n done = true;\n stop();\n clearTimeout(timer);\n resolve(value);\n };\n const stop = subscribeG9WebFindings(view, (findings) => {\n if (findings.checks > before) finish(findings);\n });\n const timer = setTimeout(() => finish(null), timeoutMs);\n view.sendGlobalEvent?.('g9:pilot-check', []);\n });\n}\n\n/** The message of a `<lynx-view>` `error` event's detail (web-core sends an Error, a string or an object with one). */\nfunction errorText(detail: unknown): string {\n if (typeof detail === 'string') return detail;\n const d = detail as { error?: unknown; message?: unknown } | null | undefined;\n const inner = d?.error as { message?: unknown } | string | undefined;\n if (typeof inner === 'string') return inner;\n if (typeof inner?.message === 'string') return inner.message;\n if (typeof d?.message === 'string') return d.message;\n try {\n return JSON.stringify(detail) ?? '';\n } catch {\n return String(detail);\n }\n}\n\n/** Installs the host on `view`; returns the uninstaller (the previous handler and map come back). */\nexport function installG9WebHost(view: G9LynxViewElement, options: G9WebInstallOptions = {}): () => void {\n const insets = options.insets ?? pageSafeInsets;\n const findings = stateOf(view);\n const handle = createG9WebHostHandler({\n ...options,\n insets,\n onPilotFindings: (next) => {\n findings.latest = next;\n for (const listener of [...findings.listeners]) listener(next);\n options.onPilotFindings?.(next);\n },\n ...(options.vibrate === undefined && typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function'\n ? { vibrate: (ms: number) => navigator.vibrate(ms) }\n : {}),\n ...(options.blur === undefined && typeof document !== 'undefined'\n ? { blur: () => (document.activeElement as { blur?: () => void } | null)?.blur?.() }\n : {}),\n });\n const previousMap = view.nativeModulesMap;\n const previousCall = view.onNativeModulesCall;\n view.nativeModulesMap = { ...(previousMap ?? {}), G9HostModule: options.moduleUrl ?? g9WebHostModuleUrl() };\n view.onNativeModulesCall = (name, data, moduleName) =>\n moduleName === 'G9HostModule'\n ? handle(name, (data ?? {}) as Readonly<Record<string, unknown>>)\n : previousCall?.(name, data, moduleName);\n const previousRules = view.injectStyleRules;\n const rules = options.styleRules ?? G9_WEB_STYLE_RULES;\n if (rules.length) view.injectStyleRules = [...(previousRules ?? []), ...rules];\n // the view attaches its shadow root when it first renders, after this install: watch it from that moment\n let stopBridges: (() => void) | undefined;\n // biome-ignore lint/suspicious/noPrototypeBuiltins: the package's lib is ES2019, which has no Object.hasOwn\n const ownAttach = Object.prototype.hasOwnProperty.call(view, 'attachShadow') ? view.attachShadow : undefined;\n const bridge = (root: Node) => {\n const stops = [bridgeStartText(root), bridgeViewportUnits(root)];\n stopBridges = () => {\n for (const stop of stops) stop();\n };\n };\n if (view.shadowRoot) bridge(view.shadowRoot);\n else if (typeof view.attachShadow === 'function') {\n const attach = view.attachShadow;\n view.attachShadow = function attachShadow(this: G9LynxViewElement, init) {\n const root = attach.call(this, init);\n bridge(root);\n return root;\n };\n }\n // the runtime's own errors (an uncaught throw in the page's code) go to the watch, which makes them js.error findings\n const onError = (event: { readonly detail?: unknown }) =>\n view.sendGlobalEvent?.('g9:lynx-error', [errorText(event.detail)]);\n view.addEventListener?.('error', onError);\n const resizes =\n options.resizeTarget === undefined ? (typeof window === 'undefined' ? null : window) : options.resizeTarget;\n const onResize = () => view.sendGlobalEvent?.('g9:insets', [insets()]);\n resizes?.addEventListener('resize', onResize);\n // the layout class follows the view's own size (see the file comment)\n const ratio =\n options.pixelRatio ?? (typeof devicePixelRatio === 'number' && devicePixelRatio > 0 ? devicePixelRatio : 1);\n const size = () => ({ width: view.clientWidth ?? 0, height: view.clientHeight ?? 0 });\n const previousConfig = view.browserConfig;\n const start = size();\n if (start.width > 0 && start.height > 0) {\n const base = typeof previousConfig === 'object' && previousConfig !== null ? previousConfig : {};\n view.browserConfig = {\n ...base,\n pixelRatio: ratio,\n pixelWidth: start.width * ratio,\n pixelHeight: start.height * ratio,\n };\n }\n let last = start;\n const watcher = options.sizeWatcher === undefined ? resizeObserverWatcher() : options.sizeWatcher;\n const stopWatching = watcher?.(view, () => {\n const next = size();\n if (next.width === last.width && next.height === last.height) return;\n last = next;\n view.sendGlobalEvent?.('onWindowResize', [next.width, next.height]);\n });\n return () => {\n view.removeEventListener?.('error', onError);\n stopBridges?.();\n if (ownAttach) view.attachShadow = ownAttach;\n else delete view.attachShadow;\n stopWatching?.();\n resizes?.removeEventListener('resize', onResize);\n view.nativeModulesMap = previousMap;\n view.onNativeModulesCall = previousCall;\n view.browserConfig = previousConfig;\n view.injectStyleRules = previousRules;\n };\n}\n"],"names":["resizeObserverWatcher","ResizeObserver","element","onResize","observer","G9_WEB_STYLE_RULES","G9_WEB_FONT_STACK","VIEWPORT_UNIT","HAS_VIEWPORT_UNIT","toContainerUnits","value","rewriteDeclaration","style","i","name","rewriteRules","rules","rule","bridgeViewportUnits","root","MutationObserver","undefined","seen","WeakSet","sheets","_root_styleSheets","_root_adoptedStyleSheets","sheet","Array","inline","text","scan","node","Element","e","child","records","r","n","INPUTS","startTextOf","bridgeStartText","input","pageSafeInsets","document","probe","getComputedStyle","px","v","Number","left","right","insets","rtl","g9WebHostModuleUrl","here","findingsOf","WeakMap","stateOf","view","state","Set","g9WebFindings","_findingsOf_get","subscribeG9WebFindings","listener","checkG9WebScreen","timeoutMs","_g9WebFindings","before","Promise","resolve","done","finish","stop","clearTimeout","timer","findings","setTimeout","errorText","detail","d","inner","_JSON_stringify","String","installG9WebHost","options","_options_insets","_options_moduleUrl","_options_styleRules","_options_pixelRatio","handle","createG9WebHostHandler","next","navigator","ms","_document_activeElement_blur","_document_activeElement","previousMap","previousCall","data","moduleName","previousRules","stopBridges","ownAttach","Object","bridge","stops","attach","init","onError","event","resizes","window","ratio","devicePixelRatio","size","_view_clientWidth","_view_clientHeight","previousConfig","start","base","last","watcher","stopWatching"],"mappings":";;AAoCA,SAASA;IACP,IAAI,AAA0B,MAA1B,OAAOC,gBAAgC,OAAO;IAClD,OAAO,CAACC,SAASC;QACf,MAAMC,WAAW,IAAIH,eAAe,IAAME;QAC1CC,SAAS,OAAO,CAACF;QACjB,OAAO,IAAME,SAAS,UAAU;IAClC;AACF;AASO,MAAMC,qBAAwC;IACnD,CAAC,qBAAqB,EAAEC,kBAAkB,GAAG,CAAC;IAC9C;IACA;CACD;AAED,MAAMC,gBAAgB;AACtB,MAAMC,oBAAoB;AAGnB,MAAMC,mBAAmB,CAACC,QAA0BA,MAAM,OAAO,CAACH,eAAe;AAExF,SAASI,mBAAmBC,KAA0B;IACpD,IAAK,IAAIC,IAAI,GAAGA,IAAID,MAAM,MAAM,EAAEC,IAAK;QACrC,MAAMC,OAAOF,MAAM,IAAI,CAACC;QACxB,MAAMH,QAAQE,MAAM,gBAAgB,CAACE;QACrC,IAAIN,kBAAkB,IAAI,CAACE,QACzBE,MAAM,WAAW,CAACE,MAAML,iBAAiBC,QAAQE,MAAM,mBAAmB,CAACE;IAC/E;AACF;AAEA,SAASC,aAAaC,KAAk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AA,QAAUhE,MAAM;YAInCA;QAHA,MAAMkC,OAAOuB;QACb,IAAIvB,KAAK,KAAK,KAAK6B,KAAK,KAAK,IAAI7B,KAAK,MAAM,KAAK6B,KAAK,MAAM,EAAE;QAC9DA,OAAO7B;gBACPlC,CAAAA,wBAAAA,KAAK,eAAe,AAAD,KAAnBA,sBAAAA,IAAAA,CAAAA,MAAuB,kBAAkB;YAACkC,KAAK,KAAK;YAAEA,KAAK,MAAM;SAAC;IACpE;IACA,OAAO;YACLlC;gBAAAA,CAAAA,4BAAAA,KAAK,mBAAmB,AAAD,KAAvBA,0BAAAA,IAAAA,CAAAA,MAA2B,SAASmD;QACpCP,QAAAA,eAAAA;QACA,IAAIC,WAAW7C,KAAK,YAAY,GAAG6C;aAC9B,OAAO7C,KAAK,YAAY;QAC7BiE,QAAAA,gBAAAA;QACAZ,QAAAA,WAAAA,QAAS,mBAAmB,CAAC,UAAU7G;QACvCwD,KAAK,gBAAgB,GAAGuC;QACxBvC,KAAK,mBAAmB,GAAGwC;QAC3BxC,KAAK,aAAa,GAAG4D;QACrB5D,KAAK,gBAAgB,GAAG2C;IAC1B;AACF"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type Reply = (envelope: unknown) => void;
|
|
2
|
+
type Call = (name: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
3
|
+
/** The G9HostModule a web page provides (the same methods as the Android and iOS hosts). */
|
|
4
|
+
export interface G9WebHostModule {
|
|
5
|
+
capabilities(callback: Reply): void;
|
|
6
|
+
getPreference(key: string, callback: Reply): void;
|
|
7
|
+
setPreference(key: string, kind: string, value: string | null, callback: Reply): void;
|
|
8
|
+
preferenceEntries(prefix: string, callback: Reply): void;
|
|
9
|
+
safeInsets(callback: Reply): void;
|
|
10
|
+
moveToBack(): void;
|
|
11
|
+
hideKeyboard(): void;
|
|
12
|
+
setSoftInputMode(mode: string): void;
|
|
13
|
+
hapticTick(): void;
|
|
14
|
+
appDataDirectory(callback: Reply): void;
|
|
15
|
+
assetUri(path: string, callback: Reply): void;
|
|
16
|
+
/** G9AppPilot's watch hands its findings to the page (LC-08; @g9tm/lynxcontrols-pilot, profile `observe` and up). */
|
|
17
|
+
pilotFindings(payload: string): void;
|
|
18
|
+
}
|
|
19
|
+
/** The factory Lynx for Web calls with `(nativeModules, nativeModulesCall)`; returns the module. */
|
|
20
|
+
export default function createG9WebHostModule(_nativeModules: unknown, call: Call): G9WebHostModule;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAMA,KAAK,KAAK,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;AACzC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9E,4FAA4F;AAC5F,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IACpC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IAClD,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IACtF,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IACzD,UAAU,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IAClC,UAAU,IAAI,IAAI,CAAC;IACnB,YAAY,IAAI,IAAI,CAAC;IACrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,UAAU,IAAI,IAAI,CAAC;IACnB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IAC9C,qHAAqH;IACrH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAWD,oGAAoG;AACpG,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,eAAe,CAqBlG"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const lost = (error)=>({
|
|
2
|
+
ok: false,
|
|
3
|
+
error: {
|
|
4
|
+
code: 'host-unreachable',
|
|
5
|
+
message: `The page did not answer: ${error instanceof Error ? error.message : String(error)}`
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
function createG9WebHostModule(_nativeModules, call) {
|
|
9
|
+
const ask = (name, data, callback)=>{
|
|
10
|
+
call(name, data).then(callback, (error)=>callback(lost(error)));
|
|
11
|
+
};
|
|
12
|
+
const tell = (name, data = {})=>{
|
|
13
|
+
call(name, data).catch(()=>void 0);
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
capabilities: (callback)=>ask('capabilities', {}, callback),
|
|
17
|
+
getPreference: (key, callback)=>ask('getPreference', {
|
|
18
|
+
key
|
|
19
|
+
}, callback),
|
|
20
|
+
setPreference: (key, kind, value, callback)=>ask('setPreference', {
|
|
21
|
+
key,
|
|
22
|
+
kind,
|
|
23
|
+
value
|
|
24
|
+
}, callback),
|
|
25
|
+
preferenceEntries: (prefix, callback)=>ask('preferenceEntries', {
|
|
26
|
+
prefix
|
|
27
|
+
}, callback),
|
|
28
|
+
safeInsets: (callback)=>ask('safeInsets', {}, callback),
|
|
29
|
+
moveToBack: ()=>tell('moveToBack'),
|
|
30
|
+
hideKeyboard: ()=>tell('hideKeyboard'),
|
|
31
|
+
setSoftInputMode: (mode)=>tell('setSoftInputMode', {
|
|
32
|
+
mode
|
|
33
|
+
}),
|
|
34
|
+
hapticTick: ()=>tell('hapticTick'),
|
|
35
|
+
appDataDirectory: (callback)=>ask('appDataDirectory', {}, callback),
|
|
36
|
+
assetUri: (path, callback)=>ask('assetUri', {
|
|
37
|
+
path
|
|
38
|
+
}, callback),
|
|
39
|
+
pilotFindings: (payload)=>tell('pilotFindings', {
|
|
40
|
+
payload
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export default createG9WebHostModule;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../src/module.ts"],"sourcesContent":["// The worker side of `G9HostModule` on the web: Lynx for Web runs the page's code in a Web Worker and builds\n// `NativeModules` there, loading each custom module from the URL its `<lynx-view>` names in `nativeModulesMap`. This\n// module's default export is that factory: every method sends its call to the page (`nativeModulesCall`), where\n// installG9WebHost answers it (./handler.ts), and hands the envelope back to the callback — so\n// @g9tm/lynxcontrols-native's createNativeHostServices finds `NativeModules.G9HostModule` and works unchanged.\n\ntype Reply = (envelope: unknown) => void;\ntype Call = (name: string, data: Record<string, unknown>) => Promise<unknown>;\n\n/** The G9HostModule a web page provides (the same methods as the Android and iOS hosts). */\nexport interface G9WebHostModule {\n capabilities(callback: Reply): void;\n getPreference(key: string, callback: Reply): void;\n setPreference(key: string, kind: string, value: string | null, callback: Reply): void;\n preferenceEntries(prefix: string, callback: Reply): void;\n safeInsets(callback: Reply): void;\n moveToBack(): void;\n hideKeyboard(): void;\n setSoftInputMode(mode: string): void;\n hapticTick(): void;\n appDataDirectory(callback: Reply): void;\n assetUri(path: string, callback: Reply): void;\n /** G9AppPilot's watch hands its findings to the page (LC-08; @g9tm/lynxcontrols-pilot, profile `observe` and up). */\n pilotFindings(payload: string): void;\n}\n\n/** A call that failed to cross (the page is gone): the typed error a host sends for a missing answer. */\nconst lost = (error: unknown) => ({\n ok: false,\n error: {\n code: 'host-unreachable',\n message: `The page did not answer: ${error instanceof Error ? error.message : String(error)}`,\n },\n});\n\n/** The factory Lynx for Web calls with `(nativeModules, nativeModulesCall)`; returns the module. */\nexport default function createG9WebHostModule(_nativeModules: unknown, call: Call): G9WebHostModule {\n const ask = (name: string, data: Record<string, unknown>, callback: Reply) => {\n call(name, data).then(callback, (error: unknown) => callback(lost(error)));\n };\n const tell = (name: string, data: Record<string, unknown> = {}) => {\n call(name, data).catch(() => undefined);\n };\n return {\n capabilities: (callback) => ask('capabilities', {}, callback),\n getPreference: (key, callback) => ask('getPreference', { key }, callback),\n setPreference: (key, kind, value, callback) => ask('setPreference', { key, kind, value }, callback),\n preferenceEntries: (prefix, callback) => ask('preferenceEntries', { prefix }, callback),\n safeInsets: (callback) => ask('safeInsets', {}, callback),\n moveToBack: () => tell('moveToBack'),\n hideKeyboard: () => tell('hideKeyboard'),\n setSoftInputMode: (mode) => tell('setSoftInputMode', { mode }),\n hapticTick: () => tell('hapticTick'),\n appDataDirectory: (callback) => ask('appDataDirectory', {}, callback),\n assetUri: (path, callback) => ask('assetUri', { path }, callback),\n pilotFindings: (payload) => tell('pilotFindings', { payload }),\n };\n}\n"],"names":["lost","error","Error","String","createG9WebHostModule","_nativeModules","call","ask","name","data","callback","tell","undefined","key","kind","value","prefix","mode","path","payload"],"mappings":"AA2BA,MAAMA,OAAO,CAACC,QAAoB;QAChC,IAAI;QACJ,OAAO;YACL,MAAM;YACN,SAAS,CAAC,yBAAyB,EAAEA,iBAAiBC,QAAQD,MAAM,OAAO,GAAGE,OAAOF,QAAQ;QAC/F;IACF;AAGe,SAASG,sBAAsBC,cAAuB,EAAEC,IAAU;IAC/E,MAAMC,MAAM,CAACC,MAAcC,MAA+BC;QACxDJ,KAAKE,MAAMC,MAAM,IAAI,CAACC,UAAU,CAACT,QAAmBS,SAASV,KAAKC;IACpE;IACA,MAAMU,OAAO,CAACH,MAAcC,OAAgC,CAAC,CAAC;QAC5DH,KAAKE,MAAMC,MAAM,KAAK,CAAC,IAAMG;IAC/B;IACA,OAAO;QACL,cAAc,CAACF,WAAaH,IAAI,gBAAgB,CAAC,GAAGG;QACpD,eAAe,CAACG,KAAKH,WAAaH,IAAI,iBAAiB;gBAAEM;YAAI,GAAGH;QAChE,eAAe,CAACG,KAAKC,MAAMC,OAAOL,WAAaH,IAAI,iBAAiB;gBAAEM;gBAAKC;gBAAMC;YAAM,GAAGL;QAC1F,mBAAmB,CAACM,QAAQN,WAAaH,IAAI,qBAAqB;gBAAES;YAAO,GAAGN;QAC9E,YAAY,CAACA,WAAaH,IAAI,cAAc,CAAC,GAAGG;QAChD,YAAY,IAAMC,KAAK;QACvB,cAAc,IAAMA,KAAK;QACzB,kBAAkB,CAACM,OAASN,KAAK,oBAAoB;gBAAEM;YAAK;QAC5D,YAAY,IAAMN,KAAK;QACvB,kBAAkB,CAACD,WAAaH,IAAI,oBAAoB,CAAC,GAAGG;QAC5D,UAAU,CAACQ,MAAMR,WAAaH,IAAI,YAAY;gBAAEW;YAAK,GAAGR;QACxD,eAAe,CAACS,UAAYR,KAAK,iBAAiB;gBAAEQ;YAAQ;IAC9D;AACF"}
|
package/dist/static.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type G9ShapeSet, toRootCssVariables } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
/** The meaning of a coloured element (`g9s-tone-<tone>`), as the controls' `G9Tone`. */
|
|
3
|
+
export type G9StaticTone = 'neutral' | 'primary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
4
|
+
/** Every tone (`g9s-tone-<tone>`). */
|
|
5
|
+
export declare const g9StaticTones: readonly G9StaticTone[];
|
|
6
|
+
/** A theme as the variables need it: what `resolveTheme` returns, or any `{ palette, scheme }`. */
|
|
7
|
+
export interface G9StaticTheme {
|
|
8
|
+
readonly palette: Parameters<typeof toRootCssVariables>[0]['palette'];
|
|
9
|
+
readonly scheme: 'light' | 'dark';
|
|
10
|
+
}
|
|
11
|
+
/** Options of {@link g9StaticVariables}. */
|
|
12
|
+
export interface G9StaticVariablesOptions {
|
|
13
|
+
/** Default: the stock light theme (`resolveTheme({ mode: 'light' })`). */
|
|
14
|
+
readonly theme?: G9StaticTheme;
|
|
15
|
+
/** Default `g9DefaultShape` (a `resolveShape(...)` result for a theme's own radii, type, density or fonts). */
|
|
16
|
+
readonly shape?: G9ShapeSet;
|
|
17
|
+
/** The page's direction: picks `--g9-font-text` from the shape's fonts. Default `'ltr'`. */
|
|
18
|
+
readonly direction?: 'ltr' | 'rtl';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The CSS variables the root of a static page carries (`<body class="g9s" style="…">` or a `.g9s` element): every
|
|
22
|
+
* variable a `G9Provider` root writes (`toRootCssVariables`), plus the progress fills' second stops, which the Lynx
|
|
23
|
+
* control computes from the palette (a colour 24 % lighter: `--g9s-progress-<type>-to`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function g9StaticVariables(options?: G9StaticVariablesOptions): Readonly<Record<string, string>>;
|
|
26
|
+
/** {@link g9StaticVariables} as a `style` attribute's text (`--g9-primary:#…;--g9-…`). */
|
|
27
|
+
export declare function g9StaticRootStyle(options?: G9StaticVariablesOptions): string;
|
|
28
|
+
/** The avatar's tone for a name, as `G9Avatar` picks it (the same person always gets the same colour). */
|
|
29
|
+
export declare function g9StaticAvatarTone(name: string): G9StaticTone;
|
|
30
|
+
/** The avatar's initials, as `G9Avatar` draws them (two at most; Persian and Arabic kept apart by a ZWNJ). */
|
|
31
|
+
export declare function g9StaticInitials(name: string | null | undefined, max?: number): string;
|
|
32
|
+
/** The avatar sizes (`g9s-avatar--<size>`), dp, as `G9Avatar`'s. */
|
|
33
|
+
export declare const g9StaticAvatarSizes: Readonly<{
|
|
34
|
+
xs: 24;
|
|
35
|
+
sm: 32;
|
|
36
|
+
md: 44;
|
|
37
|
+
lg: 64;
|
|
38
|
+
xl: 88;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* The stylesheet of the contract (one string; write it to `site.css` or a `<style>`). Every rule is scoped under
|
|
42
|
+
* `.g9s`, uses logical properties (one sheet for both directions) and reads only `--g9-*` / `--g9s-*` variables, so a
|
|
43
|
+
* theme change is a new root style, never new rules.
|
|
44
|
+
*/
|
|
45
|
+
export declare function g9StaticStylesheet(): string;
|
|
46
|
+
/** {@link g9StaticStylesheet}, built once. */
|
|
47
|
+
export declare const G9_STATIC_CSS: string;
|
|
48
|
+
/** One component of the contract: its name in a design, the control it stands for, its root class. */
|
|
49
|
+
export interface G9StaticComponent {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/** The Lynx control (export of `@g9tm/lynxcontrols`), or null for a composition of them. */
|
|
52
|
+
readonly control: string | null;
|
|
53
|
+
readonly root: string;
|
|
54
|
+
}
|
|
55
|
+
/** The components of the contract (docs/static-render.md has each one's HTML). */
|
|
56
|
+
export declare const G9_STATIC_COMPONENTS: readonly G9StaticComponent[];
|
|
57
|
+
//# sourceMappingURL=static.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,UAAU,EAQf,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AAGvC,wFAAwF;AACxF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEvG,sCAAsC;AACtC,eAAO,MAAM,aAAa,EAAE,SAAS,YAAY,EAQhD,CAAC;AAEF,mGAAmG;AACnG,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACtE,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAA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Color, g9DefaultShape, g9Derived, lighten, resolveButtonVariantVars, resolveProgressColor, resolveTheme, toKebabCase, toRootCssVariables } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
import { G9_WEB_FONT_STACK } from "./font.js";
|
|
3
|
+
const g9StaticTones = [
|
|
4
|
+
'neutral',
|
|
5
|
+
'primary',
|
|
6
|
+
'accent',
|
|
7
|
+
'info',
|
|
8
|
+
'success',
|
|
9
|
+
'warning',
|
|
10
|
+
'error'
|
|
11
|
+
];
|
|
12
|
+
const PROGRESS_TYPES = Object.values(G9ProgressType);
|
|
13
|
+
function g9StaticVariables(options = {}) {
|
|
14
|
+
var _options_theme, _options_shape, _options_direction;
|
|
15
|
+
const theme = null != (_options_theme = options.theme) ? _options_theme : resolveTheme({
|
|
16
|
+
mode: 'light'
|
|
17
|
+
});
|
|
18
|
+
const out = {
|
|
19
|
+
...toRootCssVariables(theme, null != (_options_shape = options.shape) ? _options_shape : g9DefaultShape, null != (_options_direction = options.direction) ? _options_direction : 'ltr')
|
|
20
|
+
};
|
|
21
|
+
for (const type of PROGRESS_TYPES){
|
|
22
|
+
const color = resolveProgressColor(type, theme.palette);
|
|
23
|
+
out[`--g9s-progress-${type}`] = color;
|
|
24
|
+
out[`--g9s-progress-${type}-to`] = formatColor(lighten(color, 0.24));
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
function g9StaticRootStyle(options = {}) {
|
|
29
|
+
return Object.entries(g9StaticVariables(options)).map(([name, value])=>`${name}:${value}`).join(';');
|
|
30
|
+
}
|
|
31
|
+
function g9StaticAvatarTone(name) {
|
|
32
|
+
var _ch_codePointAt;
|
|
33
|
+
const tones = [
|
|
34
|
+
'primary',
|
|
35
|
+
'accent',
|
|
36
|
+
'info',
|
|
37
|
+
'success',
|
|
38
|
+
'warning'
|
|
39
|
+
];
|
|
40
|
+
let h = 0;
|
|
41
|
+
for (const ch of name)h = 31 * h + (null != (_ch_codePointAt = ch.codePointAt(0)) ? _ch_codePointAt : 0) >>> 0;
|
|
42
|
+
return tones[h % tones.length];
|
|
43
|
+
}
|
|
44
|
+
function g9StaticInitials(name, max = 2) {
|
|
45
|
+
var _Array_from_, _Array_from_1;
|
|
46
|
+
const words = (null != name ? name : '').trim().split(/\s+/).filter(Boolean);
|
|
47
|
+
if (0 === words.length) return '?';
|
|
48
|
+
const first = null != (_Array_from_ = Array.from(words[0])[0]) ? _Array_from_ : '';
|
|
49
|
+
const last = words.length > 1 && max > 1 ? null != (_Array_from_1 = Array.from(words[words.length - 1])[0]) ? _Array_from_1 : '' : '';
|
|
50
|
+
const joiner = /[-ۿ]/.test(first + last) ? '' : '';
|
|
51
|
+
return (first + joiner + last).toUpperCase();
|
|
52
|
+
}
|
|
53
|
+
const g9StaticAvatarSizes = Object.freeze({
|
|
54
|
+
xs: 24,
|
|
55
|
+
sm: 32,
|
|
56
|
+
md: 44,
|
|
57
|
+
lg: 64,
|
|
58
|
+
xl: 88
|
|
59
|
+
});
|
|
60
|
+
const v = (token)=>`var(--g9-${toKebabCase(token)})`;
|
|
61
|
+
const ROLE = {
|
|
62
|
+
primary: 'Primary',
|
|
63
|
+
accent: 'Tertiary',
|
|
64
|
+
info: 'Info',
|
|
65
|
+
success: 'Success',
|
|
66
|
+
warning: 'Warning',
|
|
67
|
+
error: 'Error'
|
|
68
|
+
};
|
|
69
|
+
function toneVars(tone) {
|
|
70
|
+
if ('neutral' === tone) return [
|
|
71
|
+
`--g9s-soft-bg:${v('SurfaceContainerHigh')}`,
|
|
72
|
+
`--g9s-soft-fg:${v('TextSecondary')}`,
|
|
73
|
+
`--g9s-solid-bg:${v('InverseSurface')}`,
|
|
74
|
+
`--g9s-solid-fg:${v('InverseOnSurface')}`,
|
|
75
|
+
`--g9s-outline-fg:${v('TextSecondary')}`,
|
|
76
|
+
`--g9s-outline-border:${v('Outline')}`
|
|
77
|
+
].join(';');
|
|
78
|
+
const r = ROLE[tone];
|
|
79
|
+
return [
|
|
80
|
+
`--g9s-soft-bg:${v(`${r}Container`)}`,
|
|
81
|
+
`--g9s-soft-fg:${v(`On${r}Container`)}`,
|
|
82
|
+
`--g9s-solid-bg:${v(r)}`,
|
|
83
|
+
`--g9s-solid-fg:${v(`On${r}`)}`,
|
|
84
|
+
`--g9s-outline-fg:${v(r)}`,
|
|
85
|
+
`--g9s-outline-border:${v(`${r}Border`)}`
|
|
86
|
+
].join(';');
|
|
87
|
+
}
|
|
88
|
+
const BUTTON_SIZES = [
|
|
89
|
+
[
|
|
90
|
+
'small',
|
|
91
|
+
G9Metrics.ButtonHeightSmall,
|
|
92
|
+
12,
|
|
93
|
+
G9Metrics.ButtonFontSmall
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
'medium',
|
|
97
|
+
G9Metrics.ButtonHeightMedium,
|
|
98
|
+
16,
|
|
99
|
+
G9Metrics.ButtonFontMedium
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
'large',
|
|
103
|
+
G9Metrics.ButtonHeightLarge,
|
|
104
|
+
20,
|
|
105
|
+
G9Metrics.ButtonFontLarge
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
'hero',
|
|
109
|
+
G9Metrics.ButtonHeightHero,
|
|
110
|
+
16,
|
|
111
|
+
G9Metrics.ButtonFontHero
|
|
112
|
+
]
|
|
113
|
+
];
|
|
114
|
+
const VARIANTS = Object.values(G9ButtonVariant);
|
|
115
|
+
function buttonRules() {
|
|
116
|
+
const out = [];
|
|
117
|
+
for (const [size, height, pad, font] of BUTTON_SIZES)out.push(`.g9s-button--${size}{block-size:${height}px;padding-inline:${pad}px;font-size:${font}px}`);
|
|
118
|
+
for (const variant of VARIANTS){
|
|
119
|
+
const p = resolveButtonVariantVars(variant);
|
|
120
|
+
out.push(`.g9s-button--v-${variant}{${variantDeclarations(variant, 'button')}}`, `.g9s-icon-button--v-${variant}{${variantDeclarations(variant, 'icon')}}`);
|
|
121
|
+
if (p.gradient) out.push(`.g9s-button--v-${variant}:is(.g9s-button--flat,[disabled],[aria-disabled=true],[aria-busy=true]),.g9s-icon-button--v-${variant}:is([disabled],[aria-disabled=true],[aria-busy=true]){background:${p.background}}`);
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
function variantDeclarations(variant, kind) {
|
|
126
|
+
const p = resolveButtonVariantVars(variant);
|
|
127
|
+
const outlined = 'outline' === variant || 'text' === variant || 'button' === kind && 'tonal' === variant;
|
|
128
|
+
const fill = p.gradient ? g9Derived.gradient(p.gradient) : p.background;
|
|
129
|
+
return `background:${fill};border-color:${p.stroke};border-width:${outlined ? 1.5 : 0}px;color:${p.text}`;
|
|
130
|
+
}
|
|
131
|
+
function typeRules(shape) {
|
|
132
|
+
return Object.keys(shape.type).map((role)=>`.g9s-text--${role}{font-size:var(--g9-type-${role}-size);line-height:var(--g9-type-${role}-line);font-weight:var(--g9-type-${role}-weight)}`);
|
|
133
|
+
}
|
|
134
|
+
function avatarRules() {
|
|
135
|
+
return Object.entries(g9StaticAvatarSizes).map(([size, px])=>`.g9s-avatar--${size}{inline-size:${px}px;block-size:${px}px;font-size:${Math.round(0.38 * px)}px}.g9s-avatar--${size} .g9s-avatar__status{inline-size:${Math.max(8, px / 4)}px;block-size:${Math.max(8, px / 4)}px}`);
|
|
136
|
+
}
|
|
137
|
+
function progressRules() {
|
|
138
|
+
return PROGRESS_TYPES.map((type)=>`.g9s-progress--${type}{--g9s-progress-color:var(--g9s-progress-${type});--g9s-progress-end:var(--g9s-progress-${type}-to)}`);
|
|
139
|
+
}
|
|
140
|
+
function g9StaticStylesheet() {
|
|
141
|
+
const base = [
|
|
142
|
+
`.g9s{color:var(--g9-text-primary);background-color:var(--g9-background);font-family:var(--g9-font-text,${G9_WEB_FONT_STACK});font-size:14px;line-height:normal;-webkit-text-size-adjust:100%;text-size-adjust:100%}`,
|
|
143
|
+
'.g9s *,.g9s *::before,.g9s *::after{box-sizing:border-box}',
|
|
144
|
+
'.g9s :where(h1,h2,h3,h4,h5,h6,p,figure,figcaption,ul,ol,li,dl,dd,hr,blockquote){margin:0;padding:0}',
|
|
145
|
+
'.g9s :where(ul,ol){list-style:none}',
|
|
146
|
+
'.g9s :where(h1,h2,h3,h4,h5,h6){font-size:inherit;font-weight:inherit}',
|
|
147
|
+
'.g9s :where(a){color:inherit;text-decoration:none}',
|
|
148
|
+
'.g9s :where(button){font:inherit;color:inherit;background:none;border:0 solid transparent;padding:0;margin:0;cursor:pointer;text-align:inherit}',
|
|
149
|
+
'.g9s :where(img,svg,video){display:block;max-inline-size:100%}',
|
|
150
|
+
'.g9s :where(p,span,strong,b,em,small,h1,h2,h3,h4,h5,h6,a,button,li,dt,dd,figcaption,label,time,output){unicode-bidi:plaintext}',
|
|
151
|
+
'.g9s :where(:focus-visible){outline:2px solid var(--g9-primary);outline-offset:2px}',
|
|
152
|
+
'.g9s-icon{inline-size:20px;block-size:20px;flex:none;fill:none;stroke:currentColor}',
|
|
153
|
+
'.g9s-icon--fill{fill:currentColor;stroke:none}',
|
|
154
|
+
'[dir=rtl] .g9s-icon--mirror,.g9s[dir=rtl] .g9s-icon--mirror{transform:scaleX(-1)}',
|
|
155
|
+
'.g9s-document{min-block-size:100vh;min-block-size:100dvh;display:flex;flex-direction:column}',
|
|
156
|
+
'.g9s-document__main{flex:1 0 auto;display:flex;flex-direction:column}',
|
|
157
|
+
'.g9s-sr-only{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}'
|
|
158
|
+
];
|
|
159
|
+
const text = [
|
|
160
|
+
'.g9s-text{overflow-wrap:break-word}',
|
|
161
|
+
...typeRules(g9DefaultShape),
|
|
162
|
+
'.g9s-text--primary{color:var(--g9-text-primary)}.g9s-text--secondary{color:var(--g9-text-secondary)}.g9s-text--tertiary{color:var(--g9-text-tertiary)}',
|
|
163
|
+
'.g9s-text--accent{color:var(--g9-primary)}.g9s-text--success{color:var(--g9-success)}.g9s-text--warning{color:var(--g9-warning)}.g9s-text--error{color:var(--g9-error)}',
|
|
164
|
+
'.g9s-text--start{text-align:start}.g9s-text--center{text-align:center}.g9s-text--end{text-align:end}',
|
|
165
|
+
'.g9s-text--bold{font-weight:700}.g9s-text--nowrap{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
166
|
+
'.g9s-text--tabular{font-variant-numeric:tabular-nums}'
|
|
167
|
+
];
|
|
168
|
+
const image = [
|
|
169
|
+
'.g9s-image{display:block;position:relative;overflow:hidden;inline-size:100%;background-color:var(--g9-primary-container)}',
|
|
170
|
+
'.g9s-image>img,img.g9s-image{inline-size:100%;block-size:100%;object-fit:cover}',
|
|
171
|
+
'.g9s-image--contain>img,img.g9s-image--contain{object-fit:contain}',
|
|
172
|
+
'.g9s-image--stretch>img,img.g9s-image--stretch{object-fit:fill}'
|
|
173
|
+
];
|
|
174
|
+
const button = [
|
|
175
|
+
`.g9s-button{display:inline-flex;flex-direction:row;align-items:center;justify-content:center;column-gap:8px;flex:none;block-size:${G9Metrics.ButtonHeightMedium}px;padding-block:0;padding-inline:16px;border-style:solid;border-width:0;border-radius:var(--g9-radius-control,12px);overflow:hidden;font-size:${G9Metrics.ButtonFontMedium}px;font-weight:700;line-height:normal;white-space:nowrap;text-align:center;vertical-align:middle;cursor:pointer;${variantDeclarations('primary', 'button')}}`,
|
|
176
|
+
`.g9s-button:where(.g9s-button--flat,[disabled],[aria-disabled=true],[aria-busy=true]){background:${resolveButtonVariantVars('primary').background}}`,
|
|
177
|
+
'.g9s-button__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
178
|
+
'.g9s-button .g9s-icon{inline-size:20px;block-size:20px}',
|
|
179
|
+
'.g9s-button--block,.g9s-button--hero{display:flex;inline-size:100%;align-self:stretch}',
|
|
180
|
+
...buttonRules().filter((r)=>r.startsWith('.g9s-button')),
|
|
181
|
+
'.g9s-button--pill{border-radius:9999px}',
|
|
182
|
+
'.g9s-button:is([disabled],[aria-disabled=true]){opacity:0.38;cursor:default}',
|
|
183
|
+
'.g9s-button[aria-busy=true]{opacity:0.7}',
|
|
184
|
+
`.g9s-icon-button{display:inline-flex;align-items:center;justify-content:center;flex:none;inline-size:40px;block-size:40px;border-style:solid;border-width:0;border-radius:var(--g9-radius-control,${G9Metrics.RadiusMd}px);cursor:pointer;${variantDeclarations('surface', 'icon')}}`,
|
|
185
|
+
...buttonRules().filter((r)=>r.startsWith('.g9s-icon-button')),
|
|
186
|
+
'.g9s-icon-button--ghost{background:transparent;border-color:transparent;border-width:0}',
|
|
187
|
+
'.g9s-icon-button--circle{border-radius:9999px}',
|
|
188
|
+
'.g9s-icon-button:is([disabled],[aria-disabled=true]){opacity:0.38;cursor:default}'
|
|
189
|
+
];
|
|
190
|
+
const containers = [
|
|
191
|
+
'.g9s-card{display:flex;flex-direction:column;position:relative;padding:16px;border-radius:var(--g9-radius-card);overflow:hidden;background-color:var(--g9-card-background);border:1px solid var(--g9-card-border);min-inline-size:0}',
|
|
192
|
+
'.g9s-card--filled{background-color:var(--g9-surface-container);border-width:0}',
|
|
193
|
+
'.g9s-card--elevated{background-color:var(--g9-card-elevated);border-color:var(--g9-outline-variant)}',
|
|
194
|
+
'.g9s-card--glass{background-color:var(--g9-overlay-light);border-color:var(--g9-outline-variant)}',
|
|
195
|
+
'.g9s-card__edge{position:absolute;inset-block:0;inset-inline-start:0;inline-size:3px}',
|
|
196
|
+
'a.g9s-card,.g9s-card--link{cursor:pointer}',
|
|
197
|
+
'.g9s-section{display:flex;flex-direction:column;row-gap:12px;min-inline-size:0}',
|
|
198
|
+
'.g9s-section--card{padding:16px;border-radius:var(--g9-radius-card);background-color:var(--g9-card-background);border:1px solid var(--g9-card-border)}',
|
|
199
|
+
'.g9s-section__header{display:flex;flex-direction:row;align-items:center;column-gap:10px;min-block-size:32px}',
|
|
200
|
+
'.g9s-section__icon{display:flex;align-items:center;justify-content:center;flex:none;inline-size:32px;block-size:32px;border-radius:10px;background-color:var(--g9-primary-container);color:var(--g9-on-primary-container)}',
|
|
201
|
+
'.g9s-section__icon .g9s-icon{inline-size:16px;block-size:16px}',
|
|
202
|
+
'.g9s-section__titles{display:flex;flex-direction:column;flex:1 1 0;min-inline-size:0}',
|
|
203
|
+
'.g9s-section__title{font-size:var(--g9-type-section-size);line-height:var(--g9-type-section-line);font-weight:700;color:var(--g9-text-primary)}',
|
|
204
|
+
'.g9s-section__subtitle{font-size:12px;line-height:20px;color:var(--g9-text-secondary)}',
|
|
205
|
+
'.g9s-section__action{display:flex;align-items:center;justify-content:center;min-block-size:32px;padding:0 6px;font-size:13px;font-weight:700;color:var(--g9-primary)}',
|
|
206
|
+
'.g9s-section__body{display:flex;flex-direction:column}'
|
|
207
|
+
];
|
|
208
|
+
const list = [
|
|
209
|
+
`.g9s-list-row{display:flex;flex-direction:row;align-items:center;position:relative;column-gap:12px;min-block-size:56px;padding:8px 16px;background-color:var(--g9-surface);border-block-end:1px solid var(--g9-divider);color:inherit;${toneVars('neutral')}}`,
|
|
210
|
+
'.g9s-list-row--plain{border-block-end-width:0}',
|
|
211
|
+
'a.g9s-list-row,.g9s-list-row--link{cursor:pointer}',
|
|
212
|
+
'.g9s-list-row__edge{position:absolute;inset-block:0;inset-inline-start:0;inline-size:3px}',
|
|
213
|
+
'.g9s-list-row__icon{display:flex;align-items:center;justify-content:center;flex:none;inline-size:36px;block-size:36px;border-radius:11px;background-color:var(--g9s-soft-bg);color:var(--g9s-soft-fg)}',
|
|
214
|
+
'.g9s-list-row__icon .g9s-icon{inline-size:18px;block-size:18px}',
|
|
215
|
+
'.g9s-list-row__leading{flex:none}',
|
|
216
|
+
'.g9s-list-row__text{display:flex;flex-direction:column;flex:1 1 0;min-inline-size:0}',
|
|
217
|
+
'.g9s-list-row__title{font-size:15px;line-height:24px;color:var(--g9-text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
218
|
+
'.g9s-list-row__title--strong{font-size:14px;line-height:21px;font-weight:700}',
|
|
219
|
+
'.g9s-list-row__title--danger{color:var(--g9-error)}',
|
|
220
|
+
'.g9s-list-row__subtitle{font-size:12px;line-height:19px;color:var(--g9-text-secondary);display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}',
|
|
221
|
+
'.g9s-list-row__hint{font-size:11px;line-height:16px;color:var(--g9-text-tertiary);margin-block-start:2px}',
|
|
222
|
+
'.g9s-list-row__value{flex:none;max-inline-size:45%;font-size:14px;color:var(--g9-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
223
|
+
'.g9s-list-row__chevron{flex:none;inline-size:18px;block-size:18px;color:var(--g9-text-tertiary)}',
|
|
224
|
+
'[dir=rtl] .g9s-list-row__chevron{transform:scaleX(-1)}'
|
|
225
|
+
];
|
|
226
|
+
const bars = [
|
|
227
|
+
'.g9s-app-bar{display:flex;flex-direction:column;flex:none;background-color:var(--g9-surface);border-block-end:1px solid var(--g9-divider)}',
|
|
228
|
+
'.g9s-app-bar--transparent{background-color:transparent;border-block-end-color:transparent}',
|
|
229
|
+
'.g9s-app-bar--sticky{position:sticky;inset-block-start:0;z-index:3}',
|
|
230
|
+
'.g9s-app-bar__row{display:flex;flex-direction:row;align-items:center;block-size:56px;padding:0 8px;column-gap:4px}',
|
|
231
|
+
'.g9s-app-bar__row>.g9s-icon-button{margin:2px}',
|
|
232
|
+
'.g9s-app-bar__titles{display:flex;flex-direction:column;flex:1 1 0;min-inline-size:0;padding:0 8px}',
|
|
233
|
+
'.g9s-app-bar__titles--center{align-items:center;text-align:center}',
|
|
234
|
+
'.g9s-app-bar__title{font-size:var(--g9-type-title-size);line-height:var(--g9-type-title-line);font-weight:700;color:var(--g9-text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
235
|
+
'.g9s-app-bar__subtitle{font-size:12px;line-height:18px;color:var(--g9-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
236
|
+
'.g9s-app-bar__spacer{flex:1 1 0}',
|
|
237
|
+
'.g9s-app-bar__actions{display:flex;flex-direction:row;align-items:center;column-gap:2px}',
|
|
238
|
+
'.g9s-app-bar__large-block{display:flex;flex-direction:column;padding:0 16px 12px 16px}',
|
|
239
|
+
'.g9s-app-bar__large{font-size:var(--g9-type-display-size);line-height:var(--g9-type-display-line);font-weight:800;color:var(--g9-text-primary)}',
|
|
240
|
+
'.g9s-app-bar__large-subtitle{margin-block-start:2px;font-size:13px;line-height:19px;color:var(--g9-text-secondary)}',
|
|
241
|
+
'.g9s-tab-bar{flex:none;padding:14px}',
|
|
242
|
+
'.g9s-tab-bar--sticky{position:sticky;inset-block-end:0;z-index:3}',
|
|
243
|
+
'.g9s-tab-bar__items{display:flex;flex-direction:row;block-size:62px;border-radius:18px;background-color:var(--g9-surface-container-high);border:1px solid var(--g9-outline-variant);overflow:hidden}',
|
|
244
|
+
'.g9s-tab-bar__item{position:relative;isolation:isolate;display:flex;flex-direction:column;align-items:center;justify-content:center;row-gap:3px;flex:1 1 0;min-inline-size:0;padding:0 6px;color:var(--g9-on-surface-variant)}',
|
|
245
|
+
'.g9s-tab-bar__item .g9s-icon{inline-size:24px;block-size:24px}',
|
|
246
|
+
'.g9s-tab-bar__label{max-inline-size:86px;font-size:11px;font-weight:400;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
247
|
+
'.g9s-tab-bar__item:is([aria-current],.g9s-tab-bar__item--selected){color:var(--g9-on-primary-container)}',
|
|
248
|
+
'.g9s-tab-bar__item:is([aria-current],.g9s-tab-bar__item--selected) .g9s-tab-bar__label{font-weight:700}',
|
|
249
|
+
'.g9s-tab-bar__item:is([aria-current],.g9s-tab-bar__item--selected)::before{content:"";position:absolute;z-index:-1;inset-block-start:8px;inset-inline-start:50%;inline-size:48px;block-size:32px;margin-inline-start:-24px;border-radius:13px;background-color:var(--g9-primary-container)}'
|
|
250
|
+
];
|
|
251
|
+
const figures = [
|
|
252
|
+
'.g9s-stat{display:flex;flex-direction:column;row-gap:6px;min-inline-size:0;padding:14px 16px;border-radius:var(--g9-radius-card);background-color:var(--g9-card-background);border:1px solid var(--g9-card-border)}',
|
|
253
|
+
`.g9s-stat{${toneVars('primary')}}`,
|
|
254
|
+
'.g9s-stat__head{display:flex;flex-direction:row;align-items:center;justify-content:space-between;column-gap:8px}',
|
|
255
|
+
'.g9s-stat__label{flex:1 1 0;min-inline-size:0;font-size:12px;color:var(--g9-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
256
|
+
'.g9s-stat__icon{display:flex;align-items:center;justify-content:center;flex:none;inline-size:28px;block-size:28px;border-radius:9px;background-color:var(--g9s-soft-bg);color:var(--g9s-soft-fg)}',
|
|
257
|
+
'.g9s-stat__icon .g9s-icon{inline-size:16px;block-size:16px}',
|
|
258
|
+
'.g9s-stat__value{font-size:22px;line-height:32px;font-weight:800;color:var(--g9-text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}',
|
|
259
|
+
'.g9s-stat__foot{display:flex;flex-direction:row;align-items:center;column-gap:6px}',
|
|
260
|
+
'.g9s-stat__note{flex:1 1 0;min-inline-size:0;font-size:11px;color:var(--g9-text-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
261
|
+
'.g9s-delta{display:inline-flex;flex-direction:row;align-items:center;align-self:flex-start;block-size:22px;padding:0 8px;border-radius:11px;background-color:var(--g9s-soft-bg);color:var(--g9s-soft-fg);font-size:12px;font-weight:700;white-space:nowrap}',
|
|
262
|
+
'.g9s-delta--plain{block-size:auto;padding:0;background-color:transparent;color:var(--g9s-outline-fg)}',
|
|
263
|
+
'.g9s-progress{display:flex;flex-direction:column}',
|
|
264
|
+
'.g9s-progress{--g9s-progress-color:var(--g9s-progress-primary);--g9s-progress-end:var(--g9s-progress-primary-to)}',
|
|
265
|
+
...progressRules(),
|
|
266
|
+
'.g9s-progress__label{align-self:flex-end;margin-block-end:6px;font-size:11px;font-weight:700;color:var(--g9s-progress-color)}',
|
|
267
|
+
'.g9s-progress__track{position:relative;direction:ltr;block-size:10px;border-radius:5px;overflow:hidden;background-color:var(--g9-surface-variant)}',
|
|
268
|
+
'.g9s-progress__fill{position:relative;block-size:100%;border-radius:5px;overflow:hidden;background:linear-gradient(to right,var(--g9s-progress-color),var(--g9s-progress-end))}',
|
|
269
|
+
'.g9s-progress__fill::after{content:"";position:absolute;inset:0;background:repeating-linear-gradient(-60deg,rgba(255,255,255,0.16) 0px,rgba(255,255,255,0.16) 5px,transparent 5px,transparent 16px)}',
|
|
270
|
+
'.g9s-progress--paused .g9s-progress__fill::after{content:none}',
|
|
271
|
+
`.g9s-chip{display:inline-flex;flex-direction:row;align-items:center;align-self:flex-start;column-gap:5px;flex:none;block-size:32px;padding-inline:12px;border-radius:16px;border:1px solid var(--g9-surface-container-high);background-color:var(--g9-surface-container-high);color:var(--g9-text-secondary);font-size:13px;font-weight:600;white-space:nowrap;${toneVars('primary')}}`,
|
|
272
|
+
'.g9s-chip .g9s-icon{inline-size:15px;block-size:15px}',
|
|
273
|
+
'.g9s-chip--sm{block-size:26px;border-radius:13px;font-size:12px}.g9s-chip--sm .g9s-icon{inline-size:13px;block-size:13px}',
|
|
274
|
+
'.g9s-chip--lg{block-size:40px;border-radius:20px}',
|
|
275
|
+
'.g9s-chip--outline{background-color:transparent;border-color:var(--g9-outline)}',
|
|
276
|
+
'.g9s-chip--dashed{background-color:transparent;border-style:dashed;border-color:var(--g9-primary);color:var(--g9-primary)}',
|
|
277
|
+
'.g9s-chip:is([aria-pressed=true],[aria-selected=true],[aria-current],.g9s-chip--selected){background-color:var(--g9s-solid-bg);border-color:var(--g9s-solid-bg);border-style:solid;color:var(--g9s-solid-fg)}',
|
|
278
|
+
`.g9s-badge{display:inline-flex;align-items:center;justify-content:center;flex:none;min-inline-size:18px;block-size:18px;padding:0 5px;border-radius:9px;border:1px solid var(--g9s-solid-bg);background-color:var(--g9s-solid-bg);color:var(--g9s-solid-fg);font-size:11px;font-weight:700;line-height:14px;white-space:nowrap;${toneVars('error')}}`,
|
|
279
|
+
'.g9s-badge--soft{border-color:var(--g9s-soft-bg);background-color:var(--g9s-soft-bg);color:var(--g9s-soft-fg)}',
|
|
280
|
+
'.g9s-badge--outline{border-color:var(--g9s-outline-border);background-color:transparent;color:var(--g9s-outline-fg)}',
|
|
281
|
+
'.g9s-badge--dot{min-inline-size:8px;inline-size:8px;block-size:8px;padding:0;border-radius:4px;border-width:0}',
|
|
282
|
+
`.g9s-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:none;inline-size:44px;block-size:44px;border-radius:50%;background-color:var(--g9s-soft-bg);color:var(--g9s-soft-fg);font-size:17px;font-weight:700;${toneVars('primary')}}`,
|
|
283
|
+
'.g9s-avatar__disc{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:50%;overflow:hidden}',
|
|
284
|
+
'.g9s-avatar__image{position:absolute;inset:0;inline-size:100%;block-size:100%;object-fit:cover;border-radius:50%}',
|
|
285
|
+
'.g9s-avatar__status{position:absolute;inset-block-end:0;inset-inline-end:0;inline-size:11px;block-size:11px;border-radius:50%;border:2px solid var(--g9-surface)}',
|
|
286
|
+
...avatarRules(),
|
|
287
|
+
'.g9s-avatar-group{display:flex;flex-direction:row;align-items:center}',
|
|
288
|
+
'.g9s-avatar-group>.g9s-avatar{box-shadow:0 0 0 2px var(--g9-surface)}',
|
|
289
|
+
'.g9s-avatar-group>.g9s-avatar+.g9s-avatar{margin-inline-start:-10px}',
|
|
290
|
+
`.g9s-avatar--more{${toneVars('neutral')}}`,
|
|
291
|
+
'hr.g9s-divider{display:block;block-size:1px;margin:14px 0 8px 0;border:0;background-color:var(--g9-divider)}',
|
|
292
|
+
'div.g9s-divider{display:flex;flex-direction:row;align-items:center;column-gap:10px;padding:14px 0 8px 0}',
|
|
293
|
+
'.g9s-divider__line{flex:1 1 0;block-size:1px;background-color:var(--g9-divider)}',
|
|
294
|
+
'.g9s-divider__title{display:flex;flex-direction:row;align-items:center;column-gap:4px;font-size:10px;font-weight:700;letter-spacing:1.2px;text-transform:uppercase;white-space:nowrap;color:var(--g9-text-tertiary)}',
|
|
295
|
+
'[dir=rtl] .g9s-divider__title{letter-spacing:0}'
|
|
296
|
+
];
|
|
297
|
+
const tones = g9StaticTones.map((tone)=>`.g9s .g9s-tone-${tone}{${toneVars(tone)}}`);
|
|
298
|
+
return `${[
|
|
299
|
+
...base,
|
|
300
|
+
...text,
|
|
301
|
+
...image,
|
|
302
|
+
...button,
|
|
303
|
+
...containers,
|
|
304
|
+
...list,
|
|
305
|
+
...bars,
|
|
306
|
+
...figures,
|
|
307
|
+
...tones
|
|
308
|
+
].join('\n')}\n`;
|
|
309
|
+
}
|
|
310
|
+
const G9_STATIC_CSS = g9StaticStylesheet();
|
|
311
|
+
const G9_STATIC_COMPONENTS = Object.freeze([
|
|
312
|
+
{
|
|
313
|
+
name: 'Text',
|
|
314
|
+
control: null,
|
|
315
|
+
root: 'g9s-text'
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: 'Image',
|
|
319
|
+
control: 'G9Image',
|
|
320
|
+
root: 'g9s-image'
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: 'Button',
|
|
324
|
+
control: 'G9Button',
|
|
325
|
+
root: 'g9s-button'
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'IconButton',
|
|
329
|
+
control: 'G9IconButton',
|
|
330
|
+
root: 'g9s-icon-button'
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'Card',
|
|
334
|
+
control: 'G9Card',
|
|
335
|
+
root: 'g9s-card'
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: 'ListItem',
|
|
339
|
+
control: 'G9ListRow',
|
|
340
|
+
root: 'g9s-list-row'
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: 'AppBar',
|
|
344
|
+
control: 'G9AppBar',
|
|
345
|
+
root: 'g9s-app-bar'
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: 'TabBar',
|
|
349
|
+
control: 'G9TabBar',
|
|
350
|
+
root: 'g9s-tab-bar'
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: 'Section',
|
|
354
|
+
control: 'G9Section',
|
|
355
|
+
root: 'g9s-section'
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: 'Stat',
|
|
359
|
+
control: 'G9Kpi',
|
|
360
|
+
root: 'g9s-stat'
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: 'Progress',
|
|
364
|
+
control: 'G9ProgressBar',
|
|
365
|
+
root: 'g9s-progress'
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: 'Chip',
|
|
369
|
+
control: 'G9Chip',
|
|
370
|
+
root: 'g9s-chip'
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: 'Badge',
|
|
374
|
+
control: 'G9Badge',
|
|
375
|
+
root: 'g9s-badge'
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: 'Avatar',
|
|
379
|
+
control: 'G9Avatar',
|
|
380
|
+
root: 'g9s-avatar'
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'AvatarGroup',
|
|
384
|
+
control: null,
|
|
385
|
+
root: 'g9s-avatar-group'
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: 'Divider',
|
|
389
|
+
control: 'G9Separator',
|
|
390
|
+
root: 'g9s-divider'
|
|
391
|
+
}
|
|
392
|
+
]);
|
|
393
|
+
export { G9_STATIC_COMPONENTS, G9_STATIC_CSS, g9StaticAvatarSizes, g9StaticAvatarTone, g9StaticInitials, g9StaticRootStyle, g9StaticStylesheet, g9StaticTones, g9StaticVariables };
|
|
394
|
+
|
|
395
|
+
//# sourceMappingURL=static.js.map
|