@servicetitan/docs-anvil-uikit-contrib 40.2.0 → 41.0.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/dist/code-demo.d.ts +12 -0
- package/dist/code-demo.d.ts.map +1 -0
- package/dist/code-demo.js +65 -0
- package/dist/code-demo.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/docs/intl/API/create-intl.mdx +41 -0
- package/docs/intl/index.mdx +6 -0
- package/package.json +22 -2
- package/src/code-demo.tsx +63 -0
- package/src/global.d.ts +43 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentType } from 'react';
|
|
2
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
3
|
+
export interface CodeDemoProps {
|
|
4
|
+
example: ComponentType;
|
|
5
|
+
theme?: 'light' | 'dark';
|
|
6
|
+
srcPath?: string;
|
|
7
|
+
src?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const CodeDemo: (props: CodeDemoProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const DemoExample: (props: CodeDemoProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const DemoCodeBlock: (props: CodeDemoProps & Omit<ComponentProps<typeof CodeBlock>, "children">) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=code-demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-demo.d.ts","sourceRoot":"","sources":["../src/code-demo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM3D,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAIzC,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,4CAiB5C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,aAAa,4CAa/C,CAAC;AAEF,eAAO,MAAM,aAAa,GACtB,OAAO,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,EAAE,UAAU,CAAC,4CAU5E,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useColorMode } from '@docusaurus/theme-common';
|
|
3
|
+
import { dark, light } from '@servicetitan/anvil-themes';
|
|
4
|
+
import { AnvilProvider } from '@servicetitan/design-system';
|
|
5
|
+
import { AnvilProvider as Anvil2Provider } from '@servicetitan/anvil2';
|
|
6
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
7
|
+
import Tabs from '@theme/Tabs';
|
|
8
|
+
import TabItem from '@theme/TabItem';
|
|
9
|
+
export const CodeDemo = (props)=>{
|
|
10
|
+
return /*#__PURE__*/ _jsxs(Tabs, {
|
|
11
|
+
defaultValue: "example",
|
|
12
|
+
values: [
|
|
13
|
+
{
|
|
14
|
+
label: 'Example',
|
|
15
|
+
value: 'example'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: 'Source',
|
|
19
|
+
value: 'source'
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsx(TabItem, {
|
|
24
|
+
value: "example",
|
|
25
|
+
children: /*#__PURE__*/ _jsx(DemoExample, {
|
|
26
|
+
...props
|
|
27
|
+
})
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ _jsx(TabItem, {
|
|
30
|
+
value: "source",
|
|
31
|
+
children: /*#__PURE__*/ _jsx(DemoCodeBlock, {
|
|
32
|
+
...props
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export const DemoExample = (props)=>{
|
|
39
|
+
var _props_theme;
|
|
40
|
+
const { colorMode } = useColorMode();
|
|
41
|
+
const Example = props.example;
|
|
42
|
+
const theme = (_props_theme = props.theme) !== null && _props_theme !== void 0 ? _props_theme : colorMode;
|
|
43
|
+
return /*#__PURE__*/ _jsx(AnvilProvider, {
|
|
44
|
+
theme: theme === 'dark' ? dark : light,
|
|
45
|
+
children: /*#__PURE__*/ _jsx(Anvil2Provider, {
|
|
46
|
+
themeData: {
|
|
47
|
+
mode: theme === 'dark' ? dark : light
|
|
48
|
+
},
|
|
49
|
+
children: /*#__PURE__*/ _jsx(Example, {})
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export const DemoCodeBlock = (props)=>{
|
|
54
|
+
var _ref;
|
|
55
|
+
var _srcPath_match_groups, _srcPath_match;
|
|
56
|
+
const { srcPath, src, ...rest } = props;
|
|
57
|
+
const language = (_ref = srcPath === null || srcPath === void 0 ? void 0 : (_srcPath_match = srcPath.match(/\.(?<ext>[^\.]+)$/)) === null || _srcPath_match === void 0 ? void 0 : (_srcPath_match_groups = _srcPath_match.groups) === null || _srcPath_match_groups === void 0 ? void 0 : _srcPath_match_groups.ext) !== null && _ref !== void 0 ? _ref : 'tsx';
|
|
58
|
+
return /*#__PURE__*/ _jsx(CodeBlock, {
|
|
59
|
+
language: language,
|
|
60
|
+
...rest,
|
|
61
|
+
children: src
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=code-demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/code-demo.tsx"],"sourcesContent":["import type { ComponentProps, ComponentType } from 'react';\nimport { useColorMode } from '@docusaurus/theme-common';\nimport { dark, light } from '@servicetitan/anvil-themes';\nimport { AnvilProvider } from '@servicetitan/design-system';\nimport { AnvilProvider as Anvil2Provider } from '@servicetitan/anvil2';\n\nimport CodeBlock from '@theme/CodeBlock';\nimport Tabs from '@theme/Tabs';\nimport TabItem from '@theme/TabItem';\n\nexport interface CodeDemoProps {\n example: ComponentType;\n theme?: 'light' | 'dark';\n srcPath?: string;\n src?: string;\n}\n\nexport const CodeDemo = (props: CodeDemoProps) => {\n return (\n <Tabs\n defaultValue=\"example\"\n values={[\n { label: 'Example', value: 'example' },\n { label: 'Source', value: 'source' },\n ]}\n >\n <TabItem value=\"example\">\n <DemoExample {...props} />\n </TabItem>\n <TabItem value=\"source\">\n <DemoCodeBlock {...props} />\n </TabItem>\n </Tabs>\n );\n};\n\nexport const DemoExample = (props: CodeDemoProps) => {\n const { colorMode } = useColorMode();\n const Example = props.example;\n const theme = props.theme ?? colorMode;\n\n return (\n <AnvilProvider theme={theme === 'dark' ? dark : light}>\n {/* themeData.mode expects 'light' | 'dark', but a theme object is passed here to match current behavior. */}\n <Anvil2Provider themeData={{ mode: (theme === 'dark' ? dark : light) as never }}>\n <Example />\n </Anvil2Provider>\n </AnvilProvider>\n );\n};\n\nexport const DemoCodeBlock = (\n props: CodeDemoProps & Omit<ComponentProps<typeof CodeBlock>, 'children'>\n) => {\n const { srcPath, src, ...rest } = props;\n const language = srcPath?.match(/\\.(?<ext>[^\\.]+)$/)?.groups?.ext ?? 'tsx';\n\n return (\n <CodeBlock language={language} {...rest}>\n {src}\n </CodeBlock>\n );\n};\n"],"names":["useColorMode","dark","light","AnvilProvider","Anvil2Provider","CodeBlock","Tabs","TabItem","CodeDemo","props","defaultValue","values","label","value","DemoExample","DemoCodeBlock","colorMode","Example","example","theme","themeData","mode","srcPath","src","rest","language","match","groups","ext"],"mappings":";AACA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SAASC,IAAI,EAAEC,KAAK,QAAQ,6BAA6B;AACzD,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASA,iB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"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { CodeDemoProps } from './code-demo';\nexport { CodeDemo, DemoExample, DemoCodeBlock } from './code-demo';\n"],"names":["CodeDemo","DemoExample","DemoCodeBlock"],"mappings":"AACA,SAASA,QAAQ,EAAEC,WAAW,EAAEC,aAAa,QAAQ,cAAc"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: createIntl
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`createIntl` creates the imperative internationalization API without requiring React context.
|
|
6
|
+
|
|
7
|
+
Use this API in plain JavaScript, service classes, workers, or other non-React code where the React [`useIntl`](./use-intl.mdx) hook and providers are not available.
|
|
8
|
+
|
|
9
|
+
## Import
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createIntl } from '@servicetitan/intl/core';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The `/core` entrypoint does not require `react`, `react-dom`, or `react-intl` to be installed.
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createIntl } from '@servicetitan/intl/core';
|
|
21
|
+
|
|
22
|
+
const intl = createIntl({
|
|
23
|
+
currency: 'USD',
|
|
24
|
+
locale: 'en-US',
|
|
25
|
+
timeZone: 'America/Los_Angeles',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
intl.formatNumber(1234.56); // '1,234.56'
|
|
29
|
+
intl.formatCurrency(1234.56); // '$1,234.56'
|
|
30
|
+
intl.formatDate(new Date('2026-01-09T21:00:00.000Z'));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available Functions
|
|
34
|
+
|
|
35
|
+
The returned `intl` object provides the same imperative formatter API used by [`useIntl`](./use-intl.mdx), including standard Format.js formatting functions and ServiceTitan custom formatters.
|
|
36
|
+
|
|
37
|
+
See [`useIntl`](./use-intl.mdx#available-functions) for the full list of available functions and properties.
|
|
38
|
+
|
|
39
|
+
## React Usage
|
|
40
|
+
|
|
41
|
+
Inside React components, prefer [`useIntl`](./use-intl.mdx) or the formatted components from `@servicetitan/intl`. Use `createIntl` when there is no React context or when you are intentionally formatting outside React.
|
package/docs/intl/index.mdx
CHANGED
|
@@ -19,6 +19,12 @@ This library has `peerDependencies` for:
|
|
|
19
19
|
- `"@servicetitan/react-ioc": ">=22.0.0"`
|
|
20
20
|
- `"react-intl": ">=7.1.11"`
|
|
21
21
|
|
|
22
|
+
:::tip
|
|
23
|
+
|
|
24
|
+
For non-React JavaScript usage, import [`createIntl`](./API/create-intl.mdx) from `@servicetitan/intl/core`. Consumers that only need imperative formatting can use this entrypoint without installing `react`, `react-dom`, or `react-intl`.
|
|
25
|
+
|
|
26
|
+
:::
|
|
27
|
+
|
|
22
28
|
### Provider
|
|
23
29
|
|
|
24
30
|
Wrap your application with [`<IntlProvider>`](./API/intl-provider.mdx) or [`<MobxIntlProvider>`](./API/mobx-intl-provider.mdx), providing `locale`, `timeZone`, and `currency` through the `config` prop:
|
package/package.json
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-anvil-uikit-contrib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "41.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/servicetitan/anvil-uikit-contrib.git",
|
|
8
8
|
"directory": "docusaurus"
|
|
9
9
|
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"typings": "./dist/index.d.ts",
|
|
12
|
+
"sideEffects": false,
|
|
10
13
|
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"src",
|
|
11
16
|
"docs",
|
|
12
17
|
"remark"
|
|
13
18
|
],
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@docusaurus/theme-common": "^3.10.1",
|
|
21
|
+
"@servicetitan/anvil-themes": "^14.5.3",
|
|
22
|
+
"@servicetitan/anvil2": "^3.4.2",
|
|
23
|
+
"@servicetitan/design-system": "~14.5.1",
|
|
24
|
+
"@types/react": "~18.2.55",
|
|
25
|
+
"react": "^18.2.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@docusaurus/theme-common": ">=3.0.0",
|
|
29
|
+
"@servicetitan/anvil-themes": ">=13.2.1",
|
|
30
|
+
"@servicetitan/anvil2": ">=3.0.0",
|
|
31
|
+
"@servicetitan/design-system": ">=13.2.1",
|
|
32
|
+
"react": ">=17.0.2"
|
|
33
|
+
},
|
|
14
34
|
"publishConfig": {
|
|
15
35
|
"access": "public"
|
|
16
36
|
},
|
|
17
37
|
"cli": {
|
|
18
38
|
"webpack": false
|
|
19
39
|
},
|
|
20
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "9bf5eb2634c17330d1251d431ed5b60b28b56c21"
|
|
21
41
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentType } from 'react';
|
|
2
|
+
import { useColorMode } from '@docusaurus/theme-common';
|
|
3
|
+
import { dark, light } from '@servicetitan/anvil-themes';
|
|
4
|
+
import { AnvilProvider } from '@servicetitan/design-system';
|
|
5
|
+
import { AnvilProvider as Anvil2Provider } from '@servicetitan/anvil2';
|
|
6
|
+
|
|
7
|
+
import CodeBlock from '@theme/CodeBlock';
|
|
8
|
+
import Tabs from '@theme/Tabs';
|
|
9
|
+
import TabItem from '@theme/TabItem';
|
|
10
|
+
|
|
11
|
+
export interface CodeDemoProps {
|
|
12
|
+
example: ComponentType;
|
|
13
|
+
theme?: 'light' | 'dark';
|
|
14
|
+
srcPath?: string;
|
|
15
|
+
src?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const CodeDemo = (props: CodeDemoProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<Tabs
|
|
21
|
+
defaultValue="example"
|
|
22
|
+
values={[
|
|
23
|
+
{ label: 'Example', value: 'example' },
|
|
24
|
+
{ label: 'Source', value: 'source' },
|
|
25
|
+
]}
|
|
26
|
+
>
|
|
27
|
+
<TabItem value="example">
|
|
28
|
+
<DemoExample {...props} />
|
|
29
|
+
</TabItem>
|
|
30
|
+
<TabItem value="source">
|
|
31
|
+
<DemoCodeBlock {...props} />
|
|
32
|
+
</TabItem>
|
|
33
|
+
</Tabs>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const DemoExample = (props: CodeDemoProps) => {
|
|
38
|
+
const { colorMode } = useColorMode();
|
|
39
|
+
const Example = props.example;
|
|
40
|
+
const theme = props.theme ?? colorMode;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<AnvilProvider theme={theme === 'dark' ? dark : light}>
|
|
44
|
+
{/* themeData.mode expects 'light' | 'dark', but a theme object is passed here to match current behavior. */}
|
|
45
|
+
<Anvil2Provider themeData={{ mode: (theme === 'dark' ? dark : light) as never }}>
|
|
46
|
+
<Example />
|
|
47
|
+
</Anvil2Provider>
|
|
48
|
+
</AnvilProvider>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const DemoCodeBlock = (
|
|
53
|
+
props: CodeDemoProps & Omit<ComponentProps<typeof CodeBlock>, 'children'>
|
|
54
|
+
) => {
|
|
55
|
+
const { srcPath, src, ...rest } = props;
|
|
56
|
+
const language = srcPath?.match(/\.(?<ext>[^\.]+)$/)?.groups?.ext ?? 'tsx';
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<CodeBlock language={language} {...rest}>
|
|
60
|
+
{src}
|
|
61
|
+
</CodeBlock>
|
|
62
|
+
);
|
|
63
|
+
};
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* `@theme/*` resolves via a webpack alias, not a real package, so types are
|
|
3
|
+
* copied here rather than bloating this project with Docusaurus's themes.
|
|
4
|
+
* Copied from src/theme-classic.d.ts in @docusaurus/theme-classic@3.10.1
|
|
5
|
+
*/
|
|
6
|
+
/* eslint-disable import/no-default-export */
|
|
7
|
+
declare module '@theme/CodeBlock' {
|
|
8
|
+
import type { ReactNode } from 'react';
|
|
9
|
+
|
|
10
|
+
export interface Props {
|
|
11
|
+
readonly children: ReactNode;
|
|
12
|
+
readonly className?: string;
|
|
13
|
+
readonly metastring?: string;
|
|
14
|
+
readonly title?: ReactNode;
|
|
15
|
+
readonly language?: string;
|
|
16
|
+
readonly showLineNumbers?: boolean | number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function CodeBlock(props: Props): ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '@theme/Tabs' {
|
|
23
|
+
import type { ReactNode } from 'react';
|
|
24
|
+
|
|
25
|
+
export interface Props {
|
|
26
|
+
readonly children: ReactNode;
|
|
27
|
+
readonly defaultValue?: string;
|
|
28
|
+
readonly values?: readonly { value: string; label?: string }[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function Tabs(props: Props): ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '@theme/TabItem' {
|
|
35
|
+
import type { ReactNode } from 'react';
|
|
36
|
+
|
|
37
|
+
export interface Props {
|
|
38
|
+
readonly children: ReactNode;
|
|
39
|
+
readonly value: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default function TabItem(props: Props): ReactNode;
|
|
43
|
+
}
|
package/src/index.ts
ADDED