@laconius/ui 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/LICENSE +73 -0
- package/README.md +22 -0
- package/lib/module/button.js +76 -0
- package/lib/module/button.js.map +1 -0
- package/lib/module/config.js +33 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/feedback.js +81 -0
- package/lib/module/feedback.js.map +1 -0
- package/lib/module/hooks.js +107 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +18 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/kratos.js +130 -0
- package/lib/module/kratos.js.map +1 -0
- package/lib/module/media.js +61 -0
- package/lib/module/media.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/price.js +34 -0
- package/lib/module/price.js.map +1 -0
- package/lib/module/quantity-stepper.js +60 -0
- package/lib/module/quantity-stepper.js.map +1 -0
- package/lib/module/store.js +25 -0
- package/lib/module/store.js.map +1 -0
- package/lib/module/text.js +55 -0
- package/lib/module/text.js.map +1 -0
- package/lib/module/theme.js +40 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/translations.js +15 -0
- package/lib/module/translations.js.map +1 -0
- package/lib/module/use-gallery.js +22 -0
- package/lib/module/use-gallery.js.map +1 -0
- package/lib/module/use-product-card.js +36 -0
- package/lib/module/use-product-card.js.map +1 -0
- package/lib/module/use-quantity-stepper.js +20 -0
- package/lib/module/use-quantity-stepper.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/button.d.ts +18 -0
- package/lib/typescript/src/button.d.ts.map +1 -0
- package/lib/typescript/src/config.d.ts +40 -0
- package/lib/typescript/src/config.d.ts.map +1 -0
- package/lib/typescript/src/feedback.d.ts +24 -0
- package/lib/typescript/src/feedback.d.ts.map +1 -0
- package/lib/typescript/src/hooks.d.ts +31 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +16 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/kratos.d.ts +8 -0
- package/lib/typescript/src/kratos.d.ts.map +1 -0
- package/lib/typescript/src/media.d.ts +37 -0
- package/lib/typescript/src/media.d.ts.map +1 -0
- package/lib/typescript/src/price.d.ts +15 -0
- package/lib/typescript/src/price.d.ts.map +1 -0
- package/lib/typescript/src/quantity-stepper.d.ts +13 -0
- package/lib/typescript/src/quantity-stepper.d.ts.map +1 -0
- package/lib/typescript/src/store.d.ts +27 -0
- package/lib/typescript/src/store.d.ts.map +1 -0
- package/lib/typescript/src/text.d.ts +15 -0
- package/lib/typescript/src/text.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +71 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/translations.d.ts +13 -0
- package/lib/typescript/src/translations.d.ts.map +1 -0
- package/lib/typescript/src/use-gallery.d.ts +13 -0
- package/lib/typescript/src/use-gallery.d.ts.map +1 -0
- package/lib/typescript/src/use-product-card.d.ts +24 -0
- package/lib/typescript/src/use-product-card.d.ts.map +1 -0
- package/lib/typescript/src/use-quantity-stepper.d.ts +18 -0
- package/lib/typescript/src/use-quantity-stepper.d.ts.map +1 -0
- package/package.json +73 -0
- package/src/button.tsx +95 -0
- package/src/config.ts +53 -0
- package/src/feedback.tsx +95 -0
- package/src/hooks.ts +130 -0
- package/src/index.ts +62 -0
- package/src/kratos.ts +86 -0
- package/src/media.tsx +96 -0
- package/src/price.tsx +30 -0
- package/src/quantity-stepper.tsx +70 -0
- package/src/store.ts +35 -0
- package/src/text.tsx +49 -0
- package/src/theme.ts +90 -0
- package/src/translations.ts +12 -0
- package/src/use-gallery.ts +35 -0
- package/src/use-product-card.ts +47 -0
- package/src/use-quantity-stepper.ts +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved.
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @laconius/ui
|
|
2
|
+
|
|
3
|
+
The Laconius UI kit: the theme system and the eight dumb primitives. Never imports a feature
|
|
4
|
+
package.
|
|
5
|
+
|
|
6
|
+
## Public API
|
|
7
|
+
|
|
8
|
+
- **Theme**: `kratos` (default, light + dark), `defineTheme` (complete theme, no inheritance),
|
|
9
|
+
`extendTheme` (patch an existing one). Config: `ui.themes`, `ui.defaultTheme`,
|
|
10
|
+
`ui.colorScheme`.
|
|
11
|
+
- **Hooks**: `useTheme()`, `useStyles(createStyles)` (memoised `StyleSheet` per theme),
|
|
12
|
+
`useThemeSwitcher()` (runtime theme + scheme switching, persisted).
|
|
13
|
+
- **Primitives**: `Text`, `Button`, `Media` (candidate-set resolution via `useMedia`), `Price`
|
|
14
|
+
(renders OCC's `formattedValue`, `Intl` fallback), `Divider`, `Spinner`, `EmptyState`,
|
|
15
|
+
`QuantityStepper` (clamps to min/max/stock; does not know what a cart is).
|
|
16
|
+
- **Registry**: `ui.components` — a closed, typed key space. Feature packages add keys by
|
|
17
|
+
declaration merging; apps replace any component by key, and library code renders through
|
|
18
|
+
`useUiComponent(key, Fallback)`.
|
|
19
|
+
|
|
20
|
+
Interaction-state logic lives in UI-kit hooks (`useMedia`, `useGallery`, `useQuantityStepper`,
|
|
21
|
+
`useProductCard`); anything touching the server stays in feature hooks. See
|
|
22
|
+
[spec chapter 07](../../docs/spec/07-ui-kit.md).
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ActivityIndicator, Pressable, StyleSheet } from 'react-native';
|
|
4
|
+
import { useStyles, useTheme, useUiComponent } from "./hooks.js";
|
|
5
|
+
import { Text } from "./text.js";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const createStyles = theme => StyleSheet.create({
|
|
8
|
+
base: {
|
|
9
|
+
minHeight: 44,
|
|
10
|
+
paddingHorizontal: theme.spacing.lg,
|
|
11
|
+
paddingVertical: theme.spacing.sm,
|
|
12
|
+
borderRadius: theme.radii.md,
|
|
13
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
14
|
+
borderColor: 'transparent',
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
gap: theme.spacing.sm
|
|
19
|
+
},
|
|
20
|
+
primary: {
|
|
21
|
+
backgroundColor: theme.colors.primary
|
|
22
|
+
},
|
|
23
|
+
secondary: {
|
|
24
|
+
backgroundColor: theme.colors.surface,
|
|
25
|
+
borderColor: theme.colors.border
|
|
26
|
+
},
|
|
27
|
+
ghost: {
|
|
28
|
+
backgroundColor: 'transparent'
|
|
29
|
+
},
|
|
30
|
+
pressed: {
|
|
31
|
+
opacity: 0.7
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
opacity: 0.5
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export function Button({
|
|
38
|
+
title,
|
|
39
|
+
variant = 'primary',
|
|
40
|
+
loading = false,
|
|
41
|
+
disabled = false,
|
|
42
|
+
style,
|
|
43
|
+
styles: parts,
|
|
44
|
+
children,
|
|
45
|
+
...rest
|
|
46
|
+
}) {
|
|
47
|
+
const theme = useTheme();
|
|
48
|
+
const styles = useStyles(createStyles);
|
|
49
|
+
const Label = useUiComponent('Text', Text);
|
|
50
|
+
const isDisabled = disabled || loading;
|
|
51
|
+
const color = variant === 'primary' ? theme.colors.onPrimary : theme.colors.primary;
|
|
52
|
+
return /*#__PURE__*/_jsxs(Pressable, {
|
|
53
|
+
accessibilityRole: "button",
|
|
54
|
+
accessibilityLabel: title,
|
|
55
|
+
accessibilityState: {
|
|
56
|
+
disabled: isDisabled,
|
|
57
|
+
busy: loading
|
|
58
|
+
},
|
|
59
|
+
disabled: isDisabled,
|
|
60
|
+
hitSlop: 8,
|
|
61
|
+
style: ({
|
|
62
|
+
pressed
|
|
63
|
+
}) => [styles.base, styles[variant], pressed && !isDisabled ? styles.pressed : null, isDisabled ? styles.disabled : null, parts?.container, style],
|
|
64
|
+
...rest,
|
|
65
|
+
children: [loading ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
66
|
+
color: color,
|
|
67
|
+
size: "small"
|
|
68
|
+
}) : null, title ? /*#__PURE__*/_jsx(Label, {
|
|
69
|
+
variant: "label",
|
|
70
|
+
color: color,
|
|
71
|
+
style: parts?.label,
|
|
72
|
+
children: title
|
|
73
|
+
}) : null, children]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ActivityIndicator","Pressable","StyleSheet","useStyles","useTheme","useUiComponent","Text","jsx","_jsx","jsxs","_jsxs","createStyles","theme","create","base","minHeight","paddingHorizontal","spacing","lg","paddingVertical","sm","borderRadius","radii","md","borderWidth","hairlineWidth","borderColor","flexDirection","alignItems","justifyContent","gap","primary","backgroundColor","colors","secondary","surface","border","ghost","pressed","opacity","disabled","Button","title","variant","loading","style","styles","parts","children","rest","Label","isDisabled","color","onPrimary","accessibilityRole","accessibilityLabel","accessibilityState","busy","hitSlop","container","size","label"],"sourceRoot":"../../src","sources":["button.tsx"],"mappings":";;AACA,SACEA,iBAAiB,EACjBC,SAAS,EACTC,UAAU,QAKL,cAAc;AAErB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,YAAS;AAC7D,SAASC,IAAI,QAAQ,WAAQ;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAgB9B,MAAMC,YAAY,GAAIC,KAAY,IAChCV,UAAU,CAACW,MAAM,CAAC;EAChBC,IAAI,EAAE;IACJC,SAAS,EAAE,EAAE;IACbC,iBAAiB,EAAEJ,KAAK,CAACK,OAAO,CAACC,EAAE;IACnCC,eAAe,EAAEP,KAAK,CAACK,OAAO,CAACG,EAAE;IACjCC,YAAY,EAAET,KAAK,CAACU,KAAK,CAACC,EAAE;IAC5BC,WAAW,EAAEtB,UAAU,CAACuB,aAAa;IACrCC,WAAW,EAAE,aAAa;IAC1BC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,GAAG,EAAElB,KAAK,CAACK,OAAO,CAACG;EACrB,CAAC;EACDW,OAAO,EAA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OAAO,CAAC,EACfL,OAAO,IAAI,CAACa,UAAU,GAAGL,MAAM,CAACR,OAAO,GAAG,IAAI,EAC9Ca,UAAU,GAAGL,MAAM,CAACN,QAAQ,GAAG,IAAI,EACnCO,KAAK,EAAEY,SAAS,EAChBd,KAAK,CACL;IAAA,GACEI,IAAI;IAAAD,QAAA,GAEPJ,OAAO,gBAAGpC,IAAA,CAACR,iBAAiB;MAACoD,KAAK,EAAEA,KAAM;MAACQ,IAAI,EAAC;IAAO,CAAE,CAAC,GAAG,IAAI,EACjElB,KAAK,gBACJlC,IAAA,CAAC0C,KAAK;MAACP,OAAO,EAAC,OAAO;MAACS,KAAK,EAAEA,KAAM;MAACP,KAAK,EAAEE,KAAK,EAAEc,KAAM;MAAAb,QAAA,EACtDN;IAAK,CACD,CAAC,GACN,IAAI,EACPM,QAAQ;EAAA,CACA,CAAC;AAEhB","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { kratos } from "./kratos.js";
|
|
4
|
+
import { defaultUiTranslations } from "./translations.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The registry key space, closed and typed — unlike `cms.components`, whose keys are open backend
|
|
8
|
+
* type codes ([ADR-0007](../../../docs/adr/0007-two-registries-two-contracts.md)). Feature
|
|
9
|
+
* packages add their own keys by declaration merging:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* declare module '@laconius/ui' {
|
|
13
|
+
* interface LaconiusUiComponents { ProductCard: unknown }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The values are unused: only the keys are the contract, and the registry stores
|
|
18
|
+
* `ComponentType<any>` because a replacement is checked against the props it is handed, not here.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export const defaultUiConfig = {
|
|
22
|
+
ui: {
|
|
23
|
+
themes: {
|
|
24
|
+
kratos
|
|
25
|
+
},
|
|
26
|
+
defaultTheme: 'kratos',
|
|
27
|
+
colorScheme: 'system'
|
|
28
|
+
},
|
|
29
|
+
i18n: {
|
|
30
|
+
translations: defaultUiTranslations
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["kratos","defaultUiTranslations","defaultUiConfig","ui","themes","defaultTheme","colorScheme","i18n","translations"],"sourceRoot":"../../src","sources":["config.ts"],"mappings":";;AAGA,SAASA,MAAM,QAAQ,aAAU;AAEjC,SAASC,qBAAqB,QAAQ,mBAAgB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA,OAAO,MAAMC,eAAoC,GAAG;EAClDC,EAAE,EAAE;IACFC,MAAM,EAAE;MAAEJ;IAAO,CAAC;IAClBK,YAAY,EAAE,QAAQ;IACtBC,WAAW,EAAE;EACf,CAAC;EACDC,IAAI,EAAE;IAAEC,YAAY,EAAEP;EAAsB;AAC9C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ActivityIndicator, StyleSheet, View } from 'react-native';
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import { useStyles, useTheme, useUiComponent } from "./hooks.js";
|
|
6
|
+
import { Text } from "./text.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const createDividerStyles = theme => StyleSheet.create({
|
|
9
|
+
root: {
|
|
10
|
+
height: StyleSheet.hairlineWidth,
|
|
11
|
+
backgroundColor: theme.colors.border
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export function Divider({
|
|
15
|
+
inset = 0,
|
|
16
|
+
style,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const styles = useStyles(createDividerStyles);
|
|
20
|
+
return /*#__PURE__*/_jsx(View, {
|
|
21
|
+
accessibilityElementsHidden: true,
|
|
22
|
+
importantForAccessibility: "no-hide-descendants",
|
|
23
|
+
style: [styles.root, inset ? {
|
|
24
|
+
marginHorizontal: inset
|
|
25
|
+
} : null, style],
|
|
26
|
+
...rest
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function Spinner({
|
|
30
|
+
color,
|
|
31
|
+
...rest
|
|
32
|
+
}) {
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
return /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
35
|
+
color: color ?? theme.colors.primary,
|
|
36
|
+
...rest
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const createEmptyStateStyles = theme => StyleSheet.create({
|
|
40
|
+
root: {
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
gap: theme.spacing.sm,
|
|
44
|
+
padding: theme.spacing.xl
|
|
45
|
+
},
|
|
46
|
+
text: {
|
|
47
|
+
textAlign: 'center'
|
|
48
|
+
},
|
|
49
|
+
action: {
|
|
50
|
+
marginTop: theme.spacing.sm
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export function EmptyState({
|
|
54
|
+
title,
|
|
55
|
+
message,
|
|
56
|
+
action,
|
|
57
|
+
icon,
|
|
58
|
+
style,
|
|
59
|
+
styles: parts
|
|
60
|
+
}) {
|
|
61
|
+
const styles = useStyles(createEmptyStateStyles);
|
|
62
|
+
const Label = useUiComponent('Text', Text);
|
|
63
|
+
const Action = useUiComponent('Button', Button);
|
|
64
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
65
|
+
style: [styles.root, parts?.container, style],
|
|
66
|
+
children: [icon, /*#__PURE__*/_jsx(Label, {
|
|
67
|
+
variant: "subheading",
|
|
68
|
+
style: [styles.text, parts?.title],
|
|
69
|
+
children: title
|
|
70
|
+
}), message ? /*#__PURE__*/_jsx(Label, {
|
|
71
|
+
muted: true,
|
|
72
|
+
style: [styles.text, parts?.message],
|
|
73
|
+
children: message
|
|
74
|
+
}) : null, action ? /*#__PURE__*/_jsx(Action, {
|
|
75
|
+
variant: "secondary",
|
|
76
|
+
style: styles.action,
|
|
77
|
+
...action
|
|
78
|
+
}) : null]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ActivityIndicator","StyleSheet","View","Button","useStyles","useTheme","useUiComponent","Text","jsx","_jsx","jsxs","_jsxs","createDividerStyles","theme","create","root","height","hairlineWidth","backgroundColor","colors","border","Divider","inset","style","rest","styles","accessibilityElementsHidden","importantForAccessibility","marginHorizontal","Spinner","color","primary","createEmptyStateStyles","alignItems","justifyContent","gap","spacing","sm","padding","xl","text","textAlign","action","marginTop","EmptyState","title","message","icon","parts","Label","Action","container","children","variant","muted"],"sourceRoot":"../../src","sources":["feedback.tsx"],"mappings":";;AACA,SACEA,iBAAiB,EACjBC,UAAU,EACVC,IAAI,QAMC,cAAc;AAErB,SAASC,MAAM,QAA0B,aAAU;AACnD,SAASC,SAAS,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,YAAS;AAC7D,SAASC,IAAI,QAAQ,WAAQ;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAK9B,MAAMC,mBAAmB,GAAIC,KAAY,IACvCZ,UAAU,CAACa,MAAM,CAAC;EAChBC,IAAI,EAAE;IAAEC,MAAM,EAAEf,UAAU,CAACgB,aAAa;IAAEC,eAAe,EAAEL,KAAK,CAACM,MAAM,CAACC;EAAO;AACjF,CAAC,CAAC;AAEJ,OAAO,SAASC,OAAOA,CAAC;EAAEC,KAAK,GAAG,CAAC;EAAEC,KAAK;EAAE,GAAGC;AAAmB,CAAC,EAAE;EACnE,MAAMC,MAAM,GAAGrB,SAAS,CAACQ,mBAAmB,CAAC;EAC7C,oBACEH,IAAA,CAACP,IAAI;IACHwB,2BAA2B;IAC3B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AACE,MAAM,CAACV,IAAI,EAAEiC,KAAK,EAAEG,SAAS,EAAE5B,KAAK,CAAE;IAAA6B,QAAA,GACjDL,IAAI,eACLtC,IAAA,CAACwC,KAAK;MAACI,OAAO,EAAC,YAAY;MAAC9B,KAAK,EAAE,CAACE,MAAM,CAACe,IAAI,EAAEQ,KAAK,EAAEH,KAAK,CAAE;MAAAO,QAAA,EAC5DP;IAAK,CACD,CAAC,EACPC,OAAO,gBACNrC,IAAA,CAACwC,KAAK;MAACK,KAAK;MAAC/B,KAAK,EAAE,CAACE,MAAM,CAACe,IAAI,EAAEQ,KAAK,EAAEF,OAAO,CAAE;MAAAM,QAAA,EAC/CN;IAAO,CACH,CAAC,GACN,IAAI,EACPJ,MAAM,gBAAGjC,IAAA,CAACyC,MAAM;MAACG,OAAO,EAAC,WAAW;MAAC9B,KAAK,EAAEE,MAAM,CAACiB,MAAO;MAAA,GAAKA;IAAM,CAAG,CAAC,GAAG,IAAI;EAAA,CAC7E,CAAC;AAEX","ignoreList":[]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useLaconiusConfig } from '@laconius/core';
|
|
4
|
+
import { useColorScheme } from 'react-native';
|
|
5
|
+
import { kratos } from "./kratos.js";
|
|
6
|
+
import { useThemeStore } from "./store.js";
|
|
7
|
+
const resolved = new WeakMap();
|
|
8
|
+
const warned = new Set();
|
|
9
|
+
function warnOnce(message) {
|
|
10
|
+
if (process.env.NODE_ENV === 'production' || warned.has(message)) return;
|
|
11
|
+
warned.add(message);
|
|
12
|
+
console.warn(`[laconius] ${message}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cached per config and per `themeId:scheme`, because `useStyles` memoizes on theme *identity*:
|
|
17
|
+
* a theme rebuilt on every render would rebuild every `StyleSheet` with it.
|
|
18
|
+
*/
|
|
19
|
+
function resolveTheme(config, themeId, scheme) {
|
|
20
|
+
let cache = resolved.get(config);
|
|
21
|
+
if (!cache) {
|
|
22
|
+
cache = new Map();
|
|
23
|
+
resolved.set(config, cache);
|
|
24
|
+
}
|
|
25
|
+
const key = `${themeId}:${scheme}`;
|
|
26
|
+
const hit = cache.get(key);
|
|
27
|
+
if (hit) return hit;
|
|
28
|
+
const themes = config.ui?.themes;
|
|
29
|
+
let entry = themes?.[themeId];
|
|
30
|
+
if (!entry) {
|
|
31
|
+
warnOnce(`Unknown theme "${themeId}"; falling back to the first configured theme.`);
|
|
32
|
+
entry = themes ? Object.values(themes)[0] : undefined;
|
|
33
|
+
}
|
|
34
|
+
const resolvedEntry = entry ?? kratos;
|
|
35
|
+
const theme = (scheme === 'dark' ? resolvedEntry.dark : undefined) ?? resolvedEntry.light;
|
|
36
|
+
cache.set(key, theme);
|
|
37
|
+
return theme;
|
|
38
|
+
}
|
|
39
|
+
function useActiveScheme() {
|
|
40
|
+
const config = useLaconiusConfig();
|
|
41
|
+
const system = useColorScheme();
|
|
42
|
+
const override = useThemeStore(state => state.colorScheme);
|
|
43
|
+
const preference = override ?? config.ui?.colorScheme ?? 'system';
|
|
44
|
+
if (preference === 'system') return system === 'dark' ? 'dark' : 'light';
|
|
45
|
+
return preference;
|
|
46
|
+
}
|
|
47
|
+
function useActiveThemeId() {
|
|
48
|
+
const config = useLaconiusConfig();
|
|
49
|
+
const activeThemeId = useThemeStore(state => state.activeThemeId);
|
|
50
|
+
return activeThemeId ?? config.ui?.defaultTheme ?? 'kratos';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The configured theme resolved against the effective colour scheme. */
|
|
54
|
+
export function useTheme() {
|
|
55
|
+
const config = useLaconiusConfig();
|
|
56
|
+
return resolveTheme(config, useActiveThemeId(), useActiveScheme());
|
|
57
|
+
}
|
|
58
|
+
const styles = new WeakMap();
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Style factories are declared outside the component and memoized per theme identity, so a
|
|
62
|
+
* `FlatList` of a hundred rows builds one `StyleSheet`, not a hundred.
|
|
63
|
+
*/
|
|
64
|
+
export function useStyles(factory) {
|
|
65
|
+
const theme = useTheme();
|
|
66
|
+
let perTheme = styles.get(factory);
|
|
67
|
+
if (!perTheme) {
|
|
68
|
+
perTheme = new WeakMap();
|
|
69
|
+
styles.set(factory, perTheme);
|
|
70
|
+
}
|
|
71
|
+
let sheet = perTheme.get(theme);
|
|
72
|
+
if (sheet === undefined) {
|
|
73
|
+
sheet = factory(theme);
|
|
74
|
+
perTheme.set(theme, sheet);
|
|
75
|
+
}
|
|
76
|
+
return sheet;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Laconius ships no `<ThemeSwitcher>` component: picking a theme is one row in an app's settings
|
|
80
|
+
* screen, and the row belongs to the app.
|
|
81
|
+
*/
|
|
82
|
+
export function useThemeSwitcher() {
|
|
83
|
+
const config = useLaconiusConfig();
|
|
84
|
+
const setTheme = useThemeStore(state => state.setTheme);
|
|
85
|
+
const setColorScheme = useThemeStore(state => state.setColorScheme);
|
|
86
|
+
const override = useThemeStore(state => state.colorScheme);
|
|
87
|
+
return {
|
|
88
|
+
themes: Object.entries(config.ui?.themes ?? {}).map(([id, entry]) => ({
|
|
89
|
+
id,
|
|
90
|
+
name: entry.name
|
|
91
|
+
})),
|
|
92
|
+
activeId: useActiveThemeId(),
|
|
93
|
+
setTheme,
|
|
94
|
+
colorScheme: override ?? config.ui?.colorScheme ?? 'system',
|
|
95
|
+
setColorScheme
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The registry lookup, used by the components Laconius renders itself. Anything the app mounts
|
|
101
|
+
* directly it imports directly, and the registry never sees it.
|
|
102
|
+
*/
|
|
103
|
+
export function useUiComponent(key, fallback) {
|
|
104
|
+
const config = useLaconiusConfig();
|
|
105
|
+
return config.ui?.components?.[key] ?? fallback;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLaconiusConfig","useColorScheme","kratos","useThemeStore","resolved","WeakMap","warned","Set","warnOnce","message","process","env","NODE_ENV","has","add","console","warn","resolveTheme","config","themeId","scheme","cache","get","Map","set","key","hit","themes","ui","entry","Object","values","undefined","resolvedEntry","theme","dark","light","useActiveScheme","system","override","state","colorScheme","preference","useActiveThemeId","activeThemeId","defaultTheme","useTheme","styles","useStyles","factory","perTheme","sheet","useThemeSwitcher","setTheme","setColorScheme","entries","map","id","name","activeId","useUiComponent","fallback","components"],"sourceRoot":"../../src","sources":["hooks.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAA6B,gBAAgB;AAEvE,SAASC,cAAc,QAAQ,cAAc;AAG7C,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,aAAa,QAAQ,YAAS;AAGvC,MAAMC,QAAQ,GAAG,IAAIC,OAAO,CAAqC,CAAC;AAClE,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAAS,CAAC;AAEhC,SAASC,QAAQA,CAACC,OAAe,EAAQ;EACvC,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIN,MAAM,CAACO,GAAG,CAACJ,OAAO,CAAC,EAAE;EAClEH,MAAM,CAACQ,GAAG,CAACL,OAAO,CAAC;EACnBM,OAAO,CAACC,IAAI,CAAC,cAAcP,OAAO,EAAE,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA,SAASQ,YAAYA,CACnBC,MAAsB,EACtBC,OAAe,EACfC,MAAwB,EACjB;EACP,IAAIC,KAAK,GAAGjB,QAAQ,CAACkB,GAAG,CAACJ,MAAM,CAAC;EAChC,IAAI,CAACG,KAAK,EAAE;IACVA,KAAK,GAAG,IAAIE,GAAG,CAAC,CAAC;IACjBnB,QAAQ,CAACoB,GAAG,CAACN,MAAM,EAAEG,KAAK,CAAC;EAC7B;EACA,MAAMI,GAAG,GAAG,GAAGN,OAAO,IAAIC,MAAM,EAAE;EAClC,MAAMM,GAAG,GAAGL,K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MAAM,EAAEG,MAAM,CAACyB,OAAO,CAACrC,MAAM,CAACU,EAAE,EAAED,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC6B,GAAG,CAAC,CAAC,CAACC,EAAE,EAAE5B,KAAK,CAAC,MAAM;MACpE4B,EAAE;MACFC,IAAI,EAAE7B,KAAK,CAAC6B;IACd,CAAC,CAAC,CAAC;IACHC,QAAQ,EAAEhB,gBAAgB,CAAC,CAAC;IAC5BU,QAAQ;IACRZ,WAAW,EAAEF,QAAQ,IAAIrB,MAAM,CAACU,EAAE,EAAEa,WAAW,IAAI,QAAQ;IAC3Da;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASM,cAAcA,CAC5BnC,GAAwB,EACxBoC,QAA0B,EACR;EAClB,MAAM3C,MAAM,GAAGlB,iBAAiB,CAAC,CAAC;EAClC,OAAQkB,MAAM,CAACU,EAAE,EAAEkC,UAAU,GAAGrC,GAAG,CAAC,IAAqCoC,QAAQ;AACnF","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { defaultUiConfig } from "./config.js";
|
|
4
|
+
export { defineTheme, extendTheme } from "./theme.js";
|
|
5
|
+
export { kratos, kratosDark, kratosLight } from "./kratos.js";
|
|
6
|
+
export { useThemeStore } from "./store.js";
|
|
7
|
+
export { useStyles, useTheme, useThemeSwitcher, useUiComponent } from "./hooks.js";
|
|
8
|
+
export { defaultUiTranslations } from "./translations.js";
|
|
9
|
+
export { Text } from "./text.js";
|
|
10
|
+
export { Button } from "./button.js";
|
|
11
|
+
export { Media, useMedia } from "./media.js";
|
|
12
|
+
export { Price, formatPrice } from "./price.js";
|
|
13
|
+
export { Divider, EmptyState, Spinner } from "./feedback.js";
|
|
14
|
+
export { QuantityStepper } from "./quantity-stepper.js";
|
|
15
|
+
export { useProductCard } from "./use-product-card.js";
|
|
16
|
+
export { useGallery } from "./use-gallery.js";
|
|
17
|
+
export { useQuantityStepper } from "./use-quantity-stepper.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultUiConfig","defineTheme","extendTheme","kratos","kratosDark","kratosLight","useThemeStore","useStyles","useTheme","useThemeSwitcher","useUiComponent","defaultUiTranslations","Text","Button","Media","useMedia","Price","formatPrice","Divider","EmptyState","Spinner","QuantityStepper","useProductCard","useGallery","useQuantityStepper"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SACEA,eAAe,QAGV,aAAU;AAEjB,SACEC,WAAW,EACXC,WAAW,QAQN,YAAS;AAEhB,SAASC,MAAM,EAAEC,UAAU,EAAEC,WAAW,QAAQ,aAAU;AAE1D,SAASC,aAAa,QAAyB,YAAS;AAExD,SACEC,SAAS,EACTC,QAAQ,EACRC,gBAAgB,EAChBC,cAAc,QAET,YAAS;AAEhB,SAASC,qBAAqB,QAAQ,mBAAgB;AAEtD,SAASC,IAAI,QAAwB,WAAQ;AAC7C,SAASC,MAAM,QAA8C,aAAU;AACvE,SACEC,KAAK,EACLC,QAAQ,QAIH,YAAS;AAChB,SAASC,KAAK,EAAEC,WAAW,QAAyB,YAAS;AAC7D,SACEC,OAAO,EACPC,UAAU,EACVC,OAAO,QAIF,eAAY;AACnB,SAASC,eAAe,QAAmC,uBAAoB;AAC/E,SACEC,cAAc,QAGT,uBAAoB;AAC3B,SAASC,UAAU,QAAyB,kBAAe;AAC3D,SACEC,kBAAkB,QAGb,2BAAwB","ignoreList":[]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { defineTheme } from "./theme.js";
|
|
4
|
+
const spacing = {
|
|
5
|
+
xs: 4,
|
|
6
|
+
sm: 8,
|
|
7
|
+
md: 12,
|
|
8
|
+
lg: 16,
|
|
9
|
+
xl: 24,
|
|
10
|
+
xxl: 32
|
|
11
|
+
};
|
|
12
|
+
const typography = {
|
|
13
|
+
display: {
|
|
14
|
+
fontSize: 32,
|
|
15
|
+
lineHeight: 38,
|
|
16
|
+
fontWeight: '700'
|
|
17
|
+
},
|
|
18
|
+
heading: {
|
|
19
|
+
fontSize: 24,
|
|
20
|
+
lineHeight: 30,
|
|
21
|
+
fontWeight: '700'
|
|
22
|
+
},
|
|
23
|
+
subheading: {
|
|
24
|
+
fontSize: 18,
|
|
25
|
+
lineHeight: 24,
|
|
26
|
+
fontWeight: '600'
|
|
27
|
+
},
|
|
28
|
+
body: {
|
|
29
|
+
fontSize: 16,
|
|
30
|
+
lineHeight: 22,
|
|
31
|
+
fontWeight: '400'
|
|
32
|
+
},
|
|
33
|
+
label: {
|
|
34
|
+
fontSize: 14,
|
|
35
|
+
lineHeight: 18,
|
|
36
|
+
fontWeight: '600',
|
|
37
|
+
letterSpacing: 0.2
|
|
38
|
+
},
|
|
39
|
+
caption: {
|
|
40
|
+
fontSize: 12,
|
|
41
|
+
lineHeight: 16,
|
|
42
|
+
fontWeight: '400'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const radii = {
|
|
46
|
+
sm: 4,
|
|
47
|
+
md: 8,
|
|
48
|
+
pill: 999
|
|
49
|
+
};
|
|
50
|
+
const media = {
|
|
51
|
+
aspectRatio: {
|
|
52
|
+
product: 1,
|
|
53
|
+
banner: 16 / 9,
|
|
54
|
+
thumbnail: 1
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
function elevation(shadowColor, opacity) {
|
|
58
|
+
return {
|
|
59
|
+
card: {
|
|
60
|
+
shadowColor,
|
|
61
|
+
shadowOffset: {
|
|
62
|
+
width: 0,
|
|
63
|
+
height: 1
|
|
64
|
+
},
|
|
65
|
+
shadowOpacity: opacity,
|
|
66
|
+
shadowRadius: 3,
|
|
67
|
+
elevation: 2
|
|
68
|
+
},
|
|
69
|
+
modal: {
|
|
70
|
+
shadowColor,
|
|
71
|
+
shadowOffset: {
|
|
72
|
+
width: 0,
|
|
73
|
+
height: 6
|
|
74
|
+
},
|
|
75
|
+
shadowOpacity: opacity * 1.6,
|
|
76
|
+
shadowRadius: 16,
|
|
77
|
+
elevation: 12
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Every foreground/background pair below clears WCAG AA (4.5:1), verified by `kratos.test.ts`.
|
|
84
|
+
*/
|
|
85
|
+
export const kratosLight = defineTheme({
|
|
86
|
+
colors: {
|
|
87
|
+
background: '#FFFFFF',
|
|
88
|
+
surface: '#FFFFFF',
|
|
89
|
+
surfaceMuted: '#F4F4F5',
|
|
90
|
+
text: '#18181B',
|
|
91
|
+
textMuted: '#52525B',
|
|
92
|
+
textInverse: '#FFFFFF',
|
|
93
|
+
border: '#D4D4D8',
|
|
94
|
+
primary: '#1A56DB',
|
|
95
|
+
onPrimary: '#FFFFFF',
|
|
96
|
+
danger: '#B3261E',
|
|
97
|
+
success: '#146C43'
|
|
98
|
+
},
|
|
99
|
+
spacing,
|
|
100
|
+
typography,
|
|
101
|
+
radii,
|
|
102
|
+
elevation: elevation('#000000', 0.12),
|
|
103
|
+
media
|
|
104
|
+
});
|
|
105
|
+
export const kratosDark = defineTheme({
|
|
106
|
+
colors: {
|
|
107
|
+
background: '#0B0B0F',
|
|
108
|
+
surface: '#17171B',
|
|
109
|
+
surfaceMuted: '#27272A',
|
|
110
|
+
text: '#F4F4F5',
|
|
111
|
+
textMuted: '#A1A1AA',
|
|
112
|
+
textInverse: '#18181B',
|
|
113
|
+
border: '#3F3F46',
|
|
114
|
+
primary: '#93B4FF',
|
|
115
|
+
onPrimary: '#0B0B0F',
|
|
116
|
+
danger: '#FF8A80',
|
|
117
|
+
success: '#6EE7A8'
|
|
118
|
+
},
|
|
119
|
+
spacing,
|
|
120
|
+
typography,
|
|
121
|
+
radii,
|
|
122
|
+
elevation: elevation('#000000', 0.5),
|
|
123
|
+
media
|
|
124
|
+
});
|
|
125
|
+
export const kratos = {
|
|
126
|
+
name: 'Kratos',
|
|
127
|
+
light: kratosLight,
|
|
128
|
+
dark: kratosDark
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=kratos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defineTheme","spacing","xs","sm","md","lg","xl","xxl","typography","display","fontSize","lineHeight","fontWeight","heading","subheading","body","label","letterSpacing","caption","radii","pill","media","aspectRatio","product","banner","thumbnail","elevation","shadowColor","opacity","card","shadowOffset","width","height","shadowOpacity","shadowRadius","modal","kratosLight","colors","background","surface","surfaceMuted","text","textMuted","textInverse","border","primary","onPrimary","danger","success","kratosDark","kratos","name","light","dark"],"sourceRoot":"../../src","sources":["kratos.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAqC,YAAS;AAElE,MAAMC,OAAO,GAAG;EAAEC,EAAE,EAAE,CAAC;EAAEC,EAAE,EAAE,CAAC;EAAEC,EAAE,EAAE,EAAE;EAAEC,EAAE,EAAE,EAAE;EAAEC,EAAE,EAAE,EAAE;EAAEC,GAAG,EAAE;AAAG,CAAC;AAEjE,MAAMC,UAAU,GAAG;EACjBC,OAAO,EAAE;IAAEC,QAAQ,EAAE,EAAE;IAAEC,UAAU,EAAE,EAAE;IAAEC,UAAU,EAAE;EAAM,CAAC;EAC5DC,OAAO,EAAE;IAAEH,QAAQ,EAAE,EAAE;IAAEC,UAAU,EAAE,EAAE;IAAEC,UAAU,EAAE;EAAM,CAAC;EAC5DE,UAAU,EAAE;IAAEJ,QAAQ,EAAE,EAAE;IAAEC,UAAU,EAAE,EAAE;IAAEC,UAAU,EAAE;EAAM,CAAC;EAC/DG,IAAI,EAAE;IAAEL,QAAQ,EAAE,EAAE;IAAEC,UAAU,EAAE,EAAE;IAAEC,UAAU,EAAE;EAAM,CAAC;EACzDI,KAAK,EAAE;IAAEN,QAAQ,EAAE,EAAE;IAAEC,UAAU,EAAE,EAAE;IAAEC,UAAU,EAAE,KAAK;IAAEK,aAAa,EAAE;EAAI,CAAC;EAC9EC,OAAO,EA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AS,CAAC,SAAS,EAAE,IAAI,CAAC;EACrCL;AACF,CAAC,CAAC;AAEF,OAAO,MAAM4B,UAAU,GAAGjD,WAAW,CAAC;EACpCqC,MAAM,EAAE;IACNC,UAAU,EAAE,SAAS;IACrBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,SAAS;IACpBC,WAAW,EAAE,SAAS;IACtBC,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE,SAAS;IAClBC,SAAS,EAAE,SAAS;IACpBC,MAAM,EAAE,SAAS;IACjBC,OAAO,EAAE;EACX,CAAC;EACD/C,OAAO;EACPO,UAAU;EACVW,KAAK;EACLO,SAAS,EAAEA,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC;EACpCL;AACF,CAAC,CAAC;AAEF,OAAO,MAAM6B,MAAkB,GAAG;EAChCC,IAAI,EAAE,QAAQ;EACdC,KAAK,EAAEhB,WAAW;EAClBiB,IAAI,EAAEJ;AACR,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getMediaBaseUrl, resolveMediaCandidates, useLaconiusConfig } from '@laconius/core';
|
|
4
|
+
import { Image } from 'expo-image';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { useTheme } from "./hooks.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* `expo-image` implements srcset semantics against the measured container, so Laconius hands it
|
|
10
|
+
* the whole candidate set and never picks a format for a device class.
|
|
11
|
+
*/
|
|
12
|
+
export function useMedia(media, options = {}) {
|
|
13
|
+
const config = useLaconiusConfig();
|
|
14
|
+
const {
|
|
15
|
+
role,
|
|
16
|
+
maxFormat
|
|
17
|
+
} = options;
|
|
18
|
+
return useMemo(() => ({
|
|
19
|
+
sources: resolveMediaCandidates(media, {
|
|
20
|
+
baseUrl: getMediaBaseUrl(config),
|
|
21
|
+
role,
|
|
22
|
+
maxFormat,
|
|
23
|
+
formats: config.ui?.media?.formats,
|
|
24
|
+
roles: config.ui?.media?.roles
|
|
25
|
+
}),
|
|
26
|
+
altText: media?.altText
|
|
27
|
+
}), [config, media, role, maxFormat]);
|
|
28
|
+
}
|
|
29
|
+
export function Media({
|
|
30
|
+
media,
|
|
31
|
+
mediaRole,
|
|
32
|
+
maxFormat,
|
|
33
|
+
aspectRatio,
|
|
34
|
+
decorative = false,
|
|
35
|
+
style,
|
|
36
|
+
...rest
|
|
37
|
+
}) {
|
|
38
|
+
const theme = useTheme();
|
|
39
|
+
const {
|
|
40
|
+
sources,
|
|
41
|
+
altText
|
|
42
|
+
} = useMedia(media, {
|
|
43
|
+
role: mediaRole,
|
|
44
|
+
maxFormat
|
|
45
|
+
});
|
|
46
|
+
const ratio = typeof aspectRatio === 'string' ? theme.media.aspectRatio[aspectRatio] : aspectRatio;
|
|
47
|
+
return /*#__PURE__*/_jsx(Image, {
|
|
48
|
+
source: sources,
|
|
49
|
+
contentFit: "contain",
|
|
50
|
+
accessible: !decorative,
|
|
51
|
+
accessibilityRole: decorative ? undefined : 'image',
|
|
52
|
+
accessibilityLabel: decorative ? undefined : altText,
|
|
53
|
+
accessibilityElementsHidden: decorative,
|
|
54
|
+
importantForAccessibility: decorative ? 'no-hide-descendants' : 'auto',
|
|
55
|
+
style: [ratio === undefined ? null : {
|
|
56
|
+
aspectRatio: ratio
|
|
57
|
+
}, style],
|
|
58
|
+
...rest
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=media.js.map
|