@optiaxiom/proteus 0.1.13 → 0.1.14

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,32 +0,0 @@
1
- @layer optiaxiom._14psyja;
2
- @layer optiaxiom._14psyja {
3
- .ProteusQuestionItem__uar8vn2 {
4
- background-color: var(--ax-colors-bg-page);
5
- border-color: var(--ax-colors-bg-page);
6
- cursor: pointer;
7
- }
8
- .ProteusQuestionItem__uar8vn2:has(.ProteusQuestionItem__uar8vn1:checked) {
9
- background-color: var(--ax-colors-bg-accent-subtle);
10
- border-color: var(--ax-colors-bg-accent-light);
11
- }
12
- .ProteusQuestionItem__uar8vn2:has(.ProteusQuestionItem__uar8vn1:disabled) {
13
- cursor: default;
14
- opacity: 0.5;
15
- pointer-events: none;
16
- }
17
- .ProteusQuestionItem__uar8vn2:has(.ProteusQuestionItem__uar8vn1:focus-visible) {
18
- outline: 2px solid var(--ax-colors-border-focus);
19
- outline-offset: 1px;
20
- }
21
- .ProteusQuestionItem__uar8vn3 {
22
- background-color: var(--ax-colors-bg-avatar-neutral);
23
- }
24
- .ProteusQuestionItem__uar8vn0:has(.ProteusQuestionItem__uar8vn1:checked) .ProteusQuestionItem__uar8vn3 {
25
- background-color: #CDD8FC;
26
- }
27
- @media (hover: hover) {
28
- .ProteusQuestionItem__uar8vn2:hover {
29
- background-color: var(--ax-colors-bg-secondary);
30
- }
31
- }
32
- }
@@ -1,9 +0,0 @@
1
- import './../assets/src/proteus-question/ProteusQuestionItem.css.ts.vanilla-U4mkv5De.css';
2
- import { recipe } from '@optiaxiom/react/css-runtime';
3
-
4
- var addon = recipe({base:[{display:'grid',fontWeight:'500',placeItems:'center',rounded:'lg',size:'md',transition:'colors'},'ProteusQuestionItem__uar8vn3'],variants:{cursor:{pointer:{cursor:'pointer'}}}});
5
- var choice = recipe({base:[{border:'1',color:'fg.default',flexDirection:'column',fontSize:'md',gap:'8',px:'16',py:'12',rounded:'lg',transition:'colors'},'ProteusQuestionItem__uar8vn2','ProteusQuestionItem__uar8vn0'],variants:{cursor:{text:{cursor:'text'}}}});
6
- var choiceGroup = recipe({base:{flexDirection:'column',gap:'8'}});
7
- var input = recipe({base:'ProteusQuestionItem__uar8vn1'});
8
-
9
- export { addon, choice, choiceGroup, input };
@@ -1,119 +0,0 @@
1
- "use client";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useRef, createElement } from 'react';
4
- import { Group, Text, Box, Checkbox } from '@optiaxiom/react';
5
- import { VisuallyHidden, InlineInput } from '@optiaxiom/react/unstable';
6
- import { IconPencil } from '../icons/IconPencil.js';
7
- import { choiceGroup, choice, input, addon } from './ProteusQuestionItem-css.js';
8
-
9
- function ProteusQuestionItem({
10
- addonAfter,
11
- choiceRef,
12
- onValueChange,
13
- options,
14
- question,
15
- type,
16
- value
17
- }) {
18
- const otherInputRef = useRef(null);
19
- const otherValue = value?.find((v) => !options.includes(v));
20
- const otherChecked = otherValue !== void 0;
21
- return /* @__PURE__ */ jsxs(Group, { flexDirection: "column", gap: "16", children: [
22
- /* @__PURE__ */ jsxs(Group, { children: [
23
- /* @__PURE__ */ jsx(Text, { flex: "1", fontWeight: "500", children: question }),
24
- addonAfter
25
- ] }),
26
- /* @__PURE__ */ jsxs(Group, { ref: choiceRef, ...choiceGroup(), children: [
27
- options.map((option, index) => {
28
- const checked = type === "single_select" ? value?.[0] === option : value?.includes(option);
29
- const disabled = type === "single_select" && otherChecked && !!otherValue;
30
- return /* @__PURE__ */ createElement(Box, { asChild: true, ...choice(), key: option }, /* @__PURE__ */ jsxs("label", { children: [
31
- /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(Box, { asChild: true, ...input(), children: /* @__PURE__ */ jsx(
32
- "input",
33
- {
34
- checked,
35
- disabled,
36
- name: type === "single_select" ? "question-item" : void 0,
37
- onChange: () => {
38
- if (type === "single_select") {
39
- onValueChange([option]);
40
- } else {
41
- const current = value ?? [];
42
- onValueChange(
43
- checked ? current.filter((v) => v !== option) : [...current, option]
44
- );
45
- }
46
- },
47
- type: type === "single_select" ? "radio" : "checkbox",
48
- value: option
49
- }
50
- ) }) }),
51
- /* @__PURE__ */ jsxs(Group, { gap: "12", children: [
52
- /* @__PURE__ */ jsx(Box, { ...addon(), children: type === "single_select" ? index + 1 : /* @__PURE__ */ jsx(
53
- Checkbox,
54
- {
55
- checked,
56
- hidden: true,
57
- pointerEvents: "none",
58
- tabIndex: -1
59
- }
60
- ) }),
61
- /* @__PURE__ */ jsx(Group, { flex: "1", flexDirection: "column", gap: "2", children: /* @__PURE__ */ jsx(Text, { children: option }) })
62
- ] })
63
- ] }));
64
- }),
65
- /* @__PURE__ */ createElement(Box, { asChild: true, ...choice({ cursor: "text" }), key: "other" }, /* @__PURE__ */ jsxs("label", { children: [
66
- /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(Box, { asChild: true, ...input(), children: /* @__PURE__ */ jsx(
67
- "input",
68
- {
69
- checked: otherChecked,
70
- name: type === "single_select" ? "question-item" : void 0,
71
- onChange: () => {
72
- if (type === "single_select") {
73
- if (!otherValue) {
74
- onValueChange([""]);
75
- }
76
- }
77
- otherInputRef.current?.focus();
78
- },
79
- type: "checkbox",
80
- value: "other"
81
- }
82
- ) }) }),
83
- /* @__PURE__ */ jsxs(Group, { gap: "12", children: [
84
- /* @__PURE__ */ jsx(Box, { ...addon({ cursor: "pointer" }), children: type === "single_select" ? /* @__PURE__ */ jsx(IconPencil, {}) : /* @__PURE__ */ jsx(
85
- Checkbox,
86
- {
87
- checked: otherChecked,
88
- hidden: true,
89
- pointerEvents: "none",
90
- tabIndex: -1
91
- }
92
- ) }),
93
- /* @__PURE__ */ jsx(Group, { flex: "1", flexDirection: "column", gap: "2", children: /* @__PURE__ */ jsx(
94
- InlineInput,
95
- {
96
- label: "Something else",
97
- onValueChange: (text) => {
98
- if (type === "single_select") {
99
- onValueChange([text]);
100
- } else {
101
- const current = value ?? [];
102
- onValueChange([
103
- ...current.filter((v) => options.includes(v)),
104
- ...text ? [text] : []
105
- ]);
106
- }
107
- },
108
- ref: otherInputRef,
109
- value: otherValue ?? ""
110
- }
111
- ) })
112
- ] })
113
- ] }))
114
- ] })
115
- ] });
116
- }
117
- ProteusQuestionItem.displayName = "@optiaxiom/proteus/ProteusQuestionItem";
118
-
119
- export { ProteusQuestionItem };