fix(icons): render Nova Heroicons

This commit is contained in:
MeghdadFadaee committed 2026-07-30 13:53:07 +03:30
1 parent e18806baf6
commit ade3fc100a
7 files changed
+30 -2

No files matched your search

+20
View File
@@ -37,6 +37,7 @@ public function fields(NovaRequest $request): array
->add( ->add(
Approve::make(), Approve::make(),
icon: 'check', icon: 'check',
iconType: 'solid',
color: 'success', color: 'success',
activeWhen: fn (Model $model) => $model->approved, activeWhen: fn (Model $model) => $model->approved,
disabledWhen: fn (Model $model) => $model->approved, disabledWhen: fn (Model $model) => $model->approved,
@@ -71,6 +72,8 @@ view while removing them from the row ellipsis.
`add()` accepts the following named arguments: `add()` accepts the following named arguments:
- `icon`: a Nova icon name, such as `check` or `x-mark`. - `icon`: a Nova icon name, such as `check` or `x-mark`.
- `iconType`: Heroicons `outline`, `solid`, `mini`, or `micro`; defaults to
`outline`.
- `color`: `default`, `primary`, `success`, `danger`, `warning`, or `info`. - `color`: `default`, `primary`, `success`, `danger`, `warning`, or `info`.
- `variant`: `outline`, `solid`, or `ghost`. - `variant`: `outline`, `solid`, or `ghost`.
- `label`: button/accessibility label; defaults to the action name. - `label`: button/accessibility label; defaults to the action name.
@@ -87,6 +90,23 @@ view while removing them from the row ellipsis.
Callbacks receive `(Model $model, NovaRequest $request, Action $action)` and may Callbacks receive `(Model $model, NovaRequest $request, Action $action)` and may
declare only the leading arguments they need. declare only the leading arguments they need.
### Icons
Icons are rendered by Nova's `Icon` component from `laravel-nova-ui`, so the
package supports Heroicons v2.1.5+ while always using the exact Heroicons
release bundled by the installed Nova version. Use kebab-case names, including:
`check`, `x-mark`, `plus`, `minus`, `pencil-square`, `trash`, `eye`, `bolt`,
`arrow-path`, `arrow-down-tray`, `paper-airplane`, `play`, `pause`, `lock-closed`,
`lock-open`, `star`, `heart`, `bell`, `envelope`, `user`, `users`, `cog-6-tooth`,
`document`, `document-check`, `clipboard`, `magnifying-glass`, and
`exclamation-triangle`.
The package deliberately does not install a second Heroicons copy; importing
Nova's UI component avoids version conflicts. For reference, Nova 5.8.3 in the
test application declares and locks `@heroicons/vue` 2.2.0, whose icon API is
compatible with the supported 2.1.5 baseline.
## Notes and limitations ## Notes and limitations
- Actions must be normal resource actions registered by `actions()`. Pivot-only - Actions must be normal resource actions registered by `actions()`. Pivot-only
+1 -1
View File
@@ -1,2 +1,2 @@
/*! For license information please see field.js.LICENSE.txt */ /*! For license information please see field.js.LICENSE.txt */
(()=>{var e,t={673(e,t,r){"use strict";var n={};r.r(n),r.d(n,{hasBrowserEnv:()=>jt,hasStandardBrowserEnv:()=>Tt,hasStandardBrowserWebWorkerEnv:()=>Ct,navigator:()=>Pt,origin:()=>Nt});const o=Vue;var i=r(4383),s=r.n(i),a={nested:{type:Boolean,default:!1},preventInitialLoading:{type:Boolean,default:!1},showHelpText:{type:Boolean,default:!1},shownViaNewRelationModal:{type:Boolean,default:!1},resourceId:{type:[Number,String]},resourceName:{type:String},relatedResourceId:{type:[Number,String]},relatedResourceName:{type:String},field:{type:Object,required:!0},viaResource:{type:String,required:!1},viaResourceId:{type:[String,Number],required:!1},viaRelationship:{type:String,required:!1},relationshipType:{type:String,default:""},shouldOverrideMeta:{type:Boolean,default:!1},disablePagination:{type:Boolean,default:!1},clickAction:{type:String,default:"view",validator:function(e){return["edit","select","ignore","detail"].includes(e)}},mode:{type:String,default:"form",validator:function(e){return["form","modal","action-modal","action-fullscreen"].includes(e)}}};function u(e){return s()(a,e)}function c(e){return Boolean(null!=e&&null!=e&&""!==e)}function l(){return"undefined"!=typeof navigator&&"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}}const f="function"==typeof Proxy;let p,d;function h(){return void 0!==p||("undefined"!=typeof window&&window.performance?(p=!0,d=window.performance):"undefined"!=typeof globalThis&&(null===(e=globalThis.perf_hooks)||void 0===e?void 0:e.performance)?(p=!0,d=globalThis.perf_hooks.performance):p=!1),p?d.now():Date.now();var e}class y{constructor(e,t){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=e,this.hook=t;const r={};if(e.settings)for(const t in e.settings){const n=e.settings[t];r[t]=n.defaultValue}const n=`__vue-devtools-plugin-settings__${e.id}`;let o=Object.assign({},r);try{const e=localStorage.getItem(n),t=JSON.parse(e);Object.assign(o,t)}catch(e){}this.fallbacks={getSettings:()=>o,setSettings(e){try{localStorage.setItem(n,JSON.stringify(e))}catch(e){}o=e},now:()=>h()},t&&t.on("plugin:settings:set",(e,t)=>{e===this.plugin.id&&this.fallbacks.setSettings(t)}),this.proxiedOn=new Proxy({},{get:(e,t)=>this.target?this.target.on[t]:(...e)=>{this.onQueue.push({method:t,args:e})}}),this.proxiedTarget=new Proxy({},{get:(e,t)=>this.target?this.target[t]:"on"===t?this.proxiedOn:Object.keys(this.fallbacks).includes(t)?(...e)=>(this.targetQueue.push({method:t,args:e,resolve:()=>{}}),this.fallbacks[t](...e)):(...e)=>new Promise(r=>{this.targetQueue.push({method:t,args:e,resolve:r})})})}async setRealTarget(e){this.target=e;for(const e of this.onQueue)this.target.on[e.method](...e.args);for(const e of this.targetQueue)e.resolve(await this.target[e.method](...e.args))}}function g(e,t){const r=e,n=l(),o=l().__VUE_DEVTOOLS_GLOBAL_HOOK__,i=f&&r.enableEarlyProxy;if(!o||!n.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__&&i){const e=i?new y(r,o):null;(n.__VUE_DEVTOOLS_PLUGINS__=n.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:r,setupFn:t,proxy:e}),e&&t(e.proxiedTarget)}else o.emit("devtools-plugin:setup",e,t)}var v="store";function b(e,t){Object.keys(e).forEach(function(r){return t(e[r],r)})}function m(e){return null!==e&&"object"==typeof e}function w(e,t,r){return t.indexOf(e)<0&&(r&&r.prepend?t.unshift(e):t.push(e)),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}function O(e,t){e._actions=Object.create(null),e._mutations=Object.create(null),e._wrappedGetters=Object.create(null),e._modulesNamespaceMap=Object.create(null);var r=e.state;E(e,r,[],e._modules.root,!0),_(e,r,t)}function _(e,t,r){var n=e._state,i=e._scope;e.getters={},e._makeLocalGettersCache=Object.create(null);var s=e._wrappedGetters,a={},u={},c=(0,o.effectScope)(!0);c.run(function(){b(s,function(t,r){a[r]=function(e,t){return function(){return e(t)}}(t,e),u[r]=(0,o.computed)(function(){return a[r]()}),Object.defineProperty(e.getters,r,{get:function(){return u[r].value},enumerable:!0})})}),e._state=(0,o.reactive)({data:t}),e._scope=c,e.strict&&function(e){(0,o.watch)(function(){return e._state.data},function(){0},{deep:!0,flush:"sync"})}(e),n&&r&&e._withCommit(function(){n.data=null}),i&&i.stop()}function E(e,t,r,n,o){var i=!r.length,s=e._modules.getNamespace(r);if(n.namespaced&&(e._modulesNamespaceMap[s],e._modulesNamespaceMap[s]=n),!i&&!o){var a=S(t,r.slice(0,-1)),u=r[r.length-1];e._withCommit(function(){a[u]=n.state})}var c=n.context=function(e,t,r){var n=""===t,o={dispatch:n?e.dispatch:function(r,n,o){var i=x(r,n,o),s=i.payload,a=i.options,u=i.type;return a&&a.root||(u=t+u),e.dispatch(u,s)},commit:n?e.commit:function(r,n,o){var i=x(r,n,o),s=i.payload,a=i.options,u=i.type;a&&a.root||(u=t+u),e.commit(u,s,a)}};return Object.defineProperties(o,{getters:{get:n?function(){return e.getters}:function(){return R(e,t)}},state:{get:function(){return S(e.state,r)}}}),o}(e,s,r);n.forEachMutation(function(t,r){!function(e,t,r,n){var o=e._mutations[t]||(e._mutations[t]=[]);o.push(function(t){r.call(Line truncated (()=>{var e,t={722(e,t,r){"use strict";var n={};r.r(n),r.d(n,{hasBrowserEnv:()=>Pt,hasStandardBrowserEnv:()=>Ct,hasStandardBrowserWebWorkerEnv:()=>Nt,navigator:()=>Tt,origin:()=>Ut});const o=Vue,i=LaravelNovaUi;var s=r(4383),a=r.n(s),u={nested:{type:Boolean,default:!1},preventInitialLoading:{type:Boolean,default:!1},showHelpText:{type:Boolean,default:!1},shownViaNewRelationModal:{type:Boolean,default:!1},resourceId:{type:[Number,String]},resourceName:{type:String},relatedResourceId:{type:[Number,String]},relatedResourceName:{type:String},field:{type:Object,required:!0},viaResource:{type:String,required:!1},viaResourceId:{type:[String,Number],required:!1},viaRelationship:{type:String,required:!1},relationshipType:{type:String,default:""},shouldOverrideMeta:{type:Boolean,default:!1},disablePagination:{type:Boolean,default:!1},clickAction:{type:String,default:"view",validator:function(e){return["edit","select","ignore","detail"].includes(e)}},mode:{type:String,default:"form",validator:function(e){return["form","modal","action-modal","action-fullscreen"].includes(e)}}};function c(e){return a()(u,e)}function l(e){return Boolean(null!=e&&null!=e&&""!==e)}function f(){return"undefined"!=typeof navigator&&"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:{}}const p="function"==typeof Proxy;let d,h;function y(){return void 0!==d||("undefined"!=typeof window&&window.performance?(d=!0,h=window.performance):"undefined"!=typeof globalThis&&(null===(e=globalThis.perf_hooks)||void 0===e?void 0:e.performance)?(d=!0,h=globalThis.perf_hooks.performance):d=!1),d?h.now():Date.now();var e}class g{constructor(e,t){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=e,this.hook=t;const r={};if(e.settings)for(const t in e.settings){const n=e.settings[t];r[t]=n.defaultValue}const n=`__vue-devtools-plugin-settings__${e.id}`;let o=Object.assign({},r);try{const e=localStorage.getItem(n),t=JSON.parse(e);Object.assign(o,t)}catch(e){}this.fallbacks={getSettings:()=>o,setSettings(e){try{localStorage.setItem(n,JSON.stringify(e))}catch(e){}o=e},now:()=>y()},t&&t.on("plugin:settings:set",(e,t)=>{e===this.plugin.id&&this.fallbacks.setSettings(t)}),this.proxiedOn=new Proxy({},{get:(e,t)=>this.target?this.target.on[t]:(...e)=>{this.onQueue.push({method:t,args:e})}}),this.proxiedTarget=new Proxy({},{get:(e,t)=>this.target?this.target[t]:"on"===t?this.proxiedOn:Object.keys(this.fallbacks).includes(t)?(...e)=>(this.targetQueue.push({method:t,args:e,resolve:()=>{}}),this.fallbacks[t](...e)):(...e)=>new Promise(r=>{this.targetQueue.push({method:t,args:e,resolve:r})})})}async setRealTarget(e){this.target=e;for(const e of this.onQueue)this.target.on[e.method](...e.args);for(const e of this.targetQueue)e.resolve(await this.target[e.method](...e.args))}}function v(e,t){const r=e,n=f(),o=f().__VUE_DEVTOOLS_GLOBAL_HOOK__,i=p&&r.enableEarlyProxy;if(!o||!n.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__&&i){const e=i?new g(r,o):null;(n.__VUE_DEVTOOLS_PLUGINS__=n.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:r,setupFn:t,proxy:e}),e&&t(e.proxiedTarget)}else o.emit("devtools-plugin:setup",e,t)}var b="store";function m(e,t){Object.keys(e).forEach(function(r){return t(e[r],r)})}function w(e){return null!==e&&"object"==typeof e}function O(e,t,r){return t.indexOf(e)<0&&(r&&r.prepend?t.unshift(e):t.push(e)),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}function _(e,t){e._actions=Object.create(null),e._mutations=Object.create(null),e._wrappedGetters=Object.create(null),e._modulesNamespaceMap=Object.create(null);var r=e.state;R(e,r,[],e._modules.root,!0),E(e,r,t)}function E(e,t,r){var n=e._state,i=e._scope;e.getters={},e._makeLocalGettersCache=Object.create(null);var s=e._wrappedGetters,a={},u={},c=(0,o.effectScope)(!0);c.run(function(){m(s,function(t,r){a[r]=function(e,t){return function(){return e(t)}}(t,e),u[r]=(0,o.computed)(function(){return a[r]()}),Object.defineProperty(e.getters,r,{get:function(){return u[r].value},enumerable:!0})})}),e._state=(0,o.reactive)({data:t}),e._scope=c,e.strict&&function(e){(0,o.watch)(function(){return e._state.data},function(){0},{deep:!0,flush:"sync"})}(e),n&&r&&e._withCommit(function(){n.data=null}),i&&i.stop()}function R(e,t,r,n,o){var i=!r.length,s=e._modules.getNamespace(r);if(n.namespaced&&(e._modulesNamespaceMap[s],e._modulesNamespaceMap[s]=n),!i&&!o){var a=x(t,r.slice(0,-1)),u=r[r.length-1];e._withCommit(function(){a[u]=n.state})}var c=n.context=function(e,t,r){var n=""===t,o={dispatch:n?e.dispatch:function(r,n,o){var i=A(r,n,o),s=i.payload,a=i.options,u=i.type;return a&&a.root||(u=t+u),e.dispatch(u,s)},commit:n?e.commit:function(r,n,o){var i=A(r,n,o),s=i.payload,a=i.options,u=i.type;a&&a.root||(u=t+u),e.commit(u,s,a)}};return Object.defineProperties(o,{getters:{get:n?function(){return e.getters}:function(){return S(e,t)}},state:{get:function(){return x(e.state,r)}}}),o}(e,s,r);n.forEachMutation(function(t,r){!function(e,t,r,n){var o=e._mutations[t]||(e._mutations[t]=[]);o.push(funLine truncated
+1 -1
View File
@@ -1,4 +1,4 @@
{ {
"/js/field.js": "/js/field.js?id=56e41090bedfddb3143c04e6a31b515a", "/js/field.js": "/js/field.js?id=c6ec498762306920f63c189fba6ee8c6",
"/css/field.css": "/css/field.css?id=fa4c2caaf5807af420c6944bb9a2969c" "/css/field.css": "/css/field.css?id=fa4c2caaf5807af420c6944bb9a2969c"
} }
+2
View File
@@ -21,6 +21,7 @@
> >
<Icon <Icon
:name="button.icon" :name="button.icon"
:type="button.iconType"
class="nova-row-actions__icon" class="nova-row-actions__icon"
aria-hidden="true" aria-hidden="true"
/> />
@@ -68,6 +69,7 @@
<script setup> <script setup>
import { computed, getCurrentInstance } from 'vue' import { computed, getCurrentInstance } from 'vue'
import { Icon } from 'laravel-nova-ui'
import { useActions } from '@/composables/useActions' import { useActions } from '@/composables/useActions'
import { resolveActionContext } from '../actionContext.mjs' import { resolveActionContext } from '../actionContext.mjs'
+1
View File
@@ -20,6 +20,7 @@ final class RowAction
public function __construct( public function __construct(
public readonly Action $action, public readonly Action $action,
public readonly string $icon, public readonly string $icon,
public readonly string $iconType,
public readonly string $color, public readonly string $color,
public readonly string $variant, public readonly string $variant,
public readonly Closure|Stringable|string|null $label, public readonly Closure|Stringable|string|null $label,
+3
View File
@@ -44,6 +44,7 @@ class RowActions extends Field
public function add( public function add(
Action $action, Action $action,
string $icon = 'play', string $icon = 'play',
string $iconType = 'outline',
string $color = 'default', string $color = 'default',
string $variant = 'outline', string $variant = 'outline',
Closure|Stringable|string|null $label = null, Closure|Stringable|string|null $label = null,
@@ -60,6 +61,7 @@ class RowActions extends Field
$this->rowActions[] = new RowAction( $this->rowActions[] = new RowAction(
action: $action, action: $action,
icon: $icon, icon: $icon,
iconType: $iconType,
color: $color, color: $color,
variant: $variant, variant: $variant,
label: $label, label: $label,
@@ -127,6 +129,7 @@ class RowActions extends Field
'key' => $action->uriKey().'-'.$button->sequence.'-'.$index, 'key' => $action->uriKey().'-'.$button->sequence.'-'.$index,
'action' => $nativeAction, 'action' => $nativeAction,
'icon' => $button->icon, 'icon' => $button->icon,
'iconType' => $button->iconType,
'color' => $button->color, 'color' => $button->color,
'variant' => $button->variant, 'variant' => $button->variant,
'label' => $label, 'label' => $label,
+2
View File
@@ -38,6 +38,7 @@ class RowActionsTest extends TestCase
->add( ->add(
ConfigurableAction::make()->withoutConfirmation(), ConfigurableAction::make()->withoutConfirmation(),
icon: 'bolt', icon: 'bolt',
iconType: 'solid',
color: 'warning', color: 'warning',
variant: 'solid', variant: 'solid',
label: fn (Model $model) => 'Run '.$model->getKey(), label: fn (Model $model) => 'Run '.$model->getKey(),
@@ -55,6 +56,7 @@ class RowActionsTest extends TestCase
$this->assertSame('reason', $action['action']['fields'][0]['attribute']); $this->assertSame('reason', $action['action']['fields'][0]['attribute']);
$this->assertFalse($action['action']['withoutConfirmation']); $this->assertFalse($action['action']['withoutConfirmation']);
$this->assertSame('bolt', $action['icon']); $this->assertSame('bolt', $action['icon']);
$this->assertSame('solid', $action['iconType']);
$this->assertSame('warning', $action['color']); $this->assertSame('warning', $action['color']);
$this->assertSame('solid', $action['variant']); $this->assertSame('solid', $action['variant']);
$this->assertSame('Run 17', $action['label']); $this->assertSame('Run 17', $action['label']);