@stack-spot/citric-react 0.30.2 → 0.30.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAK9D,KAAK,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE9G,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,CAAE,SAAQ,eAAe,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAC7H;;;;OAIG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAC5D;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;IACxD;;;;OAIG;IACH,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CACjC;AAGD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,aAAa,IAAI,CAC/C,CAAC,SAAS,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CACjD,CAAC,SAAS,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GACxD,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,CAAA;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GACD,CAAC,SAAS,aAAa,kEAA0E,SAAS,CAAC,CAAC,CAAC,4CAc5H,CAAA"}
|
package/dist/components/Card.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { listToClass } from '@stack-spot/portal-theme';
|
|
3
|
+
import { useCitricController } from '../context/hooks.js';
|
|
3
4
|
import { applyStyles } from '../utils/css.js';
|
|
4
5
|
import { withRef } from '../utils/react.js';
|
|
5
|
-
import { CitricComponent } from './CitricComponent.js';
|
|
6
|
+
import { asCitricProps, CitricComponent } from './CitricComponent.js';
|
|
6
7
|
/**
|
|
7
8
|
* Renders a box with padding, border and background-color. If the card is focusable or has an onClick listener, hover events are also
|
|
8
9
|
* present.
|
|
@@ -13,7 +14,17 @@ import { CitricComponent } from './CitricComponent.js';
|
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
16
|
export const Card = withRef(function Card({ tag = 'div', onClick, size, bgLevel, className, children, ...props }) {
|
|
17
|
+
const citric = useCitricController();
|
|
16
18
|
const clickable = onClick || props.tabIndex === 0 || tag === 'button' || tag === 'a';
|
|
17
|
-
|
|
19
|
+
const componentProps = {
|
|
20
|
+
tag,
|
|
21
|
+
component: 'card',
|
|
22
|
+
onClick,
|
|
23
|
+
className: listToClass([clickable && 'clickable', size, bgLevel && `bg-${bgLevel}`, className]),
|
|
24
|
+
...applyStyles(props),
|
|
25
|
+
};
|
|
26
|
+
return tag === 'a' && citric?.renderLink
|
|
27
|
+
? citric.renderLink(asCitricProps(componentProps))
|
|
28
|
+
: _jsx(CitricComponent, { ...componentProps, children: children });
|
|
18
29
|
});
|
|
19
30
|
//# sourceMappingURL=Card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAgClE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CACzB,SAAS,IAAI,CAA0B,EAAE,GAAG,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAgB;IACzH,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAA;IACpC,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,GAAG,CAAA;IACpF,MAAM,cAAc,GAAG;QACrB,GAAG;QACH,SAAS,EAAE,MAAM;QACjB,OAAO;QACP,SAAS,EAAE,WAAW,CAAC,CAAC,SAAS,IAAI,WAAW,EAAE,IAAI,EAAE,OAAO,IAAI,MAAM,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;QAC/F,GAAG,WAAW,CAAC,KAAK,CAAC;KACb,CAAA;IACV,OAAO,GAAG,KAAK,GAAG,IAAI,MAAM,EAAE,UAAU;QACtC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAClD,CAAC,CAAC,KAAC,eAAe,OAAK,cAAc,YAAG,QAAQ,GAAmB,CAAA;AACvE,CAAC,CACF,CAAA"}
|
package/package.json
CHANGED
package/src/components/Card.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { listToClass } from '@stack-spot/portal-theme'
|
|
2
|
+
import { useCitricController } from '../context/hooks'
|
|
2
3
|
import { WithColorScheme, WithStyleShortcuts } from '../types'
|
|
3
4
|
import { applyStyles } from '../utils/css'
|
|
4
5
|
import { withRef } from '../utils/react'
|
|
5
|
-
import { CitricComponent } from './CitricComponent'
|
|
6
|
+
import { asCitricProps, CitricComponent } from './CitricComponent'
|
|
6
7
|
|
|
7
8
|
type SupportedTags = 'div' | 'header' | 'ul' | 'ol' | 'dl' | 'section' | 'article' | 'a' | 'button' | 'header'
|
|
8
9
|
|
|
@@ -45,17 +46,17 @@ export type CardProps<T extends SupportedTags> = (
|
|
|
45
46
|
*/
|
|
46
47
|
export const Card = withRef(
|
|
47
48
|
function Card<T extends SupportedTags>({ tag = 'div', onClick, size, bgLevel, className, children, ...props }: CardProps<T>) {
|
|
49
|
+
const citric = useCitricController()
|
|
48
50
|
const clickable = onClick || props.tabIndex === 0 || tag === 'button' || tag === 'a'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</CitricComponent>
|
|
59
|
-
)
|
|
51
|
+
const componentProps = {
|
|
52
|
+
tag,
|
|
53
|
+
component: 'card',
|
|
54
|
+
onClick,
|
|
55
|
+
className: listToClass([clickable && 'clickable', size, bgLevel && `bg-${bgLevel}`, className]),
|
|
56
|
+
...applyStyles(props),
|
|
57
|
+
} as const
|
|
58
|
+
return tag === 'a' && citric?.renderLink
|
|
59
|
+
? citric.renderLink(asCitricProps(componentProps))
|
|
60
|
+
: <CitricComponent {...componentProps}>{children}</CitricComponent>
|
|
60
61
|
},
|
|
61
62
|
)
|